Lines Matching refs:pcm
2 * \file pcm/pcm_plugin.c
46 pcm STR # PCM name
48 pcm { } # PCM definition
61 pcm "hw:0,0"
65 pcm.rate44100Hz {
74 pcm.rate44100Hz {
77 pcm "hw:0,0"
92 snd_pcm_plugin_undo_read(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
102 snd_pcm_plugin_undo_write(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
112 snd_pcm_plugin_undo_read_generic(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
122 snd_pcm_plugin_undo_write_generic(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
138 static int snd_pcm_plugin_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
140 snd_pcm_plugin_t *plugin = pcm->private_data;
149 static int snd_pcm_plugin_call_init_cb(snd_pcm_t *pcm, snd_pcm_plugin_t *plugin)
154 assert(pcm->boundary == slave->boundary);
155 *pcm->hw.ptr = *slave->hw.ptr;
156 *pcm->appl.ptr = *slave->appl.ptr;
158 err = plugin->init(pcm);
165 static int snd_pcm_plugin_prepare(snd_pcm_t *pcm)
167 snd_pcm_plugin_t *plugin = pcm->private_data;
172 return snd_pcm_plugin_call_init_cb(pcm, plugin);
175 static int snd_pcm_plugin_reset(snd_pcm_t *pcm)
177 snd_pcm_plugin_t *plugin = pcm->private_data;
182 return snd_pcm_plugin_call_init_cb(pcm, plugin);
185 static snd_pcm_sframes_t snd_pcm_plugin_rewindable(snd_pcm_t *pcm)
187 return snd_pcm_mmap_hw_rewindable(pcm);
190 snd_pcm_sframes_t snd_pcm_plugin_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
192 snd_pcm_plugin_t *plugin = pcm->private_data;
193 snd_pcm_sframes_t n = snd_pcm_plugin_rewindable(pcm);
205 snd_pcm_mmap_appl_backward(pcm, (snd_pcm_uframes_t) sframes);
209 static snd_pcm_sframes_t snd_pcm_plugin_forwardable(snd_pcm_t *pcm)
211 return snd_pcm_mmap_avail(pcm);
214 snd_pcm_sframes_t snd_pcm_plugin_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
216 snd_pcm_plugin_t *plugin = pcm->private_data;
217 snd_pcm_sframes_t n = snd_pcm_plugin_forwardable(pcm);
229 snd_pcm_mmap_appl_forward(pcm, (snd_pcm_uframes_t) frames);
233 static snd_pcm_sframes_t snd_pcm_plugin_write_areas(snd_pcm_t *pcm,
238 snd_pcm_plugin_t *plugin = pcm->private_data;
257 frames = plugin->write(pcm, areas, offset, frames,
268 res = plugin->undo_write(pcm, slave_areas, slave_offset + result, slave_frames, slave_frames - result);
279 snd_pcm_mmap_appl_forward(pcm, frames);
290 static snd_pcm_sframes_t snd_pcm_plugin_read_areas(snd_pcm_t *pcm,
295 snd_pcm_plugin_t *plugin = pcm->private_data;
314 frames = (plugin->read)(pcm, areas, offset, frames,
337 snd_pcm_mmap_appl_forward(pcm, frames);
350 snd_pcm_plugin_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)
352 snd_pcm_channel_area_t areas[pcm->channels];
353 snd_pcm_areas_from_buf(pcm, areas, (void*)buffer);
354 return snd_pcm_write_areas(pcm, areas, 0, size,
359 snd_pcm_plugin_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
361 snd_pcm_channel_area_t areas[pcm->channels];
362 snd_pcm_areas_from_bufs(pcm, areas, bufs);
363 return snd_pcm_write_areas(pcm, areas, 0, size,
368 snd_pcm_plugin_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size)
370 snd_pcm_channel_area_t areas[pcm->channels];
371 snd_pcm_areas_from_buf(pcm, areas, buffer);
372 return snd_pcm_read_areas(pcm, areas, 0, size,
377 snd_pcm_plugin_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
379 snd_pcm_channel_area_t areas[pcm->channels];
380 snd_pcm_areas_from_bufs(pcm, areas, bufs);
381 return snd_pcm_read_areas(pcm, areas, 0, size,
386 snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm,
390 snd_pcm_plugin_t *plugin = pcm->private_data;
398 if (pcm->stream == SND_PCM_STREAM_CAPTURE) {
399 snd_pcm_mmap_appl_forward(pcm, size);
405 areas = snd_pcm_mmap_areas(pcm);
406 appl_offset = snd_pcm_mmap_offset(pcm);
410 snd_pcm_uframes_t cont = pcm->buffer_size - appl_offset;
423 frames = plugin->write(pcm, areas, appl_offset, frames,
429 res = plugin->undo_write(pcm, slave_areas, slave_offset + result, slave_frames, slave_frames - result);
440 snd_pcm_mmap_appl_forward(pcm, frames);
460 snd_pcm_plugin_sync_hw_ptr_capture(snd_pcm_t *pcm,
463 snd_pcm_plugin_t *plugin = pcm->private_data;
469 xfer = snd_pcm_mmap_capture_avail(pcm);
470 size = pcm->buffer_size - xfer;
471 areas = snd_pcm_mmap_areas(pcm);
472 hw_offset = snd_pcm_mmap_hw_offset(pcm);
475 snd_pcm_uframes_t cont = pcm->buffer_size - hw_offset;
480 /* As mentioned in the ALSA API (see pcm/pcm.c:942):
495 frames = (plugin->read)(pcm, areas, hw_offset, frames,
511 snd_pcm_mmap_hw_forward(pcm, frames);
525 static snd_pcm_sframes_t snd_pcm_plugin_sync_hw_ptr(snd_pcm_t *pcm,
529 if (pcm->stream == SND_PCM_STREAM_CAPTURE &&
530 pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED &&
531 pcm->access != SND_PCM_ACCESS_RW_NONINTERLEAVED)
532 return snd_pcm_plugin_sync_hw_ptr_capture(pcm, slave_size);
533 *pcm->hw.ptr = slave_hw_ptr;
537 static snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
539 snd_pcm_plugin_t *plugin = pcm->private_data;
544 return snd_pcm_plugin_sync_hw_ptr(pcm, *slave->hw.ptr, slave_size);
547 static int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
549 snd_pcm_plugin_t *plugin = pcm->private_data;
555 snd_pcm_plugin_sync_hw_ptr(pcm, status->hw_ptr, status->avail);
558 * snd_pcm_plugin_avail_update() commits the data to the slave pcm.
566 if (pcm->stream == SND_PCM_STREAM_CAPTURE) {
567 diff = pcm_frame_diff(status->appl_ptr, *pcm->appl.ptr, pcm->boundary);
568 status->appl_ptr = *pcm->appl.ptr;
572 assert(status->appl_ptr == *pcm->appl.ptr);
578 snd_pcm_t *pcm,
582 if (pcm->stream == SND_PCM_STREAM_CAPTURE &&
583 pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED &&
584 pcm->access != SND_PCM_ACCESS_RW_NONINTERLEAVED) {
600 snd_pcm_generic_t *generic = pcm->private_data;
612 available = snd_pcm_avail_update(pcm);
616 if ((snd_pcm_uframes_t)available >= pcm->avail_min)
622 needed_slave_avail_min = pcm->avail_min - available;
629 needed_slave_avail_min = conv(pcm, needed_slave_avail_min);
650 return snd_pcm_generic_may_wait_for_avail_min(pcm, avail);
653 int snd_pcm_plugin_may_wait_for_avail_min(snd_pcm_t *pcm,
656 return snd_pcm_plugin_may_wait_for_avail_min_conv(pcm, avail, NULL);