static snd_pcm_sframes_t snd_pcm_file_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size) { snd_pcm_file_t *file = pcm->private_data; snd_pcm_channel_area_t areas[pcm->channels]; snd_pcm_sframes_t n = snd_pcm_writen(file->gen.slave, bufs, size); if (n > 0) { snd_pcm_areas_from_bufs(pcm, areas, bufs); snd_pcm_file_add_frames(pcm, areas, 0, n); } return n; }
/* locking */ static snd_pcm_sframes_t snd_pcm_file_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size) { snd_pcm_file_t *file = pcm->private_data; snd_pcm_channel_area_t areas[pcm->channels]; snd_pcm_sframes_t n = _snd_pcm_writei(file->gen.slave, buffer, size); if (n > 0) { snd_pcm_areas_from_buf(pcm, areas, (void*) buffer); __snd_pcm_lock(pcm); snd_pcm_file_add_frames(pcm, areas, 0, n); __snd_pcm_unlock(pcm); } return n; }
static snd_pcm_sframes_t snd_pcm_file_mmap_commit(snd_pcm_t *pcm, snd_pcm_uframes_t offset, snd_pcm_uframes_t size) { snd_pcm_file_t *file = pcm->private_data; snd_pcm_uframes_t ofs; snd_pcm_uframes_t siz = size; const snd_pcm_channel_area_t *areas; snd_pcm_sframes_t result; snd_pcm_mmap_begin(file->gen.slave, &areas, &ofs, &siz); assert(ofs == offset && siz == size); result = snd_pcm_mmap_commit(file->gen.slave, ofs, siz); if (result > 0) snd_pcm_file_add_frames(pcm, areas, ofs, result); return result; }
static snd_pcm_sframes_t snd_pcm_file_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size) { snd_pcm_file_t *file = pcm->private_data; snd_pcm_channel_area_t areas[pcm->channels]; snd_pcm_sframes_t n; if (file->ifd >= 0) { SNDERR("DEBUG: Noninterleaved read not yet implemented.\n"); return 0; /* TODO: Noninterleaved read */ } n = snd_pcm_readn(file->gen.slave, bufs, size); if (n > 0) { snd_pcm_areas_from_bufs(pcm, areas, bufs); snd_pcm_file_add_frames(pcm, areas, 0, n); } return n; }
static snd_pcm_sframes_t snd_pcm_file_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size) { snd_pcm_file_t *file = pcm->private_data; snd_pcm_channel_area_t areas[pcm->channels]; snd_pcm_sframes_t n; n = snd_pcm_readi(file->gen.slave, buffer, size); if (n <= 0) return n; if (file->ifd >= 0) { n = read(file->ifd, buffer, n * pcm->frame_bits / 8); if (n < 0) return n; return n * 8 / pcm->frame_bits; } snd_pcm_areas_from_buf(pcm, areas, buffer); snd_pcm_file_add_frames(pcm, areas, 0, n); return n; }
static snd_pcm_sframes_t snd_pcm_file_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size) { snd_pcm_file_t *file = pcm->private_data; snd_pcm_channel_area_t areas[pcm->channels]; snd_pcm_sframes_t n /* , bytesn */; if (file->ifd >= 0) { n = /* bytesn = */ read(file->ifd, buffer, size * pcm->frame_bits / 8); if (n > 0) n = n * 8 / pcm->frame_bits; /* SNDERR("DEBUG: channels = %d, sample_bits = %d, frame_bits = %d, bytes = %d, frames = %d", pcm->channels, pcm->sample_bits, pcm->frame_bits, bytesn, n); */ } else { n = snd_pcm_readi(file->gen.slave, buffer, size); if (n > 0) { snd_pcm_areas_from_buf(pcm, areas, buffer); snd_pcm_file_add_frames(pcm, areas, 0, n); } } return n; }