diff options
author | dvdli <70133153+dvdli@users.noreply.github.com> | 2023-09-04 17:34:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-04 17:34:44 +0800 |
commit | c0fbed5e2ba87ee8cacc3cbca55488bcb85f327a (patch) | |
tree | d8f0fabf18bb5338c21819d8b1669c1031eccb2e /src | |
parent | 7c467a1179cca66bb65a4a04f889319e4bfb9b3e (diff) | |
parent | bc3af517534346742a2e753f753a0ad21f51513b (diff) |
Merge pull request #246 from CodeLinaro/master
Support pcm drain ops
Diffstat (limited to 'src')
-rw-r--r-- | src/pcm.c | 16 | ||||
-rw-r--r-- | src/pcm_plugin.c | 13 |
2 files changed, 29 insertions, 0 deletions
@@ -1218,6 +1218,22 @@ int pcm_start(struct pcm *pcm) return 0; } +/** Drains a PCM. + * @param pcm A PCM handle. + * @return On success, zero; on failure, a negative number. + * @ingroup libtinyalsa-pcm + */ +int pcm_drain(struct pcm *pcm) +{ + if (!pcm_is_ready(pcm)) + return -1; + + if (pcm->ops->ioctl(pcm->data, SNDRV_PCM_IOCTL_DRAIN) < 0) + return oops(pcm, errno, "cannot drain channel"); + + return 0; +} + /** Stops a PCM. * @param pcm A PCM handle. * @return On success, zero; on failure, a negative number. diff --git a/src/pcm_plugin.c b/src/pcm_plugin.c index b6b69aa..4d2651c 100644 --- a/src/pcm_plugin.c +++ b/src/pcm_plugin.c @@ -622,6 +622,16 @@ static int pcm_plug_drop(struct pcm_plug_data *plug_data) return rc; } +static int pcm_plug_drain(struct pcm_plug_data *plug_data) +{ + struct pcm_plugin *plugin = plug_data->plugin; + + if (plugin->state != PCM_PLUG_STATE_RUNNING) + return -EBADFD; + + return plug_data->ops->drain(plugin); +} + static int pcm_plug_ioctl(void *data, unsigned int cmd, ...) { struct pcm_plug_data *plug_data = data; @@ -659,6 +669,9 @@ static int pcm_plug_ioctl(void *data, unsigned int cmd, ...) case SNDRV_PCM_IOCTL_START: ret = pcm_plug_start(plug_data); break; + case SNDRV_PCM_IOCTL_DRAIN: + ret = pcm_plug_drain(plug_data); + break; case SNDRV_PCM_IOCTL_DROP: ret = pcm_plug_drop(plug_data); break; |