aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRohit kumar <rohitkr@codeaurora.org>2020-08-19 15:13:57 +0530
committerRohit kumar <rohitkr@codeaurora.org>2020-08-25 11:39:56 +0530
commit1ef2d458f56d6583de5d35da6d8ca0dc8ec2a146 (patch)
tree7e6328eddf3a51589d79f0b4eec4bc17b027085f
parent1d72910d90d4b0b3d5719c865461a7637f4cc467 (diff)
pcm_plugin: Update pcm state in sync_ptr ops
PCM state is currently not updated in plugin. Add support to update the state variable.
-rw-r--r--src/pcm_plugin.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/pcm_plugin.c b/src/pcm_plugin.c
index 695ad2c..5d5f79c 100644
--- a/src/pcm_plugin.c
+++ b/src/pcm_plugin.c
@@ -89,6 +89,24 @@ static unsigned int param_list[] = {
SNDRV_PCM_HW_PARAM_PERIODS,
};
+static int convert_plugin_to_pcm_state(int plugin_state)
+{
+ switch (plugin_state) {
+ case PCM_PLUG_STATE_SETUP:
+ return PCM_STATE_SETUP;
+ case PCM_PLUG_STATE_RUNNING:
+ return PCM_STATE_RUNNING;
+ case PCM_PLUG_STATE_PREPARED:
+ return PCM_STATE_PREPARED;
+ case PCM_PLUG_STATE_OPEN:
+ return PCM_STATE_OPEN;
+ default:
+ break;
+ }
+
+ return PCM_STATE_OPEN;
+}
+
static void pcm_plug_close(void *data)
{
struct pcm_plug_data *plug_data = data;
@@ -513,8 +531,15 @@ static int pcm_plug_sync_ptr(struct pcm_plug_data *plug_data,
struct snd_pcm_sync_ptr *sync_ptr)
{
struct pcm_plugin *plugin = plug_data->plugin;
+ int ret = -EBADFD;
- return plug_data->ops->sync_ptr(plugin, sync_ptr);
+ if (plugin->state >= PCM_PLUG_STATE_SETUP) {
+ ret = plug_data->ops->sync_ptr(plugin, sync_ptr);
+ if (ret == 0)
+ sync_ptr->s.status.state = convert_plugin_to_pcm_state(plugin->state);
+ }
+
+ return ret;
}
static int pcm_plug_writei_frames(struct pcm_plug_data *plug_data,