aboutsummaryrefslogtreecommitdiff
path: root/src/pcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pcm.c')
-rw-r--r--src/pcm.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/pcm.c b/src/pcm.c
index d460593..1b2103a 100644
--- a/src/pcm.c
+++ b/src/pcm.c
@@ -1092,8 +1092,10 @@ struct pcm *pcm_open(unsigned int card, unsigned int device,
}
pcm->subdevice = info.subdevice;
- if (pcm_set_config(pcm, config) != 0)
+ if (pcm_set_config(pcm, config) != 0) {
+ memcpy(bad_pcm.error, pcm->error, sizeof(pcm->error));
goto fail_close;
+ }
rc = pcm_hw_mmap_status(pcm);
if (rc < 0) {
@@ -1216,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.