ssize_t snd_pcm_mmap_read(snd_pcm_t *handle, void *buffer, size_t size);
ssize_t snd_pcm_mmap_writev(snd_pcm_t *pcm, const struct iovec *vector, unsigned long count);
ssize_t snd_pcm_mmap_readv(snd_pcm_t *pcm, const struct iovec *vector, unsigned long count);
-int snd_pcm_mmap_samples_used(snd_pcm_t *pcm, int channel, ssize_t *samples);
-int snd_pcm_mmap_samples_free(snd_pcm_t *pcm, int channel, ssize_t *samples);
-ssize_t snd_pcm_mmap_samples_xfer(snd_pcm_t *pcm, int channel, size_t samples);
-ssize_t snd_pcm_mmap_samples_offset(snd_pcm_t *pcm, int channel);
-int snd_pcm_mmap_commit_samples(snd_pcm_t *pcm, int channel, int samples);
-ssize_t snd_pcm_mmap_write_areas(snd_pcm_t *pcm, snd_pcm_voice_area_t *voices, size_t samples);
-ssize_t snd_pcm_mmap_write_samples(snd_pcm_t *pcm, const void *buffer, size_t samples);
-ssize_t snd_pcm_mmap_read_areas(snd_pcm_t *pcm, snd_pcm_voice_area_t *voices, size_t samples);
-ssize_t snd_pcm_mmap_read_samples(snd_pcm_t *pcm, const void *buffer, size_t samples);
+int snd_pcm_mmap_frames_used(snd_pcm_t *pcm, int channel, ssize_t *frames);
+int snd_pcm_mmap_frames_free(snd_pcm_t *pcm, int channel, ssize_t *frames);
+ssize_t snd_pcm_mmap_frames_xfer(snd_pcm_t *pcm, int channel, size_t frames);
+ssize_t snd_pcm_mmap_frames_offset(snd_pcm_t *pcm, int channel);
+int snd_pcm_mmap_commit_frames(snd_pcm_t *pcm, int channel, int frames);
+ssize_t snd_pcm_mmap_write_areas(snd_pcm_t *pcm, snd_pcm_voice_area_t *voices, size_t frames);
+ssize_t snd_pcm_mmap_write_frames(snd_pcm_t *pcm, const void *buffer, size_t frames);
+ssize_t snd_pcm_mmap_read_areas(snd_pcm_t *pcm, snd_pcm_voice_area_t *voices, size_t frames);
+ssize_t snd_pcm_mmap_read_frames(snd_pcm_t *pcm, const void *buffer, size_t frames);
int snd_pcm_mmap_get_areas(snd_pcm_t *pcm, int channel, snd_pcm_voice_area_t *areas);
int snd_pcm_area_silence(const snd_pcm_voice_area_t *dst_voice, size_t dst_offset,
size_t samples, int format);
int snd_pcm_areas_silence(const snd_pcm_voice_area_t *dst_voices, size_t dst_offset,
- size_t vcount, size_t samples, int format);
+ size_t vcount, size_t frames, int format);
int snd_pcm_area_copy(const snd_pcm_voice_area_t *src_voice, size_t src_offset,
const snd_pcm_voice_area_t *dst_voice, size_t dst_offset,
size_t samples, int format);
int snd_pcm_areas_copy(const snd_pcm_voice_area_t *src_voices, size_t src_offset,
const snd_pcm_voice_area_t *dst_voices, size_t dst_offset,
- size_t vcount, size_t samples, int format);
+ size_t vcount, size_t frames, int format);
/* misc */
snd_pcm_format_t dst_format; /* destination format */
int src_width; /* sample width in bits */
int dst_width; /* sample width in bits */
- ssize_t (*src_samples)(snd_pcm_plugin_t *plugin, size_t dst_samples);
- ssize_t (*dst_samples)(snd_pcm_plugin_t *plugin, size_t src_samples);
+ ssize_t (*src_frames)(snd_pcm_plugin_t *plugin, size_t dst_frames);
+ ssize_t (*dst_frames)(snd_pcm_plugin_t *plugin, size_t src_frames);
ssize_t (*client_voices)(snd_pcm_plugin_t *plugin,
- size_t samples,
+ size_t frames,
snd_pcm_plugin_voice_t **voices);
int (*src_voices_mask)(snd_pcm_plugin_t *plugin,
bitset_t *dst_vmask,
ssize_t (*transfer)(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples);
+ size_t frames);
int (*action)(snd_pcm_plugin_t *plugin,
snd_pcm_plugin_action_t action,
unsigned long data);
snd_pcm_plugin_t *snd_pcm_plug_first(snd_pcm_t *handle, int channel);
snd_pcm_plugin_t *snd_pcm_plug_last(snd_pcm_t *handle, int channel);
int snd_pcm_plug_direct(snd_pcm_t *pcm, int channel);
-ssize_t snd_pcm_plug_client_samples(snd_pcm_t *handle, int channel, size_t drv_samples);
-ssize_t snd_pcm_plug_slave_samples(snd_pcm_t *handle, int channel, size_t clt_samples);
+ssize_t snd_pcm_plug_client_frames(snd_pcm_t *handle, int channel, size_t drv_frames);
+ssize_t snd_pcm_plug_slave_frames(snd_pcm_t *handle, int channel, size_t clt_frames);
ssize_t snd_pcm_plug_client_size(snd_pcm_t *handle, int channel, size_t drv_size);
ssize_t snd_pcm_plug_slave_size(snd_pcm_t *handle, int channel, size_t clt_size);
* Plug-In helpers
*/
-ssize_t snd_pcm_plugin_src_samples_to_size(snd_pcm_plugin_t *plugin, size_t samples);
-ssize_t snd_pcm_plugin_dst_samples_to_size(snd_pcm_plugin_t *plugin, size_t samples);
-ssize_t snd_pcm_plugin_src_size_to_samples(snd_pcm_plugin_t *plugin, size_t size);
-ssize_t snd_pcm_plugin_dst_size_to_samples(snd_pcm_plugin_t *plugin, size_t size);
+ssize_t snd_pcm_plugin_src_frames_to_size(snd_pcm_plugin_t *plugin, size_t frames);
+ssize_t snd_pcm_plugin_dst_frames_to_size(snd_pcm_plugin_t *plugin, size_t frames);
+ssize_t snd_pcm_plugin_src_size_to_frames(snd_pcm_plugin_t *plugin, size_t size);
+ssize_t snd_pcm_plugin_dst_size_to_frames(snd_pcm_plugin_t *plugin, size_t size);
/*
* Plug-In constructors
return err;
memcpy(&chan->setup, setup, sizeof(*setup));
chan->sample_width = snd_pcm_format_physical_width(setup->format.format);
- chan->bits_per_sample = chan->sample_width * setup->format.voices;
- chan->samples_per_frag = setup->frag_size * 8 / chan->bits_per_sample;
+ chan->bits_per_frame = chan->sample_width * setup->format.voices;
+ chan->frames_per_frag = setup->frag_size * 8 / chan->bits_per_frame;
chan->valid_setup = 1;
return 0;
}
static ssize_t snd_pcm_plugin_side_voices(snd_pcm_plugin_t *plugin,
int client_side,
- size_t samples,
+ size_t frames,
snd_pcm_plugin_voice_t **voices)
{
char *ptr;
*voices = v;
if ((width = snd_pcm_format_physical_width(format->format)) < 0)
return width;
- size = format->voices * samples * width;
+ size = format->voices * frames * width;
if ((size % 8) != 0)
return -EINVAL;
size /= 8;
v->area.step = width;
}
}
- return samples;
+ return frames;
}
ssize_t snd_pcm_plugin_client_voices(snd_pcm_plugin_t *plugin,
- size_t samples,
+ size_t frames,
snd_pcm_plugin_voice_t **voices)
{
- return snd_pcm_plugin_side_voices(plugin, 1, samples, voices);
+ return snd_pcm_plugin_side_voices(plugin, 1, frames, voices);
}
ssize_t snd_pcm_plugin_slave_voices(snd_pcm_plugin_t *plugin,
- size_t samples,
+ size_t frames,
snd_pcm_plugin_voice_t **voices)
{
- return snd_pcm_plugin_side_voices(plugin, 0, samples, voices);
+ return snd_pcm_plugin_side_voices(plugin, 0, frames, voices);
}
return 0;
}
-ssize_t snd_pcm_plugin_src_samples_to_size(snd_pcm_plugin_t *plugin, size_t samples)
+ssize_t snd_pcm_plugin_src_frames_to_size(snd_pcm_plugin_t *plugin, size_t frames)
{
ssize_t result;
if (plugin == NULL)
return -EFAULT;
- result = samples * plugin->src_format.voices * plugin->src_width;
+ result = frames * plugin->src_format.voices * plugin->src_width;
if (result % 8 != 0)
return -EINVAL;
return result / 8;
}
-ssize_t snd_pcm_plugin_dst_samples_to_size(snd_pcm_plugin_t *plugin, size_t samples)
+ssize_t snd_pcm_plugin_dst_frames_to_size(snd_pcm_plugin_t *plugin, size_t frames)
{
ssize_t result;
if (plugin == NULL)
return -EFAULT;
- result = samples * plugin->dst_format.voices * plugin->dst_width;
+ result = frames * plugin->dst_format.voices * plugin->dst_width;
if (result % 8 != 0)
return -EINVAL;
return result / 8;
}
-ssize_t snd_pcm_plugin_src_size_to_samples(snd_pcm_plugin_t *plugin, size_t size)
+ssize_t snd_pcm_plugin_src_size_to_frames(snd_pcm_plugin_t *plugin, size_t size)
{
ssize_t result;
long tmp;
return result / tmp;
}
-ssize_t snd_pcm_plugin_dst_size_to_samples(snd_pcm_plugin_t *plugin, size_t size)
+ssize_t snd_pcm_plugin_dst_size_to_frames(snd_pcm_plugin_t *plugin, size_t size)
{
ssize_t result;
long tmp;
return result / tmp;
}
-ssize_t snd_pcm_plug_client_samples(snd_pcm_plugin_handle_t *handle, int channel, size_t drv_samples)
+ssize_t snd_pcm_plug_client_frames(snd_pcm_plugin_handle_t *handle, int channel, size_t drv_frames)
{
snd_pcm_plugin_t *plugin, *plugin_prev, *plugin_next;
if (channel != SND_PCM_CHANNEL_PLAYBACK &&
channel != SND_PCM_CHANNEL_CAPTURE)
return -EINVAL;
- if (drv_samples == 0)
+ if (drv_frames == 0)
return 0;
if (channel == SND_PCM_CHANNEL_PLAYBACK) {
plugin = snd_pcm_plug_last(handle, SND_PCM_CHANNEL_PLAYBACK);
- while (plugin && drv_samples > 0) {
+ while (plugin && drv_frames > 0) {
plugin_prev = plugin->prev;
- if (plugin->src_samples)
- drv_samples = plugin->src_samples(plugin, drv_samples);
+ if (plugin->src_frames)
+ drv_frames = plugin->src_frames(plugin, drv_frames);
plugin = plugin_prev;
}
} else if (channel == SND_PCM_CHANNEL_CAPTURE) {
plugin = snd_pcm_plug_first(handle, SND_PCM_CHANNEL_CAPTURE);
- while (plugin && drv_samples > 0) {
+ while (plugin && drv_frames > 0) {
plugin_next = plugin->next;
- if (plugin->dst_samples)
- drv_samples = plugin->dst_samples(plugin, drv_samples);
+ if (plugin->dst_frames)
+ drv_frames = plugin->dst_frames(plugin, drv_frames);
plugin = plugin_next;
}
}
- return drv_samples;
+ return drv_frames;
}
-ssize_t snd_pcm_plug_slave_samples(snd_pcm_plugin_handle_t *handle, int channel, size_t clt_samples)
+ssize_t snd_pcm_plug_slave_frames(snd_pcm_plugin_handle_t *handle, int channel, size_t clt_frames)
{
snd_pcm_plugin_t *plugin, *plugin_prev, *plugin_next;
- ssize_t samples;
+ ssize_t frames;
if (handle == NULL)
return -EFAULT;
if (channel != SND_PCM_CHANNEL_PLAYBACK &&
channel != SND_PCM_CHANNEL_CAPTURE)
return -EINVAL;
- if (clt_samples == 0)
+ if (clt_frames == 0)
return 0;
- samples = clt_samples;
+ frames = clt_frames;
if (channel == SND_PCM_CHANNEL_PLAYBACK) {
plugin = snd_pcm_plug_first(handle, SND_PCM_CHANNEL_PLAYBACK);
- while (plugin && samples > 0) {
+ while (plugin && frames > 0) {
plugin_next = plugin->next;
- if (plugin->dst_samples) {
- samples = plugin->dst_samples(plugin, samples);
- if (samples < 0)
- return samples;
+ if (plugin->dst_frames) {
+ frames = plugin->dst_frames(plugin, frames);
+ if (frames < 0)
+ return frames;
}
plugin = plugin_next;
}
plugin = snd_pcm_plug_last(handle, SND_PCM_CHANNEL_CAPTURE);
while (plugin) {
plugin_prev = plugin->prev;
- if (plugin->src_samples) {
- samples = plugin->src_samples(plugin, samples);
- if (samples < 0)
- return samples;
+ if (plugin->src_frames) {
+ frames = plugin->src_frames(plugin, frames);
+ if (frames < 0)
+ return frames;
}
plugin = plugin_prev;
}
}
- return samples;
+ return frames;
}
ssize_t snd_pcm_plug_client_size(snd_pcm_plugin_handle_t *handle, int channel, size_t drv_size)
plugin = snd_pcm_plug_last(handle, SND_PCM_CHANNEL_PLAYBACK);
if (plugin == NULL)
return drv_size;
- result = snd_pcm_plugin_dst_size_to_samples(plugin, drv_size);
+ result = snd_pcm_plugin_dst_size_to_frames(plugin, drv_size);
if (result < 0)
return result;
- result = snd_pcm_plug_client_samples(handle, SND_PCM_CHANNEL_PLAYBACK, result);
+ result = snd_pcm_plug_client_frames(handle, SND_PCM_CHANNEL_PLAYBACK, result);
if (result < 0)
return result;
plugin = snd_pcm_plug_first(handle, SND_PCM_CHANNEL_PLAYBACK);
- result = snd_pcm_plugin_src_samples_to_size(plugin, result);
+ result = snd_pcm_plugin_src_frames_to_size(plugin, result);
} else if (channel == SND_PCM_CHANNEL_CAPTURE) {
plugin = snd_pcm_plug_first(handle, SND_PCM_CHANNEL_CAPTURE);
if (plugin == NULL)
return drv_size;
- result = snd_pcm_plugin_src_size_to_samples(plugin, drv_size);
+ result = snd_pcm_plugin_src_size_to_frames(plugin, drv_size);
if (result < 0)
return result;
- result = snd_pcm_plug_client_samples(handle, SND_PCM_CHANNEL_CAPTURE, result);
+ result = snd_pcm_plug_client_frames(handle, SND_PCM_CHANNEL_CAPTURE, result);
if (result < 0)
return result;
plugin = snd_pcm_plug_last(handle, SND_PCM_CHANNEL_CAPTURE);
- result = snd_pcm_plugin_dst_samples_to_size(plugin, result);
+ result = snd_pcm_plugin_dst_frames_to_size(plugin, result);
}
return result;
}
plugin = snd_pcm_plug_first(handle, SND_PCM_CHANNEL_PLAYBACK);
if (plugin == NULL)
return clt_size;
- result = snd_pcm_plugin_src_size_to_samples(plugin, clt_size);
+ result = snd_pcm_plugin_src_size_to_frames(plugin, clt_size);
if (result < 0)
return result;
- result = snd_pcm_plug_slave_samples(handle, SND_PCM_CHANNEL_PLAYBACK, result);
+ result = snd_pcm_plug_slave_frames(handle, SND_PCM_CHANNEL_PLAYBACK, result);
if (result < 0)
return result;
plugin = snd_pcm_plug_last(handle, SND_PCM_CHANNEL_PLAYBACK);
- result = snd_pcm_plugin_dst_samples_to_size(plugin, result);
+ result = snd_pcm_plugin_dst_frames_to_size(plugin, result);
} else if (channel == SND_PCM_CHANNEL_CAPTURE) {
plugin = snd_pcm_plug_last(handle, SND_PCM_CHANNEL_CAPTURE);
if (plugin == NULL)
return clt_size;
- result = snd_pcm_plugin_dst_size_to_samples(plugin, clt_size);
+ result = snd_pcm_plugin_dst_size_to_frames(plugin, clt_size);
if (result < 0)
return result;
- result = snd_pcm_plug_slave_samples(handle, SND_PCM_CHANNEL_CAPTURE, result);
+ result = snd_pcm_plug_slave_frames(handle, SND_PCM_CHANNEL_CAPTURE, result);
if (result < 0)
return result;
plugin = snd_pcm_plug_first(handle, SND_PCM_CHANNEL_CAPTURE);
- result = snd_pcm_plugin_src_samples_to_size(plugin, result);
+ result = snd_pcm_plugin_src_frames_to_size(plugin, result);
}
return result;
}
{
snd_pcm_plugin_t *plugin, *next;
snd_pcm_plugin_voice_t *dst_voices;
- ssize_t samples;
+ ssize_t frames;
int err;
if ((err = snd_pcm_plug_playback_disable_useless_voices(handle, src_voices)) < 0)
return err;
plugin = snd_pcm_plug_first(handle, SND_PCM_CHANNEL_PLAYBACK);
- samples = snd_pcm_plugin_src_size_to_samples(plugin, size);
- if (samples < 0)
- return samples;
- while (plugin && samples > 0) {
+ frames = snd_pcm_plugin_src_size_to_frames(plugin, size);
+ if (frames < 0)
+ return frames;
+ while (plugin && frames > 0) {
if ((next = plugin->next) != NULL) {
- ssize_t samples1 = samples;
- if (plugin->dst_samples)
- samples1 = plugin->dst_samples(plugin, samples);
- if ((err = next->client_voices(next, samples1, &dst_voices)) < 0) {
+ ssize_t frames1 = frames;
+ if (plugin->dst_frames)
+ frames1 = plugin->dst_frames(plugin, frames);
+ if ((err = next->client_voices(next, frames1, &dst_voices)) < 0) {
snd_pcm_plug_buf_unlock(handle, SND_PCM_CHANNEL_PLAYBACK, src_voices->aptr);
return err;
}
- if (err != samples1) {
- samples = err;
- if (plugin->src_samples)
- samples = plugin->src_samples(plugin, samples1);
+ if (err != frames1) {
+ frames = err;
+ if (plugin->src_frames)
+ frames = plugin->src_frames(plugin, frames1);
}
} else {
- if ((err = snd_pcm_plugin_slave_voices(plugin, samples, &dst_voices)) < 0)
+ if ((err = snd_pcm_plugin_slave_voices(plugin, frames, &dst_voices)) < 0)
return err;
}
- pdprintf("write plugin: %s, %i\n", plugin->name, samples);
- if ((samples = plugin->transfer(plugin, src_voices, dst_voices, samples)) < 0) {
+ pdprintf("write plugin: %s, %i\n", plugin->name, frames);
+ if ((frames = plugin->transfer(plugin, src_voices, dst_voices, frames)) < 0) {
snd_pcm_plug_buf_unlock(handle, SND_PCM_CHANNEL_PLAYBACK, src_voices->aptr);
snd_pcm_plug_buf_unlock(handle, SND_PCM_CHANNEL_PLAYBACK, dst_voices->aptr);
- return samples;
+ return frames;
}
snd_pcm_plug_buf_unlock(handle, SND_PCM_CHANNEL_PLAYBACK, src_voices->aptr);
src_voices = dst_voices;
plugin = next;
}
snd_pcm_plug_buf_unlock(handle, SND_PCM_CHANNEL_PLAYBACK, src_voices->aptr);
- samples = snd_pcm_plug_client_samples(handle, SND_PCM_CHANNEL_PLAYBACK, samples);
- if (samples < 0)
- return samples;
- return snd_pcm_plugin_src_samples_to_size(snd_pcm_plug_first(handle, SND_PCM_CHANNEL_PLAYBACK), samples);
+ frames = snd_pcm_plug_client_frames(handle, SND_PCM_CHANNEL_PLAYBACK, frames);
+ if (frames < 0)
+ return frames;
+ return snd_pcm_plugin_src_frames_to_size(snd_pcm_plug_first(handle, SND_PCM_CHANNEL_PLAYBACK), frames);
}
ssize_t snd_pcm_plug_read_transfer(snd_pcm_plugin_handle_t *handle, snd_pcm_plugin_voice_t *dst_voices_final, size_t size)
{
snd_pcm_plugin_t *plugin, *next;
snd_pcm_plugin_voice_t *src_voices, *dst_voices;
- ssize_t samples;
+ ssize_t frames;
int err;
plugin = snd_pcm_plug_last(handle, SND_PCM_CHANNEL_CAPTURE);
- samples = snd_pcm_plugin_dst_size_to_samples(plugin, size);
- if (samples < 0)
- return samples;
- samples = snd_pcm_plug_slave_samples(handle, SND_PCM_CHANNEL_CAPTURE, samples);
- if (samples < 0)
- return samples;
+ frames = snd_pcm_plugin_dst_size_to_frames(plugin, size);
+ if (frames < 0)
+ return frames;
+ frames = snd_pcm_plug_slave_frames(handle, SND_PCM_CHANNEL_CAPTURE, frames);
+ if (frames < 0)
+ return frames;
plugin = snd_pcm_plug_first(handle, SND_PCM_CHANNEL_CAPTURE);
- if ((err = snd_pcm_plugin_slave_voices(plugin, samples, &src_voices)) < 0)
+ if ((err = snd_pcm_plugin_slave_voices(plugin, frames, &src_voices)) < 0)
return err;
if ((err = snd_pcm_plug_capture_disable_useless_voices(handle, src_voices, dst_voices_final) < 0))
return err;
- while (plugin && samples > 0) {
+ while (plugin && frames > 0) {
if ((next = plugin->next) != NULL) {
- if ((err = plugin->client_voices(plugin, samples, &dst_voices)) < 0) {
+ if ((err = plugin->client_voices(plugin, frames, &dst_voices)) < 0) {
snd_pcm_plug_buf_unlock(handle, SND_PCM_CHANNEL_CAPTURE, src_voices->aptr);
return err;
}
- samples = err;
+ frames = err;
} else {
dst_voices = dst_voices_final;
}
- pdprintf("read plugin: %s, %i\n", plugin->name, samples);
- if ((samples = plugin->transfer(plugin, src_voices, dst_voices, samples)) < 0) {
+ pdprintf("read plugin: %s, %i\n", plugin->name, frames);
+ if ((frames = plugin->transfer(plugin, src_voices, dst_voices, frames)) < 0) {
snd_pcm_plug_buf_unlock(handle, SND_PCM_CHANNEL_CAPTURE, src_voices->aptr);
snd_pcm_plug_buf_unlock(handle, SND_PCM_CHANNEL_CAPTURE, dst_voices->aptr);
- return samples;
+ return frames;
}
#if 0
{
src_voices = dst_voices;
}
snd_pcm_plug_buf_unlock(handle, SND_PCM_CHANNEL_CAPTURE, src_voices->aptr);
- return snd_pcm_plugin_dst_samples_to_size(snd_pcm_plug_last(handle, SND_PCM_CHANNEL_CAPTURE), samples);
+ return snd_pcm_plugin_dst_frames_to_size(snd_pcm_plug_last(handle, SND_PCM_CHANNEL_CAPTURE), frames);
}
int snd_pcm_area_silence(const snd_pcm_voice_area_t *dst_area, size_t dst_offset,
}
int snd_pcm_areas_silence(const snd_pcm_voice_area_t *dst_areas, size_t dst_offset,
- size_t vcount, size_t samples, int format)
+ size_t vcount, size_t frames, int format)
{
int width = snd_pcm_format_physical_width(format);
while (vcount > 0) {
d.addr = begin->addr;
d.first = begin->first;
d.step = width;
- err = snd_pcm_area_silence(&d, dst_offset * v, samples * v, format);
+ err = snd_pcm_area_silence(&d, dst_offset * v, frames * v, format);
vcount -= v;
} else {
- err = snd_pcm_area_silence(begin, dst_offset, samples, format);
+ err = snd_pcm_area_silence(begin, dst_offset, frames, format);
dst_areas = begin + 1;
vcount--;
}
int snd_pcm_areas_copy(const snd_pcm_voice_area_t *src_areas, size_t src_offset,
const snd_pcm_voice_area_t *dst_areas, size_t dst_offset,
- size_t vcount, size_t samples, int format)
+ size_t vcount, size_t frames, int format)
{
int width = snd_pcm_format_physical_width(format);
while (vcount > 0) {
d.addr = dst_start->addr;
d.first = dst_start->first;
d.step = width;
- snd_pcm_area_copy(&s, src_offset * v, &d, dst_offset * v, samples * v, format);
+ snd_pcm_area_copy(&s, src_offset * v, &d, dst_offset * v, frames * v, format);
vcount -= v;
} else {
- snd_pcm_area_copy(src_start, src_offset, dst_start, dst_offset, samples, format);
+ snd_pcm_area_copy(src_start, src_offset, dst_start, dst_offset, frames, format);
src_areas = src_start + 1;
dst_areas = dst_start + 1;
vcount--;
snd_pcm_channel_setup_t setup;
snd_pcm_voice_area_t *voices;
size_t sample_width;
- size_t bits_per_sample;
- size_t samples_per_frag;
+ size_t bits_per_frame;
+ size_t frames_per_frag;
snd_pcm_mmap_control_t *mmap_control;
size_t mmap_control_size;
int mmap_control_emulation;
int snd_pcm_plug_capture_voices_mask(snd_pcm_plugin_handle_t *handle,
bitset_t *client_vmask);
int snd_pcm_plugin_client_voices(snd_pcm_plugin_t *plugin,
- size_t samples,
+ size_t frames,
snd_pcm_plugin_voice_t **voices);
void *snd_pcm_plug_buf_alloc(snd_pcm_t *pcm, int channel, size_t size);
return bytes_used;
}
-static ssize_t snd_pcm_mmap_playback_samples_used(snd_pcm_t *pcm)
+static ssize_t snd_pcm_mmap_playback_frames_used(snd_pcm_t *pcm)
{
struct snd_pcm_chan *chan = &pcm->chan[SND_PCM_CHANNEL_PLAYBACK];
ssize_t bytes = snd_pcm_mmap_playback_bytes_used(chan);
- return bytes * 8 / chan->bits_per_sample;
+ return bytes * 8 / chan->bits_per_frame;
}
static inline size_t snd_pcm_mmap_capture_bytes_used(struct snd_pcm_chan *chan)
return bytes_used;
}
-static size_t snd_pcm_mmap_capture_samples_used(snd_pcm_t *pcm)
+static size_t snd_pcm_mmap_capture_frames_used(snd_pcm_t *pcm)
{
struct snd_pcm_chan *chan = &pcm->chan[SND_PCM_CHANNEL_CAPTURE];
size_t bytes = snd_pcm_mmap_capture_bytes_used(chan);
- return bytes * 8 / chan->bits_per_sample;
+ return bytes * 8 / chan->bits_per_frame;
}
-int snd_pcm_mmap_samples_used(snd_pcm_t *pcm, int channel, ssize_t *samples)
+int snd_pcm_mmap_frames_used(snd_pcm_t *pcm, int channel, ssize_t *frames)
{
struct snd_pcm_chan *chan;
if (!pcm)
if (!chan->open || !chan->mmap_control)
return -EBADFD;
if (channel == SND_PCM_CHANNEL_PLAYBACK)
- *samples = snd_pcm_mmap_playback_samples_used(pcm);
+ *frames = snd_pcm_mmap_playback_frames_used(pcm);
else
- *samples = snd_pcm_mmap_capture_samples_used(pcm);
+ *frames = snd_pcm_mmap_capture_frames_used(pcm);
return 0;
}
return chan->setup.buffer_size - snd_pcm_mmap_playback_bytes_used(chan);
}
-static size_t snd_pcm_mmap_playback_samples_free(snd_pcm_t *pcm)
+static size_t snd_pcm_mmap_playback_frames_free(snd_pcm_t *pcm)
{
struct snd_pcm_chan *chan = &pcm->chan[SND_PCM_CHANNEL_PLAYBACK];
size_t bytes = snd_pcm_mmap_playback_bytes_free(chan);
- return bytes * 8 / chan->bits_per_sample;
+ return bytes * 8 / chan->bits_per_frame;
}
static inline ssize_t snd_pcm_mmap_capture_bytes_free(struct snd_pcm_chan *chan)
return chan->setup.buffer_size - snd_pcm_mmap_capture_bytes_used(chan);
}
-static ssize_t snd_pcm_mmap_capture_samples_free(snd_pcm_t *pcm)
+static ssize_t snd_pcm_mmap_capture_frames_free(snd_pcm_t *pcm)
{
struct snd_pcm_chan *chan = &pcm->chan[SND_PCM_CHANNEL_CAPTURE];
ssize_t bytes = snd_pcm_mmap_capture_bytes_free(chan);
- return bytes * 8 / chan->bits_per_sample;
+ return bytes * 8 / chan->bits_per_frame;
}
-int snd_pcm_mmap_samples_free(snd_pcm_t *pcm, int channel, ssize_t *samples)
+int snd_pcm_mmap_frames_free(snd_pcm_t *pcm, int channel, ssize_t *frames)
{
struct snd_pcm_chan *chan;
if (!pcm)
if (!chan->open || !chan->mmap_control)
return -EBADFD;
if (channel == SND_PCM_CHANNEL_PLAYBACK)
- *samples = snd_pcm_mmap_playback_samples_free(pcm);
+ *frames = snd_pcm_mmap_playback_frames_free(pcm);
else
- *samples = snd_pcm_mmap_capture_samples_free(pcm);
+ *frames = snd_pcm_mmap_capture_frames_free(pcm);
return 0;
}
return bytes;
}
-static ssize_t snd_pcm_mmap_playback_samples_xfer(snd_pcm_t *pcm, size_t samples)
+static ssize_t snd_pcm_mmap_playback_frames_xfer(snd_pcm_t *pcm, size_t frames)
{
struct snd_pcm_chan *chan = &pcm->chan[SND_PCM_CHANNEL_PLAYBACK];
- size_t bytes = samples * chan->bits_per_sample / 8;
+ size_t bytes = frames * chan->bits_per_frame / 8;
bytes = snd_pcm_mmap_playback_bytes_xfer(pcm, bytes);
- return bytes * 8 / chan->bits_per_sample;
+ return bytes * 8 / chan->bits_per_frame;
}
-static ssize_t snd_pcm_mmap_capture_samples_xfer(snd_pcm_t *pcm, size_t samples)
+static ssize_t snd_pcm_mmap_capture_frames_xfer(snd_pcm_t *pcm, size_t frames)
{
struct snd_pcm_chan *chan = &pcm->chan[SND_PCM_CHANNEL_CAPTURE];
- size_t bytes = samples * chan->bits_per_sample / 8;
+ size_t bytes = frames * chan->bits_per_frame / 8;
bytes = snd_pcm_mmap_capture_bytes_xfer(pcm, bytes);
- return bytes * 8 / chan->bits_per_sample;
+ return bytes * 8 / chan->bits_per_frame;
}
-ssize_t snd_pcm_mmap_samples_xfer(snd_pcm_t *pcm, int channel, size_t samples)
+ssize_t snd_pcm_mmap_frames_xfer(snd_pcm_t *pcm, int channel, size_t frames)
{
struct snd_pcm_chan *chan;
if (!pcm)
if (!chan->open || !chan->mmap_control)
return -EBADFD;
if (channel == SND_PCM_CHANNEL_PLAYBACK)
- return snd_pcm_mmap_playback_samples_xfer(pcm, samples);
+ return snd_pcm_mmap_playback_frames_xfer(pcm, frames);
else
- return snd_pcm_mmap_capture_samples_xfer(pcm, samples);
+ return snd_pcm_mmap_capture_frames_xfer(pcm, frames);
}
-ssize_t snd_pcm_mmap_samples_offset(snd_pcm_t *pcm, int channel)
+ssize_t snd_pcm_mmap_frames_offset(snd_pcm_t *pcm, int channel)
{
struct snd_pcm_chan *chan;
snd_pcm_mmap_control_t *ctrl;
ctrl = chan->mmap_control;
if (!ctrl)
return -EBADFD;
- return (ctrl->byte_data % chan->setup.buffer_size) * 8 / chan->bits_per_sample;
+ return (ctrl->byte_data % chan->setup.buffer_size) * 8 / chan->bits_per_frame;
}
-int snd_pcm_mmap_commit_samples(snd_pcm_t *pcm, int channel, int samples)
+int snd_pcm_mmap_commit_frames(snd_pcm_t *pcm, int channel, int frames)
{
struct snd_pcm_chan *chan;
snd_pcm_mmap_control_t *ctrl;
ctrl = chan->mmap_control;
if (!ctrl)
return -EBADFD;
- bytes = samples * chan->bits_per_sample;
+ bytes = frames * chan->bits_per_frame;
if (bytes % 8)
return -EINVAL;
bytes /= 8;
return 0;
}
-ssize_t snd_pcm_mmap_write_areas(snd_pcm_t *pcm, snd_pcm_voice_area_t *voices, size_t samples)
+ssize_t snd_pcm_mmap_write_areas(snd_pcm_t *pcm, snd_pcm_voice_area_t *voices, size_t frames)
{
struct snd_pcm_chan *chan;
snd_pcm_mmap_control_t *ctrl;
if (ctrl->status < SND_PCM_STATUS_PREPARED)
return -EBADFD;
if (chan->setup.mode == SND_PCM_MODE_BLOCK) {
- if (samples % chan->samples_per_frag != 0)
+ if (frames % chan->frames_per_frag != 0)
return -EINVAL;
} else {
if (ctrl->status == SND_PCM_STATUS_RUNNING &&
chan->mode & SND_PCM_NONBLOCK)
snd_pcm_channel_update(pcm, SND_PCM_CHANNEL_PLAYBACK);
}
- while (samples > 0) {
+ while (frames > 0) {
ssize_t mmap_offset;
- size_t samples1;
+ size_t frames1;
int ready = snd_pcm_mmap_playback_ready(pcm);
if (ready < 0)
return ready;
return result > 0 ? result : -EPIPE;
assert(snd_pcm_mmap_playback_ready(pcm));
}
- samples1 = snd_pcm_mmap_playback_samples_xfer(pcm, samples);
- assert(samples1 > 0);
- mmap_offset = snd_pcm_mmap_samples_offset(pcm, SND_PCM_CHANNEL_PLAYBACK);
- snd_pcm_areas_copy(voices, offset, chan->voices, mmap_offset, chan->setup.format.voices, samples1, chan->setup.format.format);
+ frames1 = snd_pcm_mmap_playback_frames_xfer(pcm, frames);
+ assert(frames1 > 0);
+ mmap_offset = snd_pcm_mmap_frames_offset(pcm, SND_PCM_CHANNEL_PLAYBACK);
+ snd_pcm_areas_copy(voices, offset, chan->voices, mmap_offset, chan->setup.format.voices, frames1, chan->setup.format.format);
if (ctrl->status == SND_PCM_STATUS_XRUN)
return result > 0 ? result : -EPIPE;
- snd_pcm_mmap_commit_samples(pcm, SND_PCM_CHANNEL_PLAYBACK, samples1);
- samples -= samples1;
- offset += samples1;
- result += samples1;
+ snd_pcm_mmap_commit_frames(pcm, SND_PCM_CHANNEL_PLAYBACK, frames1);
+ frames -= frames1;
+ offset += frames1;
+ result += frames1;
if (ctrl->status == SND_PCM_STATUS_PREPARED &&
(chan->setup.start_mode == SND_PCM_START_DATA ||
(chan->setup.start_mode == SND_PCM_START_FULL &&
return result;
}
-ssize_t snd_pcm_mmap_write_samples(snd_pcm_t *pcm, const void *buffer, size_t samples)
+ssize_t snd_pcm_mmap_write_frames(snd_pcm_t *pcm, const void *buffer, size_t frames)
{
struct snd_pcm_chan *chan;
unsigned int nvoices;
return -EBADFD;
if (!chan->mmap_data || !chan->mmap_control)
return -EBADFD;
- if (samples > 0 && !buffer)
+ if (frames > 0 && !buffer)
return -EFAULT;
nvoices = chan->setup.format.voices;
if (!chan->setup.format.interleave && nvoices > 1)
for (voice = 0; voice < nvoices; ++voice) {
voices[voice].addr = (char*)buffer;
voices[voice].first = chan->sample_width * voice;
- voices[voice].step = chan->bits_per_sample;
+ voices[voice].step = chan->bits_per_frame;
}
- return snd_pcm_mmap_write_areas(pcm, voices, samples);
+ return snd_pcm_mmap_write_areas(pcm, voices, frames);
}
}
{
struct snd_pcm_chan *chan;
unsigned int nvoices;
- ssize_t samples;
+ ssize_t frames;
if (!pcm)
return -EFAULT;
chan = &pcm->chan[SND_PCM_CHANNEL_PLAYBACK];
nvoices = chan->setup.format.voices;
if (!chan->setup.format.interleave && nvoices > 1)
return -EINVAL;
- samples = bytes * 8 / chan->bits_per_sample;
- samples = snd_pcm_mmap_write_samples(pcm, buffer, samples);
- if (samples <= 0)
- return samples;
- return samples * chan->bits_per_sample / 8;
+ frames = bytes * 8 / chan->bits_per_frame;
+ frames = snd_pcm_mmap_write_frames(pcm, buffer, frames);
+ if (frames <= 0)
+ return frames;
+ return frames * chan->bits_per_frame / 8;
}
ssize_t snd_pcm_mmap_writev(snd_pcm_t *pcm, const struct iovec *vector, unsigned long vcount)
unsigned int b;
for (b = 0; b < vcount; b++) {
ssize_t ret;
- size_t samples = vector[b].iov_len * 8 / chan->bits_per_sample;
- ret = snd_pcm_mmap_write_samples(pcm, vector[b].iov_base, samples);
+ size_t frames = vector[b].iov_len * 8 / chan->bits_per_frame;
+ ret = snd_pcm_mmap_write_frames(pcm, vector[b].iov_base, frames);
if (ret < 0) {
if (result <= 0)
return ret;
unsigned int v;
ssize_t ret;
size_t bytes = 0;
- size_t samples;
+ size_t frames;
bytes = vector[0].iov_len;
for (v = 0; v < nvoices; ++v) {
if (vector[v].iov_len != bytes)
voices[v].first = 0;
voices[v].step = chan->sample_width;
}
- samples = bytes * 8 / chan->sample_width;
- ret = snd_pcm_mmap_write_areas(pcm, voices, samples);
+ frames = bytes * 8 / chan->sample_width;
+ ret = snd_pcm_mmap_write_areas(pcm, voices, frames);
if (ret < 0) {
if (result <= 0)
return ret;
break;
}
result += ret;
- if ((size_t)ret != samples)
+ if ((size_t)ret != frames)
break;
vector += nvoices;
}
}
- return result * chan->bits_per_sample / 8;
+ return result * chan->bits_per_frame / 8;
}
-ssize_t snd_pcm_mmap_read_areas(snd_pcm_t *pcm, snd_pcm_voice_area_t *voices, size_t samples)
+ssize_t snd_pcm_mmap_read_areas(snd_pcm_t *pcm, snd_pcm_voice_area_t *voices, size_t frames)
{
struct snd_pcm_chan *chan;
snd_pcm_mmap_control_t *ctrl;
if (ctrl->status < SND_PCM_STATUS_PREPARED)
return -EBADFD;
if (chan->setup.mode == SND_PCM_MODE_BLOCK) {
- if (samples % chan->samples_per_frag != 0)
+ if (frames % chan->frames_per_frag != 0)
return -EINVAL;
} else {
if (ctrl->status == SND_PCM_STATUS_RUNNING &&
if (err < 0)
return err;
}
- while (samples > 0) {
+ while (frames > 0) {
ssize_t mmap_offset;
- size_t samples1;
+ size_t frames1;
int ready = snd_pcm_mmap_capture_ready(pcm);
if (ready < 0)
return ready;
return result > 0 ? result : -EPIPE;
assert(snd_pcm_mmap_capture_ready(pcm));
}
- samples1 = snd_pcm_mmap_capture_samples_xfer(pcm, samples);
- assert(samples1 > 0);
- mmap_offset = snd_pcm_mmap_samples_offset(pcm, SND_PCM_CHANNEL_CAPTURE);
- snd_pcm_areas_copy(chan->voices, mmap_offset, voices, offset, chan->setup.format.voices, samples1, chan->setup.format.format);
+ frames1 = snd_pcm_mmap_capture_frames_xfer(pcm, frames);
+ assert(frames1 > 0);
+ mmap_offset = snd_pcm_mmap_frames_offset(pcm, SND_PCM_CHANNEL_CAPTURE);
+ snd_pcm_areas_copy(chan->voices, mmap_offset, voices, offset, chan->setup.format.voices, frames1, chan->setup.format.format);
if (ctrl->status == SND_PCM_STATUS_XRUN &&
chan->setup.xrun_mode == SND_PCM_XRUN_DRAIN)
return result > 0 ? result : -EPIPE;
- snd_pcm_mmap_commit_samples(pcm, SND_PCM_CHANNEL_CAPTURE, samples1);
- samples -= samples1;
- offset += samples1;
- result += samples1;
+ snd_pcm_mmap_commit_frames(pcm, SND_PCM_CHANNEL_CAPTURE, frames1);
+ frames -= frames1;
+ offset += frames1;
+ result += frames1;
}
return result;
}
-ssize_t snd_pcm_mmap_read_samples(snd_pcm_t *pcm, const void *buffer, size_t samples)
+ssize_t snd_pcm_mmap_read_frames(snd_pcm_t *pcm, const void *buffer, size_t frames)
{
struct snd_pcm_chan *chan;
unsigned int nvoices;
return -EBADFD;
if (!chan->mmap_data || !chan->mmap_control)
return -EBADFD;
- if (samples > 0 && !buffer)
+ if (frames > 0 && !buffer)
return -EFAULT;
nvoices = chan->setup.format.voices;
if (!chan->setup.format.interleave && nvoices > 1)
for (voice = 0; voice < nvoices; ++voice) {
voices[voice].addr = (char*)buffer;
voices[voice].first = chan->sample_width * voice;
- voices[voice].step = chan->bits_per_sample;
+ voices[voice].step = chan->bits_per_frame;
}
- return snd_pcm_mmap_read_areas(pcm, voices, samples);
+ return snd_pcm_mmap_read_areas(pcm, voices, frames);
}
}
{
struct snd_pcm_chan *chan;
unsigned int nvoices;
- ssize_t samples;
+ ssize_t frames;
if (!pcm)
return -EFAULT;
chan = &pcm->chan[SND_PCM_CHANNEL_CAPTURE];
nvoices = chan->setup.format.voices;
if (!chan->setup.format.interleave && nvoices > 1)
return -EINVAL;
- samples = bytes * 8 / chan->bits_per_sample;
- samples = snd_pcm_mmap_read_samples(pcm, buffer, samples);
- if (samples <= 0)
- return samples;
- return samples * chan->bits_per_sample / 8;
+ frames = bytes * 8 / chan->bits_per_frame;
+ frames = snd_pcm_mmap_read_frames(pcm, buffer, frames);
+ if (frames <= 0)
+ return frames;
+ return frames * chan->bits_per_frame / 8;
}
ssize_t snd_pcm_mmap_readv(snd_pcm_t *pcm, const struct iovec *vector, unsigned long vcount)
unsigned int b;
for (b = 0; b < vcount; b++) {
ssize_t ret;
- size_t samples = vector[b].iov_len * 8 / chan->bits_per_sample;
- ret = snd_pcm_mmap_read_samples(pcm, vector[b].iov_base, samples);
+ size_t frames = vector[b].iov_len * 8 / chan->bits_per_frame;
+ ret = snd_pcm_mmap_read_frames(pcm, vector[b].iov_base, frames);
if (ret < 0) {
if (result <= 0)
return ret;
unsigned int v;
ssize_t ret;
size_t bytes = 0;
- size_t samples;
+ size_t frames;
bytes = vector[0].iov_len;
for (v = 0; v < nvoices; ++v) {
if (vector[v].iov_len != bytes)
voices[v].first = 0;
voices[v].step = chan->sample_width;
}
- samples = bytes * 8 / chan->sample_width;
- ret = snd_pcm_mmap_read_areas(pcm, voices, samples);
+ frames = bytes * 8 / chan->sample_width;
+ ret = snd_pcm_mmap_read_areas(pcm, voices, frames);
if (ret < 0) {
if (result <= 0)
return ret;
break;
}
result += ret;
- if ((size_t)ret != samples)
+ if ((size_t)ret != frames)
break;
vector += nvoices;
}
}
- return result * chan->bits_per_sample / 8;
+ return result * chan->bits_per_frame / 8;
}
static ssize_t mmap_playback_bytes_xfer(struct snd_pcm_chan *chan)
struct snd_pcm_chan *chan;
unsigned int voice;
int width;
- size_t size;
if (snd_pcm_plug_direct(pcm, channel))
return snd_pcm_voice_setup(plug->slave, channel, setup);
if (voice >= chan->setup.format.voices)
return -EINVAL;
- width = snd_pcm_format_physical_width(chan->setup.format.format);
- if (width < 0)
- return width;
- size = chan->mmap_data_size;
if (chan->setup.format.interleave) {
setup->area.addr = chan->mmap_data;
- setup->area.first = chan->sample_width;
- setup->area.step = chan->bits_per_sample;
+ setup->area.first = setup->voice * chan->sample_width;
+ setup->area.step = chan->bits_per_frame;
} else {
- size /= chan->setup.format.voices;
+ size_t size = chan->mmap_data_size / chan->setup.format.voices;
setup->area.addr = chan->mmap_data + setup->voice * size;
setup->area.first = 0;
- setup->area.step = width;
+ setup->area.step = chan->sample_width;
}
return 0;
}
typedef void (*adpcm_f)(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples);
+ size_t frames);
typedef struct adpcm_private_data {
adpcm_f func;
static void adpcm_decode(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples)
+ size_t frames)
{
#define PUT_S16_LABELS
#include "plugin_ops.h"
int srcbit;
char *dst;
int src_step, srcbit_step, dst_step;
- size_t samples1;
+ size_t frames1;
adpcm_voice_t *state;
if (!src_voices[voice].enabled) {
if (dst_voices[voice].wanted)
- snd_pcm_area_silence(&dst_voices[voice].area, 0, samples, plugin->dst_format.format);
+ snd_pcm_area_silence(&dst_voices[voice].area, 0, frames, plugin->dst_format.format);
dst_voices[voice].enabled = 0;
continue;
}
srcbit_step = src_voices[voice].area.step % 8;
dst_step = dst_voices[voice].area.step / 8;
state = &data->voices[voice];
- samples1 = samples;
- while (samples1-- > 0) {
+ frames1 = frames;
+ while (frames1-- > 0) {
signed short sample;
int v;
if (srcbit)
static void adpcm_encode(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples)
+ size_t frames)
{
#define GET_S16_LABELS
#include "plugin_ops.h"
char *dst;
int dstbit;
int src_step, dst_step, dstbit_step;
- size_t samples1;
+ size_t frames1;
adpcm_voice_t *state;
if (!src_voices[voice].enabled) {
if (dst_voices[voice].wanted)
- snd_pcm_area_silence(&dst_voices[voice].area, 0, samples, plugin->dst_format.format);
+ snd_pcm_area_silence(&dst_voices[voice].area, 0, frames, plugin->dst_format.format);
dst_voices[voice].enabled = 0;
continue;
}
dst_step = dst_voices[voice].area.step / 8;
dstbit_step = dst_voices[voice].area.step % 8;
state = &data->voices[voice];
- samples1 = samples;
- while (samples1-- > 0) {
+ frames1 = frames;
+ while (frames1-- > 0) {
int v;
goto *get;
#define GET_S16_END after
static ssize_t adpcm_transfer(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples)
+ size_t frames)
{
adpcm_t *data;
unsigned int voice;
if (plugin == NULL || src_voices == NULL || dst_voices == NULL)
return -EFAULT;
- if (samples == 0)
+ if (frames == 0)
return 0;
for (voice = 0; voice < plugin->src_format.voices; voice++) {
if (plugin->src_format.format == SND_PCM_SFMT_IMA_ADPCM) {
}
}
data = (adpcm_t *)plugin->extra_data;
- data->func(plugin, src_voices, dst_voices, samples);
- return samples;
+ data->func(plugin, src_voices, dst_voices, frames);
+ return frames;
}
static int adpcm_action(snd_pcm_plugin_t * plugin,
typedef void (*alaw_f)(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples);
+ size_t frames);
typedef struct alaw_private_data {
alaw_f func;
static void alaw_decode(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples)
+ size_t frames)
{
#define PUT_S16_LABELS
#include "plugin_ops.h"
char *src;
char *dst;
int src_step, dst_step;
- size_t samples1;
+ size_t frames1;
if (!src_voices[voice].enabled) {
if (dst_voices[voice].wanted)
- snd_pcm_area_silence(&dst_voices[voice].area, 0, samples, plugin->dst_format.format);
+ snd_pcm_area_silence(&dst_voices[voice].area, 0, frames, plugin->dst_format.format);
dst_voices[voice].enabled = 0;
continue;
}
dst = dst_voices[voice].area.addr + dst_voices[voice].area.first / 8;
src_step = src_voices[voice].area.step / 8;
dst_step = dst_voices[voice].area.step / 8;
- samples1 = samples;
- while (samples1-- > 0) {
+ frames1 = frames;
+ while (frames1-- > 0) {
signed short sample = alaw2linear(*src);
goto *put;
#define PUT_S16_END after
static void alaw_encode(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples)
+ size_t frames)
{
#define GET_S16_LABELS
#include "plugin_ops.h"
char *src;
char *dst;
int src_step, dst_step;
- size_t samples1;
+ size_t frames1;
if (!src_voices[voice].enabled) {
if (dst_voices[voice].wanted)
- snd_pcm_area_silence(&dst_voices[voice].area, 0, samples, plugin->dst_format.format);
+ snd_pcm_area_silence(&dst_voices[voice].area, 0, frames, plugin->dst_format.format);
dst_voices[voice].enabled = 0;
continue;
}
dst = dst_voices[voice].area.addr + dst_voices[voice].area.first / 8;
src_step = src_voices[voice].area.step / 8;
dst_step = dst_voices[voice].area.step / 8;
- samples1 = samples;
- while (samples1-- > 0) {
+ frames1 = frames;
+ while (frames1-- > 0) {
goto *get;
#define GET_S16_END after
#include "plugin_ops.h"
static ssize_t alaw_transfer(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples)
+ size_t frames)
{
alaw_t *data;
unsigned int voice;
if (plugin == NULL || src_voices == NULL || dst_voices == NULL)
return -EFAULT;
- if (samples == 0)
+ if (frames == 0)
return 0;
for (voice = 0; voice < plugin->src_format.voices; voice++) {
if (src_voices[voice].area.first % 8 != 0 ||
return -EINVAL;
}
data = (alaw_t *)plugin->extra_data;
- data->func(plugin, src_voices, dst_voices, samples);
- return samples;
+ data->func(plugin, src_voices, dst_voices, frames);
+ return frames;
}
int snd_pcm_plugin_build_alaw(snd_pcm_plugin_handle_t *handle,
static ssize_t copy_transfer(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples)
+ size_t frames)
{
unsigned int voice;
unsigned int nvoices;
if (plugin == NULL || src_voices == NULL || dst_voices == NULL)
return -EFAULT;
- if (samples == 0)
+ if (frames == 0)
return 0;
nvoices = plugin->src_format.voices;
for (voice = 0; voice < nvoices; voice++) {
return -EINVAL;
if (!src_voices->enabled) {
if (dst_voices->wanted)
- snd_pcm_area_silence(&dst_voices->area, 0, samples, plugin->dst_format.format);
+ snd_pcm_area_silence(&dst_voices->area, 0, frames, plugin->dst_format.format);
dst_voices->enabled = 0;
continue;
}
dst_voices->enabled = 1;
- snd_pcm_area_copy(&src_voices->area, 0, &dst_voices->area, 0, samples, plugin->src_format.format);
+ snd_pcm_area_copy(&src_voices->area, 0, &dst_voices->area, 0, frames, plugin->src_format.format);
src_voices++;
dst_voices++;
}
- return samples;
+ return frames;
}
int snd_pcm_plugin_build_copy(snd_pcm_plugin_handle_t *handle,
static ssize_t io_transfer(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples)
+ size_t frames)
{
io_t *data;
ssize_t result;
if (plugin->channel == SND_PCM_CHANNEL_PLAYBACK) {
if (src_voices == NULL)
return -EINVAL;
- if ((result = snd_pcm_plugin_src_samples_to_size(plugin, samples)) < 0)
+ if ((result = snd_pcm_plugin_src_frames_to_size(plugin, frames)) < 0)
return result;
count = plugin->src_format.voices;
if (plugin->src_format.interleave) {
}
if (result < 0)
return result;
- return snd_pcm_plugin_src_size_to_samples(plugin, result);
+ return snd_pcm_plugin_src_size_to_frames(plugin, result);
} else if (plugin->channel == SND_PCM_CHANNEL_CAPTURE) {
if (dst_voices == NULL)
return -EINVAL;
- if ((result = snd_pcm_plugin_dst_samples_to_size(plugin, samples)) < 0)
+ if ((result = snd_pcm_plugin_dst_frames_to_size(plugin, frames)) < 0)
return result;
count = plugin->dst_format.voices;
if (plugin->dst_format.interleave) {
}
if (result < 0)
return result;
- return snd_pcm_plugin_dst_size_to_samples(plugin, result);
+ return snd_pcm_plugin_dst_size_to_frames(plugin, result);
} else {
return -EINVAL;
}
}
static ssize_t io_src_voices(snd_pcm_plugin_t *plugin,
- size_t samples,
+ size_t frames,
snd_pcm_plugin_voice_t **voices)
{
int err;
unsigned int voice;
snd_pcm_plugin_voice_t *v;
- err = snd_pcm_plugin_client_voices(plugin, samples, &v);
+ err = snd_pcm_plugin_client_voices(plugin, frames, &v);
if (err < 0)
return err;
*voices = v;
for (voice = 0; voice < plugin->src_format.voices; ++voice, ++v)
v->wanted = 1;
- return samples;
+ return frames;
}
int snd_pcm_plugin_build_io(snd_pcm_plugin_handle_t *pcm,
static void convert(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples)
+ size_t frames)
{
#define CONV_LABELS
#include "plugin_ops.h"
char *src;
char *dst;
int src_step, dst_step;
- size_t samples1;
+ size_t frames1;
if (!src_voices[voice].enabled) {
if (dst_voices[voice].wanted)
- snd_pcm_area_silence(&dst_voices[voice].area, 0, samples, plugin->dst_format.format);
+ snd_pcm_area_silence(&dst_voices[voice].area, 0, frames, plugin->dst_format.format);
dst_voices[voice].enabled = 0;
continue;
}
dst = dst_voices[voice].area.addr + dst_voices[voice].area.first / 8;
src_step = src_voices[voice].area.step / 8;
dst_step = dst_voices[voice].area.step / 8;
- samples1 = samples;
- while (samples1-- > 0) {
+ frames1 = frames;
+ while (frames1-- > 0) {
goto *conv;
#define CONV_END after
#include "plugin_ops.h"
static ssize_t linear_transfer(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples)
+ size_t frames)
{
linear_t *data;
unsigned int voice;
if (plugin == NULL || src_voices == NULL || dst_voices == NULL)
return -EFAULT;
data = (linear_t *)plugin->extra_data;
- if (samples == 0)
+ if (frames == 0)
return 0;
for (voice = 0; voice < plugin->src_format.voices; voice++) {
if (src_voices[voice].area.first % 8 != 0 ||
dst_voices[voice].area.step % 8 != 0)
return -EINVAL;
}
- convert(plugin, src_voices, dst_voices, samples);
- return samples;
+ convert(plugin, src_voices, dst_voices, frames);
+ return frames;
}
int conv_index(int src_format, int dst_format)
static ssize_t mmap_src_voices(snd_pcm_plugin_t *plugin,
- size_t samples,
+ size_t frames,
snd_pcm_plugin_voice_t **voices)
{
mmap_t *data;
assert(snd_pcm_mmap_ready(data->slave, plugin->channel));
}
pos = ctrl->byte_data % setup->buffer_size;
- if ((pos * 8) % chan->bits_per_sample != 0)
+ if ((pos * 8) % chan->bits_per_frame != 0)
return -EINVAL;
- pos = (pos * 8) / chan->bits_per_sample;
+ pos = (pos * 8) / chan->bits_per_frame;
sv = plugin->src_voices;
dv = chan->voices;
++sv;
++dv;
}
- return snd_pcm_mmap_samples_xfer(data->slave, plugin->channel, samples);
+ return snd_pcm_mmap_frames_xfer(data->slave, plugin->channel, frames);
}
static ssize_t mmap_dst_voices(snd_pcm_plugin_t *plugin,
- size_t samples,
+ size_t frames,
snd_pcm_plugin_voice_t **voices)
{
mmap_t *data;
assert(snd_pcm_mmap_ready(data->slave, plugin->channel));
}
pos = ctrl->byte_data % setup->buffer_size;
- if ((pos * 8) % chan->bits_per_sample != 0)
+ if ((pos * 8) % chan->bits_per_frame != 0)
return -EINVAL;
- pos = (pos * 8) / chan->bits_per_sample;
+ pos = (pos * 8) / chan->bits_per_frame;
sv = chan->voices;
dv = plugin->dst_voices;
++sv;
++dv;
}
- return snd_pcm_mmap_samples_xfer(data->slave, plugin->channel, samples);
+ return snd_pcm_mmap_frames_xfer(data->slave, plugin->channel, frames);
}
static ssize_t mmap_playback_transfer(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices UNUSED,
- size_t samples)
+ size_t frames)
{
mmap_t *data;
snd_pcm_channel_setup_t *setup;
}
#endif
- snd_pcm_mmap_commit_samples(data->slave, SND_PCM_CHANNEL_PLAYBACK, samples);
+ snd_pcm_mmap_commit_frames(data->slave, SND_PCM_CHANNEL_PLAYBACK, frames);
if (ctrl->status == SND_PCM_STATUS_PREPARED &&
(chan->setup.start_mode == SND_PCM_START_DATA ||
(chan->setup.start_mode == SND_PCM_START_FULL &&
if (err < 0)
return err;
}
- return samples;
+ return frames;
}
static ssize_t mmap_capture_transfer(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices UNUSED,
snd_pcm_plugin_voice_t *dst_voices UNUSED,
- size_t samples)
+ size_t frames)
{
mmap_t *data;
snd_pcm_channel_setup_t *setup;
setup = &data->slave->chan[SND_PCM_CHANNEL_CAPTURE].setup;
/* FIXME: not here the increment */
- snd_pcm_mmap_commit_samples(data->slave, SND_PCM_CHANNEL_CAPTURE, samples);
- return samples;
+ snd_pcm_mmap_commit_frames(data->slave, SND_PCM_CHANNEL_CAPTURE, frames);
+ return frames;
}
static int mmap_action(snd_pcm_plugin_t *plugin,
typedef void (*mulaw_f)(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples);
+ size_t frames);
typedef struct mulaw_private_data {
mulaw_f func;
static void mulaw_decode(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples)
+ size_t frames)
{
#define PUT_S16_LABELS
#include "plugin_ops.h"
char *src;
char *dst;
int src_step, dst_step;
- size_t samples1;
+ size_t frames1;
if (!src_voices[voice].enabled) {
if (dst_voices[voice].wanted)
- snd_pcm_area_silence(&dst_voices[voice].area, 0, samples, plugin->dst_format.format);
+ snd_pcm_area_silence(&dst_voices[voice].area, 0, frames, plugin->dst_format.format);
dst_voices[voice].enabled = 0;
continue;
}
dst = dst_voices[voice].area.addr + dst_voices[voice].area.first / 8;
src_step = src_voices[voice].area.step / 8;
dst_step = dst_voices[voice].area.step / 8;
- samples1 = samples;
- while (samples1-- > 0) {
+ frames1 = frames;
+ while (frames1-- > 0) {
signed short sample = ulaw2linear(*src);
goto *put;
#define PUT_S16_END after
static void mulaw_encode(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples)
+ size_t frames)
{
#define GET_S16_LABELS
#include "plugin_ops.h"
char *src;
char *dst;
int src_step, dst_step;
- size_t samples1;
+ size_t frames1;
if (!src_voices[voice].enabled) {
if (dst_voices[voice].wanted)
- snd_pcm_area_silence(&dst_voices[voice].area, 0, samples, plugin->dst_format.format);
+ snd_pcm_area_silence(&dst_voices[voice].area, 0, frames, plugin->dst_format.format);
dst_voices[voice].enabled = 0;
continue;
}
dst = dst_voices[voice].area.addr + dst_voices[voice].area.first / 8;
src_step = src_voices[voice].area.step / 8;
dst_step = dst_voices[voice].area.step / 8;
- samples1 = samples;
- while (samples1-- > 0) {
+ frames1 = frames;
+ while (frames1-- > 0) {
goto *get;
#define GET_S16_END after
#include "plugin_ops.h"
static ssize_t mulaw_transfer(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples)
+ size_t frames)
{
mulaw_t *data;
unsigned int voice;
if (plugin == NULL || src_voices == NULL || dst_voices == NULL)
return -EFAULT;
- if (samples == 0)
+ if (frames == 0)
return 0;
for (voice = 0; voice < plugin->src_format.voices; voice++) {
if (src_voices[voice].area.first % 8 != 0 ||
return -EINVAL;
}
data = (mulaw_t *)plugin->extra_data;
- data->func(plugin, src_voices, dst_voices, samples);
- return samples;
+ data->func(plugin, src_voices, dst_voices, frames);
+ return frames;
}
int snd_pcm_plugin_build_mulaw(snd_pcm_plugin_handle_t *handle,
typedef void (*rate_f)(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- int src_samples, int dst_samples);
+ int src_frames, int dst_frames);
typedef struct rate_private_data {
unsigned int pitch;
unsigned int pos;
rate_f func;
int get, put;
- ssize_t old_src_samples, old_dst_samples;
+ ssize_t old_src_frames, old_dst_frames;
rate_voice_t voices[0];
} rate_t;
static void resample_expand(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- int src_samples, int dst_samples)
+ int src_frames, int dst_frames)
{
unsigned int pos = 0;
signed int val;
char *src, *dst;
unsigned int voice;
int src_step, dst_step;
- int src_samples1, dst_samples1;
+ int src_frames1, dst_frames1;
rate_t *data = (rate_t *)plugin->extra_data;
rate_voice_t *rvoices = data->voices;
S2 = rvoices->last_S2;
if (!src_voices[voice].enabled) {
if (dst_voices[voice].wanted)
- snd_pcm_area_silence(&dst_voices[voice].area, 0, dst_samples, plugin->dst_format.format);
+ snd_pcm_area_silence(&dst_voices[voice].area, 0, dst_frames, plugin->dst_format.format);
dst_voices[voice].enabled = 0;
continue;
}
dst = (char *)dst_voices[voice].area.addr + dst_voices[voice].area.first / 8;
src_step = src_voices[voice].area.step / 8;
dst_step = dst_voices[voice].area.step / 8;
- src_samples1 = src_samples;
- dst_samples1 = dst_samples;
+ src_frames1 = src_frames;
+ dst_frames1 = dst_frames;
if (pos & ~MASK) {
get_s16_end = &&after_get1;
goto *get;
S1 = S2;
S2 = sample;
src += src_step;
- src_samples--;
+ src_frames--;
}
- while (dst_samples1-- > 0) {
+ while (dst_frames1-- > 0) {
if (pos & ~MASK) {
pos &= MASK;
S1 = S2;
- if (src_samples1-- > 0) {
+ if (src_frames1-- > 0) {
get_s16_end = &&after_get2;
goto *get;
after_get2:
static void resample_shrink(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- int src_samples, int dst_samples)
+ int src_frames, int dst_frames)
{
unsigned int pos = 0;
signed int val;
char *src, *dst;
unsigned int voice;
int src_step, dst_step;
- int src_samples1, dst_samples1;
+ int src_frames1, dst_frames1;
rate_t *data = (rate_t *)plugin->extra_data;
rate_voice_t *rvoices = data->voices;
S2 = rvoices->last_S2;
if (!src_voices[voice].enabled) {
if (dst_voices[voice].wanted)
- snd_pcm_area_silence(&dst_voices[voice].area, 0, dst_samples, plugin->dst_format.format);
+ snd_pcm_area_silence(&dst_voices[voice].area, 0, dst_frames, plugin->dst_format.format);
dst_voices[voice].enabled = 0;
continue;
}
dst = (char *)dst_voices[voice].area.addr + dst_voices[voice].area.first / 8;
src_step = src_voices[voice].area.step / 8;
dst_step = dst_voices[voice].area.step / 8;
- src_samples1 = src_samples;
- dst_samples1 = dst_samples;
- while (dst_samples1 > 0) {
+ src_frames1 = src_frames;
+ dst_frames1 = dst_frames;
+ while (dst_frames1 > 0) {
S1 = S2;
- if (src_samples1-- > 0) {
+ if (src_frames1-- > 0) {
goto *get;
#define GET_S16_END after_get
#include "plugin_ops.h"
#undef PUT_S16_END
after_put:
dst += dst_step;
- dst_samples1--;
+ dst_frames1--;
}
pos += data->pitch;
}
data->pos = pos;
}
-static ssize_t rate_src_samples(snd_pcm_plugin_t *plugin, size_t samples)
+static ssize_t rate_src_frames(snd_pcm_plugin_t *plugin, size_t frames)
{
rate_t *data;
ssize_t res;
- if (plugin == NULL || samples <= 0)
+ if (plugin == NULL || frames <= 0)
return -EINVAL;
data = (rate_t *)plugin->extra_data;
if (plugin->src_format.rate < plugin->dst_format.rate) {
- res = (((samples * data->pitch) + (BITS/2)) >> SHIFT);
+ res = (((frames * data->pitch) + (BITS/2)) >> SHIFT);
} else {
- res = (((samples << SHIFT) + (data->pitch / 2)) / data->pitch);
+ res = (((frames << SHIFT) + (data->pitch / 2)) / data->pitch);
}
- if (data->old_src_samples > 0) {
- ssize_t samples1 = samples, res1 = data->old_dst_samples;
- while (data->old_src_samples < samples1) {
- samples1 >>= 1;
+ if (data->old_src_frames > 0) {
+ ssize_t frames1 = frames, res1 = data->old_dst_frames;
+ while (data->old_src_frames < frames1) {
+ frames1 >>= 1;
res1 <<= 1;
}
- while (data->old_src_samples > samples1) {
- samples1 <<= 1;
+ while (data->old_src_frames > frames1) {
+ frames1 <<= 1;
res1 >>= 1;
}
- if (data->old_src_samples == samples1)
+ if (data->old_src_frames == frames1)
return res1;
}
- data->old_src_samples = samples;
- data->old_dst_samples = res;
+ data->old_src_frames = frames;
+ data->old_dst_frames = res;
return res;
}
-static ssize_t rate_dst_samples(snd_pcm_plugin_t *plugin, size_t samples)
+static ssize_t rate_dst_frames(snd_pcm_plugin_t *plugin, size_t frames)
{
rate_t *data;
ssize_t res;
- if (plugin == NULL || samples <= 0)
+ if (plugin == NULL || frames <= 0)
return -EINVAL;
data = (rate_t *)plugin->extra_data;
if (plugin->src_format.rate < plugin->dst_format.rate) {
- res = (((samples << SHIFT) + (data->pitch / 2)) / data->pitch);
+ res = (((frames << SHIFT) + (data->pitch / 2)) / data->pitch);
} else {
- res = (((samples * data->pitch) + (BITS/2)) >> SHIFT);
+ res = (((frames * data->pitch) + (BITS/2)) >> SHIFT);
}
- if (data->old_dst_samples > 0) {
- ssize_t samples1 = samples, res1 = data->old_src_samples;
- while (data->old_dst_samples < samples1) {
- samples1 >>= 1;
+ if (data->old_dst_frames > 0) {
+ ssize_t frames1 = frames, res1 = data->old_src_frames;
+ while (data->old_dst_frames < frames1) {
+ frames1 >>= 1;
res1 <<= 1;
}
- while (data->old_dst_samples > samples1) {
- samples1 <<= 1;
+ while (data->old_dst_frames > frames1) {
+ frames1 <<= 1;
res1 >>= 1;
}
- if (data->old_dst_samples == samples1)
+ if (data->old_dst_frames == frames1)
return res1;
}
- data->old_dst_samples = samples;
- data->old_src_samples = res;
+ data->old_dst_frames = frames;
+ data->old_src_frames = res;
return res;
}
static ssize_t rate_transfer(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples)
+ size_t frames)
{
- size_t dst_samples;
+ size_t dst_frames;
unsigned int voice;
rate_t *data;
if (plugin == NULL || src_voices == NULL || dst_voices == NULL)
return -EFAULT;
- if (samples == 0)
+ if (frames == 0)
return 0;
for (voice = 0; voice < plugin->src_format.voices; voice++) {
if (src_voices[voice].area.first % 8 != 0 ||
return -EINVAL;
}
- dst_samples = rate_dst_samples(plugin, samples);
+ dst_frames = rate_dst_frames(plugin, frames);
data = (rate_t *)plugin->extra_data;
- data->func(plugin, src_voices, dst_voices, samples, dst_samples);
- return dst_samples;
+ data->func(plugin, src_voices, dst_voices, frames, dst_frames);
+ return dst_frames;
}
static int rate_action(snd_pcm_plugin_t *plugin,
}
data->pos = 0;
rate_init(plugin);
- data->old_src_samples = data->old_dst_samples = 0;
+ data->old_src_frames = data->old_dst_frames = 0;
plugin->transfer = rate_transfer;
- plugin->src_samples = rate_src_samples;
- plugin->dst_samples = rate_dst_samples;
+ plugin->src_frames = rate_src_frames;
+ plugin->dst_frames = rate_dst_frames;
plugin->action = rate_action;
*r_plugin = plugin;
return 0;
#include "../pcm_local.h"
#endif
+/* The best possible hack to support missing optimization in gcc 2.7.2.3 */
+#if ROUTE_PLUGIN_RESOLUTION & (ROUTE_PLUGIN_RESOLUTION - 1) != 0
+#define div(a) a /= ROUTE_PLUGIN_RESOLUTION
+#elif ROUTE_PLUGIN_RESOLUTION == 16
+#define div(a) a >>= 4
+#else
+#error "Add some code here"
+#endif
+
typedef struct ttable_dst ttable_dst_t;
typedef struct route_private_data route_t;
typedef void (*route_voice_f)(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voice,
- ttable_dst_t* ttable, size_t samples);
+ ttable_dst_t* ttable, size_t frames);
typedef struct {
int voice;
static void route_to_voice_from_zero(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices UNUSED,
snd_pcm_plugin_voice_t *dst_voice,
- ttable_dst_t* ttable UNUSED, size_t samples)
+ ttable_dst_t* ttable UNUSED, size_t frames)
{
if (dst_voice->wanted)
- snd_pcm_area_silence(&dst_voice->area, 0, samples, plugin->dst_format.format);
+ snd_pcm_area_silence(&dst_voice->area, 0, frames, plugin->dst_format.format);
dst_voice->enabled = 0;
}
static void route_to_voice_from_one(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voice,
- ttable_dst_t* ttable, size_t samples)
+ ttable_dst_t* ttable, size_t frames)
{
#define CONV_LABELS
#include "plugin_ops.h"
break;
}
if (srcidx == ttable->nsrcs) {
- route_to_voice_from_zero(plugin, src_voices, dst_voice, ttable, samples);
+ route_to_voice_from_zero(plugin, src_voices, dst_voice, ttable, frames);
return;
}
src_step = src_voice->area.step / 8;
dst = dst_voice->area.addr + dst_voice->area.first / 8;
dst_step = dst_voice->area.step / 8;
- while (samples-- > 0) {
+ while (frames-- > 0) {
goto *conv;
#define CONV_END after
#include "plugin_ops.h"
static void route_to_voice(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voice,
- ttable_dst_t* ttable, size_t samples)
+ ttable_dst_t* ttable, size_t frames)
{
#define GET_U_LABELS
#define PUT_U32_LABELS
}
nsrcs = srcidx1;
if (nsrcs == 0) {
- route_to_voice_from_zero(plugin, src_voices, dst_voice, ttable, samples);
+ route_to_voice_from_zero(plugin, src_voices, dst_voice, ttable, frames);
return;
} else if (nsrcs == 1 && src_tt[0].as_int == ROUTE_PLUGIN_RESOLUTION) {
- route_to_voice_from_one(plugin, src_voices, dst_voice, ttable, samples);
+ route_to_voice_from_one(plugin, src_voices, dst_voice, ttable, frames);
return;
}
dst = dst_voice->area.addr + dst_voice->area.first / 8;
dst_step = dst_voice->area.step / 8;
- while (samples-- > 0) {
+ while (frames-- > 0) {
ttable_src_t *ttp = src_tt;
sum_t sum;
norm_int64_8_att:
sum.as_uint64 <<= 8;
norm_int64_0_att:
- sum.as_uint64 /= ROUTE_PLUGIN_RESOLUTION;
+ div(sum.as_uint64);
goto norm_int;
norm_int32_16_att:
sum.as_uint64 = sum.as_uint32;
norm_int64_16_att:
sum.as_uint64 <<= 16;
- sum.as_uint64 /= ROUTE_PLUGIN_RESOLUTION;
+ div(sum.as_uint64);
goto norm_int;
norm_int32_24_att:
sum.as_uint64 = sum.as_uint32;
norm_int64_24_att:
sum.as_uint64 <<= 24;
- sum.as_uint64 /= ROUTE_PLUGIN_RESOLUTION;
+ div(sum.as_uint64);
goto norm_int;
norm_int32_8_noatt:
static ssize_t route_transfer(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voices,
- size_t samples)
+ size_t frames)
{
route_t *data;
int src_nvoices, dst_nvoices;
if (plugin == NULL || src_voices == NULL || dst_voices == NULL)
return -EFAULT;
- if (samples == 0)
+ if (frames == 0)
return 0;
data = (route_t *)plugin->extra_data;
ttp = data->ttable;
dvp = dst_voices;
for (dst_voice = 0; dst_voice < dst_nvoices; ++dst_voice) {
- ttp->func(plugin, src_voices, dvp, ttp, samples);
+ ttp->func(plugin, src_voices, dvp, ttp, frames);
dvp++;
ttp++;
}
- return samples;
+ return frames;
}
int getput_index(int format)