Lines Matching refs:pcm

2  * \file pcm/pcm_dmix.c
312 static void snd_pcm_dmix_sync_area(snd_pcm_t *pcm)
314 snd_pcm_direct_t *dmix = pcm->private_data;
323 size = pcm_frame_diff2(dmix->appl_ptr, dmix->last_appl_ptr, pcm->boundary);
335 dmix->last_appl_ptr %= pcm->boundary;
338 size = pcm_frame_diff2(dmix->appl_ptr, dmix->last_appl_ptr, pcm->boundary);
359 src_areas = snd_pcm_mmap_areas(pcm);
361 appl_ptr = dmix->last_appl_ptr % pcm->buffer_size;
363 dmix->last_appl_ptr %= pcm->boundary;
370 if (appl_ptr + transfer > pcm->buffer_size)
371 transfer = pcm->buffer_size - appl_ptr;
381 appl_ptr %= pcm->buffer_size;
389 static int snd_pcm_dmix_sync_ptr0(snd_pcm_t *pcm, snd_pcm_uframes_t slave_hw_ptr)
391 snd_pcm_direct_t *dmix = pcm->private_data;
405 dmix->hw_ptr %= pcm->boundary;
406 if (pcm->stop_threshold >= pcm->boundary) /* don't care */
408 avail = snd_pcm_mmap_playback_avail(pcm);
411 if (avail >= pcm->stop_threshold) {
413 gettimestamp(&dmix->trigger_tstamp, pcm->tstamp_type);
425 static int snd_pcm_dmix_sync_ptr(snd_pcm_t *pcm)
427 snd_pcm_direct_t *dmix = pcm->private_data;
434 err = snd_pcm_direct_check_xrun(dmix, pcm);
438 return snd_pcm_dmix_sync_ptr0(pcm, slave_hw_ptr);
445 static snd_pcm_state_t snd_pcm_dmix_state(snd_pcm_t *pcm)
447 snd_pcm_direct_t *dmix = pcm->private_data;
449 snd_pcm_direct_check_xrun(dmix, pcm);
455 static int snd_pcm_dmix_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
457 snd_pcm_direct_t *dmix = pcm->private_data;
465 snd_pcm_dmix_sync_ptr0(pcm, status->hw_ptr);
466 status->delay = snd_pcm_mmap_playback_delay(pcm);
472 status->state = snd_pcm_dmix_state(pcm);
473 status->hw_ptr = *pcm->hw.ptr; /* boundary may be different */
474 status->appl_ptr = *pcm->appl.ptr; /* slave PCM doesn't set appl_ptr */
476 status->avail = snd_pcm_mmap_playback_avail(pcm);
482 static int snd_pcm_dmix_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
484 snd_pcm_direct_t *dmix = pcm->private_data;
490 err = snd_pcm_dmix_sync_ptr(pcm);
497 *delayp = snd_pcm_mmap_playback_delay(pcm);
508 static int snd_pcm_dmix_hwsync(snd_pcm_t *pcm)
510 snd_pcm_direct_t *dmix = pcm->private_data;
516 return snd_pcm_dmix_sync_ptr(pcm);
530 static int snd_pcm_dmix_reset(snd_pcm_t *pcm)
532 snd_pcm_direct_t *dmix = pcm->private_data;
533 dmix->hw_ptr %= pcm->period_size;
535 snd_pcm_direct_reset_slave_ptr(pcm, dmix, *dmix->spcm->hw.ptr);
539 static int snd_pcm_dmix_start_timer(snd_pcm_t *pcm, snd_pcm_direct_t *dmix)
544 snd_pcm_direct_reset_slave_ptr(pcm, dmix, *dmix->spcm->hw.ptr);
552 static int snd_pcm_dmix_start(snd_pcm_t *pcm)
554 snd_pcm_direct_t *dmix = pcm->private_data;
560 avail = snd_pcm_mmap_playback_hw_avail(pcm);
566 if ((err = snd_pcm_dmix_start_timer(pcm, dmix)) < 0)
568 snd_pcm_dmix_sync_area(pcm);
570 gettimestamp(&dmix->trigger_tstamp, pcm->tstamp_type);
574 static int snd_pcm_dmix_drop(snd_pcm_t *pcm)
576 snd_pcm_direct_t *dmix = pcm->private_data;
585 static int __snd_pcm_dmix_drain(snd_pcm_t *pcm)
587 snd_pcm_direct_t *dmix = pcm->private_data;
601 if (snd_pcm_mmap_playback_hw_avail(pcm) > 0)
602 snd_pcm_dmix_start(pcm);
604 snd_pcm_dmix_drop(pcm);
610 snd_pcm_dmix_drop(pcm);
614 stop_threshold = pcm->stop_threshold;
615 if (pcm->stop_threshold > pcm->buffer_size)
616 pcm->stop_threshold = pcm->buffer_size;
619 err = snd_pcm_dmix_sync_ptr(pcm);
621 snd_pcm_dmix_drop(pcm);
625 snd_pcm_dmix_sync_area(pcm);
626 if ((pcm->mode & SND_PCM_NONBLOCK) == 0) {
627 snd_pcm_wait_nocheck(pcm, SND_PCM_WAIT_DRAIN);
639 if (pcm->mode & SND_PCM_NONBLOCK) {
647 pcm->stop_threshold = stop_threshold;
651 static int snd_pcm_dmix_drain(snd_pcm_t *pcm)
655 snd_pcm_lock(pcm);
656 err = __snd_pcm_dmix_drain(pcm);
657 snd_pcm_unlock(pcm);
661 static int snd_pcm_dmix_pause(snd_pcm_t *pcm ATTRIBUTE_UNUSED, int enable ATTRIBUTE_UNUSED)
666 static snd_pcm_sframes_t snd_pcm_dmix_rewindable(snd_pcm_t *pcm)
668 return snd_pcm_mmap_playback_hw_rewindable(pcm);
671 static snd_pcm_sframes_t snd_pcm_dmix_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
673 snd_pcm_direct_t *dmix = pcm->private_data;
681 err = snd_pcm_dmix_hwsync(pcm);
693 size = pcm_frame_diff(dmix->last_appl_ptr, dmix->appl_ptr, pcm->boundary);
696 snd_pcm_mmap_appl_backward(pcm, size);
705 size = pcm_frame_diff(dmix->appl_ptr, dmix->hw_ptr, pcm->boundary);
708 slave_size = pcm_frame_diff(dmix->slave_appl_ptr, dmix->slave_hw_ptr, pcm->boundary);
718 src_areas = snd_pcm_mmap_areas(pcm);
721 dmix->last_appl_ptr %= pcm->boundary;
722 appl_ptr = dmix->last_appl_ptr % pcm->buffer_size;
729 if (appl_ptr + transfer > pcm->buffer_size)
730 transfer = pcm->buffer_size - appl_ptr;
740 appl_ptr %= pcm->buffer_size;
744 snd_pcm_mmap_appl_backward(pcm, frames_to_remix);
753 static snd_pcm_sframes_t snd_pcm_dmix_forwardable(snd_pcm_t *pcm)
755 return snd_pcm_mmap_avail(pcm);
758 static snd_pcm_sframes_t snd_pcm_dmix_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
762 avail = snd_pcm_dmix_forwardable(pcm);
765 snd_pcm_mmap_appl_forward(pcm, frames);
769 static snd_pcm_sframes_t snd_pcm_dmix_readi(snd_pcm_t *pcm ATTRIBUTE_UNUSED, void *buffer ATTRIBUTE_UNUSED, snd_pcm_uframes_t size ATTRIBUTE_UNUSED)
774 static snd_pcm_sframes_t snd_pcm_dmix_readn(snd_pcm_t *pcm ATTRIBUTE_UNUSED, void **bufs ATTRIBUTE_UNUSED, snd_pcm_uframes_t size ATTRIBUTE_UNUSED)
779 static int snd_pcm_dmix_close(snd_pcm_t *pcm)
781 snd_pcm_direct_t *dmix = pcm->private_data;
798 pcm->private_data = NULL;
803 static snd_pcm_sframes_t snd_pcm_dmix_mmap_commit(snd_pcm_t *pcm,
807 snd_pcm_direct_t *dmix = pcm->private_data;
810 err = snd_pcm_direct_check_xrun(dmix, pcm);
815 snd_pcm_mmap_appl_forward(pcm, size);
817 if ((err = snd_pcm_dmix_start_timer(pcm, dmix)) < 0)
821 if ((err = snd_pcm_dmix_sync_ptr(pcm)) < 0)
828 snd_pcm_dmix_sync_area(pcm);
830 if (snd_pcm_mmap_playback_avail(pcm) < pcm->avail_min)
836 static snd_pcm_sframes_t snd_pcm_dmix_avail_update(snd_pcm_t *pcm)
838 snd_pcm_direct_t *dmix = pcm->private_data;
843 if ((err = snd_pcm_dmix_sync_ptr(pcm)) < 0)
849 return snd_pcm_mmap_playback_avail(pcm);
852 static int snd_pcm_dmix_htimestamp(snd_pcm_t *pcm,
856 snd_pcm_direct_t *dmix = pcm->private_data;
863 snd_pcm_dmix_sync_ptr(pcm);
864 avail1 = snd_pcm_mmap_playback_avail(pcm);
874 static int snd_pcm_dmix_poll_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
876 snd_pcm_direct_t *dmix = pcm->private_data;
878 snd_pcm_dmix_sync_area(pcm);
879 return snd_pcm_direct_poll_revents(pcm, pfds, nfds, revents);
883 static void snd_pcm_dmix_dump(snd_pcm_t *pcm, snd_output_t *out)
885 snd_pcm_direct_t *dmix = pcm->private_data;
888 if (pcm->setup) {
890 snd_pcm_dump_setup(pcm, out);
966 snd_pcm_t *pcm, *spcm = NULL;
977 ret = _snd_pcm_direct_new(&pcm, &dmix, SND_PCM_TYPE_DMIX, name, opts, params, stream, mode);
982 pcm->ops = &snd_pcm_dmix_ops;
983 pcm->fast_ops = &snd_pcm_dmix_fast_ops;
984 pcm->private_data = dmix;
1090 pcm->poll_fd = dmix->poll_fd;
1091 pcm->poll_events = POLLIN; /* it's different than other plugins */
1092 pcm->tstamp_type = spcm->tstamp_type;
1093 pcm->mmap_rw = 1;
1094 snd_pcm_set_hw_ptr(pcm, &dmix->hw_ptr, -1, 0);
1095 snd_pcm_set_appl_ptr(pcm, &dmix->appl_ptr, -1, 0);
1102 *pcmp = pcm;
1124 snd_pcm_free(pcm);
1137 pcm.name {
1154 pcm STR # slave PCM name
1156 pcm { } # slave PCM definition
1215 pcm.dmix_44 {
1220 pcm "hw:0"
1226 You can hear 48000 Hz samples still using this dmix pcm via plug plugin
1235 pcm.dmixoss {
1240 pcm "hw:0"
1251 pcm.dmixoss {