mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-01 22:58:49 -04:00
improved stream linking and plugin code cleanups
- added link/unlink/link_fd fast_ops callbacks - moved code from snd_pcm_link to pcm_hw.c - moved "empty" routines pointing to slave to pcm_generic.c - introduced snd_pcm_generic_t
This commit is contained in:
parent
9501520606
commit
836987aa99
25 changed files with 767 additions and 957 deletions
|
|
@ -137,74 +137,11 @@ void snd_pcm_plugin_init(snd_pcm_plugin_t *plugin)
|
|||
snd_atomic_write_init(&plugin->watom);
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_close(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
int err = 0;
|
||||
if (plugin->close_slave)
|
||||
err = snd_pcm_close(plugin->slave);
|
||||
free(plugin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_nonblock(snd_pcm_t *pcm, int nonblock)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
return snd_pcm_nonblock(plugin->slave, nonblock);
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_async(snd_pcm_t *pcm, int sig, pid_t pid)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
return snd_pcm_async(plugin->slave, sig, pid);
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_poll_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
return snd_pcm_poll_descriptors_revents(plugin->slave, pfds, nfds, revents);
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_info(snd_pcm_t *pcm, snd_pcm_info_t * info)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
return snd_pcm_info(plugin->slave, info);
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_hw_free(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
return snd_pcm_hw_free(plugin->slave);
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
return snd_pcm_sw_params(plugin->slave, params);
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *info)
|
||||
{
|
||||
return snd_pcm_channel_info_shm(pcm, info, -1);
|
||||
}
|
||||
|
||||
snd_pcm_state_t snd_pcm_plugin_state(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
return snd_pcm_state(plugin->slave);
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_hwsync(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
return snd_pcm_hwsync(plugin->slave);
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
snd_pcm_sframes_t sd;
|
||||
int err = snd_pcm_delay(plugin->slave, &sd);
|
||||
int err = snd_pcm_delay(plugin->gen.slave, &sd);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (plugin->client_frames)
|
||||
|
|
@ -218,7 +155,7 @@ int snd_pcm_plugin_prepare(snd_pcm_t *pcm)
|
|||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
int err;
|
||||
snd_atomic_write_begin(&plugin->watom);
|
||||
err = snd_pcm_prepare(plugin->slave);
|
||||
err = snd_pcm_prepare(plugin->gen.slave);
|
||||
if (err < 0) {
|
||||
snd_atomic_write_end(&plugin->watom);
|
||||
return err;
|
||||
|
|
@ -239,7 +176,7 @@ static int snd_pcm_plugin_reset(snd_pcm_t *pcm)
|
|||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
int err;
|
||||
snd_atomic_write_begin(&plugin->watom);
|
||||
err = snd_pcm_reset(plugin->slave);
|
||||
err = snd_pcm_reset(plugin->gen.slave);
|
||||
if (err < 0) {
|
||||
snd_atomic_write_end(&plugin->watom);
|
||||
return err;
|
||||
|
|
@ -255,30 +192,6 @@ static int snd_pcm_plugin_reset(snd_pcm_t *pcm)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_start(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
return snd_pcm_start(plugin->slave);
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_drop(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
return snd_pcm_drop(plugin->slave);
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_drain(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
return snd_pcm_drain(plugin->slave);
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_pause(snd_pcm_t *pcm, int enable)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
return snd_pcm_pause(plugin->slave, enable);
|
||||
}
|
||||
|
||||
snd_pcm_sframes_t snd_pcm_plugin_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
|
|
@ -296,7 +209,7 @@ snd_pcm_sframes_t snd_pcm_plugin_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames
|
|||
else
|
||||
sframes = frames;
|
||||
snd_atomic_write_begin(&plugin->watom);
|
||||
sframes = snd_pcm_rewind(plugin->slave, sframes);
|
||||
sframes = snd_pcm_rewind(plugin->gen.slave, sframes);
|
||||
if (sframes < 0) {
|
||||
snd_atomic_write_end(&plugin->watom);
|
||||
return sframes;
|
||||
|
|
@ -325,7 +238,7 @@ snd_pcm_sframes_t snd_pcm_plugin_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frame
|
|||
else
|
||||
sframes = frames;
|
||||
snd_atomic_write_begin(&plugin->watom);
|
||||
sframes = INTERNAL(snd_pcm_forward)(plugin->slave, (snd_pcm_uframes_t) sframes);
|
||||
sframes = INTERNAL(snd_pcm_forward)(plugin->gen.slave, (snd_pcm_uframes_t) sframes);
|
||||
if ((snd_pcm_sframes_t) sframes < 0) {
|
||||
snd_atomic_write_end(&plugin->watom);
|
||||
return sframes;
|
||||
|
|
@ -337,27 +250,13 @@ snd_pcm_sframes_t snd_pcm_plugin_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frame
|
|||
return n;
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_resume(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
return snd_pcm_resume(plugin->slave);
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_poll_ask(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
if (plugin->slave->fast_ops->poll_ask)
|
||||
return plugin->slave->fast_ops->poll_ask(plugin->slave->fast_op_arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static snd_pcm_sframes_t snd_pcm_plugin_write_areas(snd_pcm_t *pcm,
|
||||
const snd_pcm_channel_area_t *areas,
|
||||
snd_pcm_uframes_t offset,
|
||||
snd_pcm_uframes_t size)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
snd_pcm_t *slave = plugin->slave;
|
||||
snd_pcm_t *slave = plugin->gen.slave;
|
||||
snd_pcm_uframes_t xfer = 0;
|
||||
snd_pcm_sframes_t result;
|
||||
int err;
|
||||
|
|
@ -404,7 +303,7 @@ static snd_pcm_sframes_t snd_pcm_plugin_read_areas(snd_pcm_t *pcm,
|
|||
snd_pcm_uframes_t size)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
snd_pcm_t *slave = plugin->slave;
|
||||
snd_pcm_t *slave = plugin->gen.slave;
|
||||
snd_pcm_uframes_t xfer = 0;
|
||||
snd_pcm_sframes_t result;
|
||||
|
||||
|
|
@ -483,7 +382,7 @@ snd_pcm_sframes_t snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm,
|
|||
snd_pcm_uframes_t size)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
snd_pcm_t *slave = plugin->slave;
|
||||
snd_pcm_t *slave = plugin->gen.slave;
|
||||
const snd_pcm_channel_area_t *areas;
|
||||
snd_pcm_uframes_t appl_offset;
|
||||
snd_pcm_sframes_t slave_size;
|
||||
|
|
@ -549,7 +448,7 @@ snd_pcm_sframes_t snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm,
|
|||
snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
snd_pcm_t *slave = plugin->slave;
|
||||
snd_pcm_t *slave = plugin->gen.slave;
|
||||
snd_pcm_sframes_t slave_size;
|
||||
|
||||
slave_size = snd_pcm_avail_update(slave);
|
||||
|
|
@ -617,16 +516,6 @@ snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
|
|||
}
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_mmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_munmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
|
|
@ -635,7 +524,7 @@ int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
|
|||
snd_atomic_read_init(&ratom, &plugin->watom);
|
||||
_again:
|
||||
snd_atomic_read_begin(&ratom);
|
||||
err = snd_pcm_status(plugin->slave, status);
|
||||
err = snd_pcm_status(plugin->gen.slave, status);
|
||||
if (err < 0) {
|
||||
snd_atomic_read_ok(&ratom);
|
||||
return err;
|
||||
|
|
@ -655,33 +544,24 @@ int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_hw_refine_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
return snd_pcm_hw_refine(plugin->slave, params);
|
||||
}
|
||||
|
||||
int snd_pcm_plugin_hw_params_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
return _snd_pcm_hw_params(plugin->slave, params);
|
||||
}
|
||||
|
||||
snd_pcm_fast_ops_t snd_pcm_plugin_fast_ops = {
|
||||
.status = snd_pcm_plugin_status,
|
||||
.state = snd_pcm_plugin_state,
|
||||
.hwsync = snd_pcm_plugin_hwsync,
|
||||
.status = snd_pcm_generic_status,
|
||||
.state = snd_pcm_generic_state,
|
||||
.hwsync = snd_pcm_generic_hwsync,
|
||||
.delay = snd_pcm_plugin_delay,
|
||||
.prepare = snd_pcm_plugin_prepare,
|
||||
.reset = snd_pcm_plugin_reset,
|
||||
.start = snd_pcm_plugin_start,
|
||||
.drop = snd_pcm_plugin_drop,
|
||||
.drain = snd_pcm_plugin_drain,
|
||||
.pause = snd_pcm_plugin_pause,
|
||||
.start = snd_pcm_generic_start,
|
||||
.drop = snd_pcm_generic_drop,
|
||||
.drain = snd_pcm_generic_drain,
|
||||
.pause = snd_pcm_generic_pause,
|
||||
.rewind = snd_pcm_plugin_rewind,
|
||||
.forward = snd_pcm_plugin_forward,
|
||||
.resume = snd_pcm_plugin_resume,
|
||||
.poll_ask = snd_pcm_plugin_poll_ask,
|
||||
.resume = snd_pcm_generic_resume,
|
||||
.poll_ask = snd_pcm_generic_poll_ask,
|
||||
.link_fd = snd_pcm_generic_link_fd,
|
||||
.link = snd_pcm_generic_link,
|
||||
.unlink = snd_pcm_generic_unlink,
|
||||
.writei = snd_pcm_plugin_writei,
|
||||
.writen = snd_pcm_plugin_writen,
|
||||
.readi = snd_pcm_plugin_readi,
|
||||
|
|
@ -690,5 +570,4 @@ snd_pcm_fast_ops_t snd_pcm_plugin_fast_ops = {
|
|||
.mmap_commit = snd_pcm_plugin_mmap_commit,
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue