Lines Matching defs:slave
105 snd_pcm_share_slave_t *slave;
122 static snd_pcm_uframes_t snd_pcm_share_slave_avail(snd_pcm_share_slave_t *slave)
125 snd_pcm_t *pcm = slave->pcm;
126 avail = slave->hw_ptr - *pcm->appl.ptr;
135 /* Return number of frames to mmap_commit the slave */
136 static snd_pcm_uframes_t _snd_pcm_share_slave_forward(snd_pcm_share_slave_t *slave)
145 slave_avail = snd_pcm_share_slave_avail(slave);
146 boundary = slave->pcm->boundary;
147 buffer_size = slave->pcm->buffer_size;
150 slave_appl_ptr = *slave->pcm->appl.ptr;
151 list_for_each(i, &slave->clients) {
178 safety_frames = slave->safety_threshold - slave_hw_avail;
202 snd_pcm_share_slave_t *slave = share->slave;
203 snd_pcm_t *spcm = slave->pcm;
210 // printf("state=%s hw_ptr=%ld appl_ptr=%ld slave appl_ptr=%ld safety=%ld silence=%ld\n", snd_pcm_state_name(share->state), slave->hw_ptr, share->appl_ptr, *slave->pcm->appl_ptr, slave->safety_threshold, slave->silence_frames);
221 share->hw_ptr = slave->hw_ptr;
228 slave_avail = snd_pcm_share_slave_avail(slave);
232 snd_pcm_sframes_t safety_missing = slave_hw_avail - slave->safety_threshold;
312 if (avail >= slave->silence_frames) {
315 snd_pcm_uframes_t size = slave->silence_frames;
330 silence_missing = slave->silence_frames - avail;
339 static snd_pcm_uframes_t _snd_pcm_share_slave_missing(snd_pcm_share_slave_t *slave)
343 /* snd_pcm_sframes_t avail = */ snd_pcm_avail_update(slave->pcm);
344 slave->hw_ptr = *slave->pcm->hw.ptr;
345 list_for_each(i, &slave->clients) {
357 snd_pcm_share_slave_t *slave = data;
358 snd_pcm_t *spcm = slave->pcm;
362 pfd[0].fd = slave->poll[0];
369 Pthread_mutex_lock(&slave->mutex);
370 err = pipe(slave->poll);
375 while (slave->open_count > 0) {
378 missing = _snd_pcm_share_slave_missing(slave);
383 hw_ptr = slave->hw_ptr + missing;
395 snd_pcm_sw_params_set_avail_min(spcm, &slave->sw_params, avail_min);
396 err = snd_pcm_sw_params(spcm, &slave->sw_params);
402 slave->polling = 1;
403 Pthread_mutex_unlock(&slave->mutex);
405 Pthread_mutex_lock(&slave->mutex);
411 slave->polling = 0;
412 pthread_cond_wait(&slave->poll_cond, &slave->mutex);
415 Pthread_mutex_unlock(&slave->mutex);
422 snd_pcm_share_slave_t *slave = share->slave;
423 snd_pcm_t *spcm = slave->pcm;
426 slave->hw_ptr = *slave->pcm->hw.ptr;
429 if (!slave->polling) {
430 pthread_cond_signal(&slave->poll_cond);
436 hw_ptr = slave->hw_ptr + missing;
448 snd_pcm_sw_params_set_avail_min(spcm, &slave->sw_params, avail_min);
449 err = snd_pcm_sw_params(spcm, &slave->sw_params);
471 return snd_pcm_info(share->slave->pcm, info);
477 snd_pcm_share_slave_t *slave = share->slave;
490 if (slave->format != SND_PCM_FORMAT_UNKNOWN) {
491 err = _snd_pcm_hw_params_set_format(params, slave->format);
496 if (slave->rate >= 0) {
498 slave->rate, 0);
502 if (slave->period_time >= 0) {
504 slave->period_time, 0);
508 if (slave->buffer_time >= 0) {
510 slave->buffer_time, 0);
521 snd_pcm_share_slave_t *slave = share->slave;
527 slave->channels, 0);
595 return snd_pcm_hw_refine(share->slave->pcm, params);
601 return _snd_pcm_hw_params(share->slave->pcm, params);
617 snd_pcm_share_slave_t *slave = share->slave;
618 snd_pcm_t *spcm = slave->pcm;
620 Pthread_mutex_lock(&slave->mutex);
621 if (slave->setup_count) {
642 SNDERR("slave is already running with incompatible setup");
654 snd_pcm_sw_params_current(slave->pcm, &slave->sw_params);
656 slave->safety_threshold = slave->pcm->rate * 30 / 1000;
657 slave->safety_threshold += slave->pcm->period_size - 1;
658 slave->safety_threshold -= slave->safety_threshold % slave->pcm->period_size;
659 slave->silence_frames = slave->safety_threshold;
660 if (slave->pcm->stream == SND_PCM_STREAM_PLAYBACK)
661 snd_pcm_areas_silence(slave->pcm->running_areas, 0, slave->pcm->channels, slave->pcm->buffer_size, slave->pcm->format);
664 slave->setup_count++;
666 Pthread_mutex_unlock(&slave->mutex);
673 snd_pcm_share_slave_t *slave = share->slave;
675 Pthread_mutex_lock(&slave->mutex);
676 slave->setup_count--;
677 if (slave->setup_count == 0)
678 err = snd_pcm_hw_free(slave->pcm);
680 Pthread_mutex_unlock(&slave->mutex);
692 snd_pcm_share_slave_t *slave = share->slave;
695 Pthread_mutex_lock(&slave->mutex);
708 err = snd_pcm_delay(slave->pcm, &sd);
716 Pthread_mutex_unlock(&slave->mutex);
729 snd_pcm_share_slave_t *slave = share->slave;
736 return snd_pcm_hwsync(slave->pcm);
742 snd_pcm_share_slave_t *slave = share->slave;
744 Pthread_mutex_lock(&slave->mutex);
746 Pthread_mutex_unlock(&slave->mutex);
753 snd_pcm_share_slave_t *slave = share->slave;
766 return snd_pcm_delay(slave->pcm, delayp);
772 snd_pcm_share_slave_t *slave = share->slave;
774 Pthread_mutex_lock(&slave->mutex);
776 Pthread_mutex_unlock(&slave->mutex);
783 snd_pcm_share_slave_t *slave = share->slave;
785 Pthread_mutex_lock(&slave->mutex);
787 avail = snd_pcm_avail_update(slave->pcm);
789 Pthread_mutex_unlock(&slave->mutex);
792 share->hw_ptr = *slave->pcm->hw.ptr;
794 Pthread_mutex_unlock(&slave->mutex);
805 snd_pcm_share_slave_t *slave = share->slave;
807 Pthread_mutex_lock(&slave->mutex);
808 err = snd_pcm_htimestamp(slave->pcm, avail, tstamp);
809 Pthread_mutex_unlock(&slave->mutex);
819 snd_pcm_share_slave_t *slave = share->slave;
820 snd_pcm_t *spcm = slave->pcm;
839 frames = _snd_pcm_share_slave_forward(slave);
862 snd_pcm_share_slave_t *slave = share->slave;
864 Pthread_mutex_lock(&slave->mutex);
866 Pthread_mutex_unlock(&slave->mutex);
873 snd_pcm_share_slave_t *slave = share->slave;
875 Pthread_mutex_lock(&slave->mutex);
889 if (slave->prepared_count == 0) {
890 err = snd_pcm_prepare(slave->pcm);
894 slave->prepared_count++;
899 Pthread_mutex_unlock(&slave->mutex);
906 snd_pcm_share_slave_t *slave = share->slave;
909 Pthread_mutex_lock(&slave->mutex);
911 share->hw_ptr = *slave->pcm->hw.ptr;
913 Pthread_mutex_unlock(&slave->mutex);
920 snd_pcm_share_slave_t *slave = share->slave;
921 snd_pcm_t *spcm = slave->pcm;
925 Pthread_mutex_lock(&slave->mutex);
934 if (slave->running_count) {
960 if (slave->running_count == 0) {
970 if (slave->running_count == 0) {
975 slave->running_count++;
979 Pthread_mutex_unlock(&slave->mutex);
996 snd_pcm_share_slave_t *slave = share->slave;
1001 err = snd_pcm_channel_info(slave->pcm, info);
1009 snd_pcm_share_slave_t *slave = share->slave;
1032 snd_pcm_sframes_t ret = snd_pcm_rewind(slave->pcm, frames);
1045 snd_pcm_share_slave_t *slave = share->slave;
1047 Pthread_mutex_lock(&slave->mutex);
1048 ret = snd_pcm_rewindable(slave->pcm);
1049 Pthread_mutex_unlock(&slave->mutex);
1056 snd_pcm_share_slave_t *slave = share->slave;
1058 Pthread_mutex_lock(&slave->mutex);
1060 Pthread_mutex_unlock(&slave->mutex);
1067 snd_pcm_share_slave_t *slave = share->slave;
1089 snd_pcm_sframes_t ret = INTERNAL(snd_pcm_forward)(slave->pcm, frames);
1102 snd_pcm_share_slave_t *slave = share->slave;
1104 Pthread_mutex_lock(&slave->mutex);
1105 ret = snd_pcm_forwardable(slave->pcm);
1106 Pthread_mutex_unlock(&slave->mutex);
1113 snd_pcm_share_slave_t *slave = share->slave;
1115 Pthread_mutex_lock(&slave->mutex);
1117 Pthread_mutex_unlock(&slave->mutex);
1125 snd_pcm_share_slave_t *slave = share->slave;
1138 } else if (slave->running_count > 1) {
1143 err = snd_pcm_delay(slave->pcm, &delay);
1145 snd_pcm_rewind(slave->pcm, delay);
1149 slave->prepared_count--;
1150 slave->running_count--;
1151 if (slave->running_count == 0) {
1152 int err = snd_pcm_drop(slave->pcm);
1160 snd_pcm_share_slave_t *slave = share->slave;
1162 Pthread_mutex_lock(&slave->mutex);
1184 Pthread_mutex_unlock(&slave->mutex);
1211 Pthread_mutex_unlock(&slave->mutex);
1218 snd_pcm_share_slave_t *slave = share->slave;
1220 Pthread_mutex_lock(&slave->mutex);
1248 Pthread_mutex_unlock(&slave->mutex);
1255 snd_pcm_share_slave_t *slave = share->slave;
1259 Pthread_mutex_lock(&slave->mutex);
1260 slave->open_count--;
1261 if (slave->open_count == 0) {
1262 pthread_cond_signal(&slave->poll_cond);
1263 Pthread_mutex_unlock(&slave->mutex);
1264 err = pthread_join(slave->thread, 0);
1266 err = snd_pcm_close(slave->pcm);
1267 pthread_mutex_destroy(&slave->mutex);
1268 pthread_cond_destroy(&slave->poll_cond);
1269 list_del(&slave->list);
1270 free(slave);
1274 Pthread_mutex_unlock(&slave->mutex);
1297 snd_pcm_share_slave_t *slave = share->slave;
1308 snd_pcm_dump(slave->pcm, out);
1383 snd_pcm_share_slave_t *slave = NULL;
1391 SNDERR("Invalid slave channel (%d) in binding", channels_map[k]);
1395 SNDERR("Repeated slave channel (%d) in binding", channels_map[k]);
1458 slave = s;
1462 if (!slave) {
1476 slave = calloc(1, sizeof(snd_pcm_share_slave_t) * 8);
1477 if (!slave) {
1487 INIT_LIST_HEAD(&slave->clients);
1488 slave->pcm = spcm;
1489 slave->channels = schannels;
1490 slave->format = sformat;
1491 slave->rate = srate;
1492 slave->period_time = speriod_time;
1493 slave->buffer_time = sbuffer_time;
1494 pthread_mutex_init(&slave->mutex, NULL);
1495 pthread_cond_init(&slave->poll_cond, NULL);
1496 list_add_tail(&slave->list, &snd_pcm_share_slaves);
1497 Pthread_mutex_lock(&slave->mutex);
1498 err = pthread_create(&slave->thread, NULL, snd_pcm_share_thread, slave);
1502 Pthread_mutex_lock(&slave->mutex);
1504 list_for_each(i, &slave->clients) {
1509 Pthread_mutex_unlock(&slave->mutex);
1521 share->slave = slave;
1532 pcm->monotonic = slave->pcm->monotonic;
1536 slave->open_count++;
1537 list_add_tail(&share->list, &slave->clients);
1539 Pthread_mutex_unlock(&slave->mutex);
1562 slave STR # Slave name
1564 slave { # Slave definition
1608 snd_config_t *slave = NULL, *sconf;
1624 if (strcmp(id, "slave") == 0) {
1625 slave = n;
1639 if (!slave) {
1640 SNDERR("slave is not defined");
1643 err = snd_pcm_slave_conf(root, slave, &sconf, 5,
1657 SNDERR("slave.pcm is not a string");