Lines Matching refs:pcm

2  * \file pcm/pcm_file.c
154 snd_pcm_t *pcm = file->gen.slave;
174 pcm->rate);
183 pcm->channels);
192 pcm->frame_bits/pcm->channels);
202 snd_pcm_format_name(pcm->format));
290 static int snd_pcm_file_areas_read_infile(snd_pcm_t *pcm,
295 snd_pcm_file_t *file = pcm->private_data;
296 snd_pcm_channel_area_t areas_if[pcm->channels];
306 SYSERR("requested more frames than pcm buffer");
310 bytes = snd_pcm_frames_to_bytes(pcm, frames);
319 snd_pcm_areas_from_buf(pcm, areas_if, file->rbuf);
320 snd_pcm_areas_copy(areas, offset, areas_if, 0, pcm->channels, snd_pcm_bytes_to_frames(pcm, bytes), pcm->format);
325 static void setup_wav_header(snd_pcm_t *pcm, struct wav_fmt *fmt)
328 fmt->chan = TO_LE16(pcm->channels);
329 fmt->rate = TO_LE32(pcm->rate);
330 fmt->bwidth = pcm->frame_bits / 8;
331 fmt->bps = fmt->bwidth * pcm->rate;
332 fmt->bits = snd_pcm_format_width(pcm->format);
338 static int write_wav_header(snd_pcm_t *pcm)
340 snd_pcm_file_t *file = pcm->private_data;
355 setup_wav_header(pcm, &file->wav_header);
389 static void fixup_wav_header(snd_pcm_t *pcm)
391 snd_pcm_file_t *file = pcm->private_data;
418 static int snd_pcm_file_write_bytes(snd_pcm_t *pcm, size_t bytes)
420 snd_pcm_file_t *file = pcm->private_data;
426 err = write_wav_header(pcm);
458 static int snd_pcm_file_add_frames(snd_pcm_t *pcm,
463 snd_pcm_file_t *file = pcm->private_data;
468 snd_pcm_uframes_t avail = file->wbuf_size - snd_pcm_bytes_to_frames(pcm, file->wbuf_used_bytes);
475 pcm->channels, n, pcm->format);
481 file->wbuf_used_bytes += snd_pcm_frames_to_bytes(pcm, n);
483 err = snd_pcm_file_write_bytes(pcm, file->wbuf_used_bytes - file->buffer_bytes);
492 static int snd_pcm_file_close(snd_pcm_t *pcm)
494 snd_pcm_file_t *file = pcm->private_data;
497 fixup_wav_header(pcm);
509 return snd_pcm_generic_close(pcm);
512 static int snd_pcm_file_reset(snd_pcm_t *pcm)
514 snd_pcm_file_t *file = pcm->private_data;
518 snd_pcm_file_write_bytes(pcm, file->wbuf_used_bytes);
524 static int snd_pcm_file_drop(snd_pcm_t *pcm)
526 snd_pcm_file_t *file = pcm->private_data;
530 snd_pcm_file_write_bytes(pcm, file->wbuf_used_bytes);
537 static int snd_pcm_file_drain(snd_pcm_t *pcm)
539 snd_pcm_file_t *file = pcm->private_data;
542 __snd_pcm_lock(pcm);
543 snd_pcm_file_write_bytes(pcm, file->wbuf_used_bytes);
545 __snd_pcm_unlock(pcm);
550 static snd_pcm_sframes_t snd_pcm_file_rewindable(snd_pcm_t *pcm)
552 snd_pcm_file_t *file = pcm->private_data;
554 snd_pcm_sframes_t n = snd_pcm_bytes_to_frames(pcm, file->wbuf_used_bytes);
560 static snd_pcm_sframes_t snd_pcm_file_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
562 snd_pcm_file_t *file = pcm->private_data;
566 n = snd_pcm_frames_to_bytes(pcm, frames);
568 frames = snd_pcm_bytes_to_frames(pcm, file->wbuf_used_bytes);
572 n = snd_pcm_frames_to_bytes(pcm, err);
578 static snd_pcm_sframes_t snd_pcm_file_forwardable(snd_pcm_t *pcm)
580 snd_pcm_file_t *file = pcm->private_data;
582 snd_pcm_sframes_t n = snd_pcm_bytes_to_frames(pcm, file->wbuf_size_bytes - file->wbuf_used_bytes);
588 static snd_pcm_sframes_t snd_pcm_file_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
590 snd_pcm_file_t *file = pcm->private_data;
594 n = snd_pcm_frames_to_bytes(pcm, frames);
596 frames = snd_pcm_bytes_to_frames(pcm, file->wbuf_size_bytes - file->wbuf_used_bytes);
600 n = snd_pcm_frames_to_bytes(pcm, err);
607 static snd_pcm_sframes_t snd_pcm_file_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)
609 snd_pcm_file_t *file = pcm->private_data;
610 snd_pcm_channel_area_t areas[pcm->channels];
613 snd_pcm_areas_from_buf(pcm, areas, (void*) buffer);
614 __snd_pcm_lock(pcm);
615 if (snd_pcm_file_add_frames(pcm, areas, 0, n) < 0) {
616 __snd_pcm_unlock(pcm);
619 __snd_pcm_unlock(pcm);
625 static snd_pcm_sframes_t snd_pcm_file_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
627 snd_pcm_file_t *file = pcm->private_data;
628 snd_pcm_channel_area_t areas[pcm->channels];
631 snd_pcm_areas_from_bufs(pcm, areas, bufs);
632 __snd_pcm_lock(pcm);
633 if (snd_pcm_file_add_frames(pcm, areas, 0, n) < 0) {
634 __snd_pcm_unlock(pcm);
637 __snd_pcm_unlock(pcm);
643 static snd_pcm_sframes_t snd_pcm_file_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size)
645 snd_pcm_file_t *file = pcm->private_data;
646 snd_pcm_channel_area_t areas[pcm->channels];
653 snd_pcm_areas_from_buf(pcm, areas, buffer);
654 snd_pcm_file_areas_read_infile(pcm, areas, 0, frames);
655 __snd_pcm_lock(pcm);
656 if (snd_pcm_file_add_frames(pcm, areas, 0, frames) < 0) {
657 __snd_pcm_unlock(pcm);
661 __snd_pcm_unlock(pcm);
667 static snd_pcm_sframes_t snd_pcm_file_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
669 snd_pcm_file_t *file = pcm->private_data;
670 snd_pcm_channel_area_t areas[pcm->channels];
677 snd_pcm_areas_from_bufs(pcm, areas, bufs);
678 snd_pcm_file_areas_read_infile(pcm, areas, 0, frames);
679 __snd_pcm_lock(pcm);
680 if (snd_pcm_file_add_frames(pcm, areas, 0, frames) < 0) {
681 __snd_pcm_unlock(pcm);
685 __snd_pcm_unlock(pcm);
690 static snd_pcm_sframes_t snd_pcm_file_mmap_commit(snd_pcm_t *pcm,
694 snd_pcm_file_t *file = pcm->private_data;
707 if (snd_pcm_file_add_frames(pcm, areas, ofs, result) < 0)
714 static int snd_pcm_file_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas,
717 snd_pcm_file_t *file = pcm->private_data;
724 if (pcm->stream != SND_PCM_STREAM_CAPTURE)
732 snd_pcm_file_areas_read_infile(pcm, *areas, *offset, *frames);
737 static int snd_pcm_file_hw_free(snd_pcm_t *pcm)
739 snd_pcm_file_t *file = pcm->private_data;
751 static int snd_pcm_file_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
753 snd_pcm_file_t *file = pcm->private_data;
767 snd_pcm_file_hw_free(pcm);
772 snd_pcm_file_hw_free(pcm);
781 snd_pcm_file_hw_free(pcm);
800 snd_pcm_unlink_hw_ptr(pcm, file->gen.slave);
801 snd_pcm_unlink_appl_ptr(pcm, file->gen.slave);
803 snd_pcm_link_hw_ptr(pcm, file->gen.slave);
804 snd_pcm_link_appl_ptr(pcm, file->gen.slave);
809 static void snd_pcm_file_dump(snd_pcm_t *pcm, snd_output_t *out)
811 snd_pcm_file_t *file = pcm->private_data;
820 if (pcm->setup) {
822 snd_pcm_dump_setup(pcm, out);
904 snd_pcm_t *pcm;
948 err = snd_pcm_new(&pcm, SND_PCM_TYPE_FILE, name, slave->stream, slave->mode);
955 pcm->ops = &snd_pcm_file_ops;
956 pcm->fast_ops = &snd_pcm_file_fast_ops;
957 pcm->private_data = file;
958 pcm->poll_fd = slave->poll_fd;
959 pcm->poll_events = slave->poll_events;
960 pcm->mmap_shadow = 1;
961 pcm->tstamp_type = SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY;
964 pcm->tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC;
966 pcm->stream = stream;
967 snd_pcm_link_hw_ptr(pcm, slave);
968 snd_pcm_link_appl_ptr(pcm, slave);
969 *pcmp = pcm;
982 pcm.name {
987 pcm STR # Slave PCM name
989 pcm { } # Slave PCM definition
1112 if (snd_config_search(root, "defaults.pcm.file_format", &n) >= 0) {