Fixed mmaped access..

This commit is contained in:
Jaroslav Kysela 1999-11-08 23:19:36 +00:00
parent 8abf9370b5
commit 8328751e64
5 changed files with 15 additions and 39 deletions

View file

@ -60,8 +60,9 @@ typedef struct snd_stru_pcm_plugin snd_pcm_plugin_t;
typedef enum {
INIT = 0,
DRAIN = 1,
FLUSH = 2
PREPARE = 1,
DRAIN = 2,
FLUSH = 3
} snd_pcm_plugin_action_t;
#define snd_pcm_plugin_extra_data(plugin) (((char *)plugin) + sizeof(*plugin))
@ -95,6 +96,7 @@ int snd_pcm_plugin_info(snd_pcm_t *handle, snd_pcm_channel_info_t *info);
int snd_pcm_plugin_params(snd_pcm_t *handle, snd_pcm_channel_params_t *params);
int snd_pcm_plugin_setup(snd_pcm_t *handle, snd_pcm_channel_setup_t *setup);
int snd_pcm_plugin_status(snd_pcm_t *handle, snd_pcm_channel_status_t *status);
int snd_pcm_plugin_prepare(snd_pcm_t *handle, int channel);
int snd_pcm_plugin_drain_playback(snd_pcm_t *handle);
int snd_pcm_plugin_flush(snd_pcm_t *handle, int channel);
int snd_pcm_plugin_pointer(snd_pcm_t *pcm, int channel, void **ptr, size_t *size);

View file

@ -504,6 +504,15 @@ int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_channel_status_t *status)
return 0;
}
int snd_pcm_plugin_prepare(snd_pcm_t *pcm, int channel)
{
int err;
if ((err = snd_pcm_plugin_action(pcm, channel, PREPARE))<0)
return err;
return snd_pcm_channel_prepare(pcm, channel);
}
int snd_pcm_plugin_drain_playback(snd_pcm_t *pcm)
{
int err;

View file

@ -55,21 +55,6 @@ static ssize_t block_transfer(snd_pcm_plugin_t *plugin,
}
}
static int block_action(snd_pcm_plugin_t *plugin, snd_pcm_plugin_action_t action)
{
struct block_private_data *data;
if (plugin == NULL)
return -EINVAL;
data = (struct block_private_data *)snd_pcm_plugin_extra_data(plugin);
if (action == DRAIN && data->channel == SND_PCM_CHANNEL_PLAYBACK) {
return snd_pcm_drain_playback(data->pcm);
} else if (action == FLUSH) {
return snd_pcm_flush_channel(data->pcm, data->channel);
}
return 0; /* silenty ignore other actions */
}
int snd_pcm_plugin_build_block(snd_pcm_t *pcm, int channel, snd_pcm_plugin_t **r_plugin)
{
struct block_private_data *data;
@ -90,7 +75,6 @@ int snd_pcm_plugin_build_block(snd_pcm_t *pcm, int channel, snd_pcm_plugin_t **r
data->pcm = pcm;
data->channel = channel;
plugin->transfer = block_transfer;
plugin->action = block_action;
*r_plugin = plugin;
return 0;
}

View file

@ -208,7 +208,6 @@ static ssize_t mmap_transfer(snd_pcm_plugin_t *plugin,
static int mmap_action(snd_pcm_plugin_t *plugin, snd_pcm_plugin_action_t action)
{
struct mmap_private_data *data;
int res;
if (plugin == NULL)
return -EINVAL;
@ -217,14 +216,12 @@ static int mmap_action(snd_pcm_plugin_t *plugin, snd_pcm_plugin_action_t action)
if (data->control)
snd_pcm_munmap(data->pcm, data->channel);
return snd_pcm_mmap(data->pcm, data->channel, &data->control, (void **)&data->buffer);
} else if (action == PREPARE) {
data->frag = 0;
} else if (action == DRAIN && data->channel == SND_PCM_CHANNEL_PLAYBACK) {
res = snd_pcm_drain_playback(data->pcm);
data->frag = 0;
return res;
} else if (action == FLUSH) {
res = snd_pcm_flush_channel(data->pcm, data->channel);
data->frag = 0;
return res;
}
return 0; /* silenty ignore other actions */
}

View file

@ -55,21 +55,6 @@ static ssize_t stream_transfer(snd_pcm_plugin_t *plugin,
}
}
static int stream_action(snd_pcm_plugin_t *plugin, snd_pcm_plugin_action_t action)
{
struct stream_private_data *data;
if (plugin == NULL)
return -EINVAL;
data = (struct stream_private_data *)snd_pcm_plugin_extra_data(plugin);
if (action == DRAIN && data->channel == SND_PCM_CHANNEL_PLAYBACK) {
return snd_pcm_drain_playback(data->pcm);
} else if (action == FLUSH) {
return snd_pcm_flush_channel(data->pcm, data->channel);
}
return 0; /* silenty ignore other actions */
}
int snd_pcm_plugin_build_stream(snd_pcm_t *pcm, int channel, snd_pcm_plugin_t **r_plugin)
{
struct stream_private_data *data;
@ -90,7 +75,6 @@ int snd_pcm_plugin_build_stream(snd_pcm_t *pcm, int channel, snd_pcm_plugin_t **
data->pcm = pcm;
data->channel = channel;
plugin->transfer = stream_transfer;
plugin->action = stream_action;
*r_plugin = plugin;
return 0;
}