diff options
author | Taylor Holberton <taylorcholberton@gmail.com> | 2016-12-04 13:42:28 -0800 |
---|---|---|
committer | Taylor Holberton <taylorcholberton@gmail.com> | 2016-12-04 13:42:28 -0800 |
commit | 558e594ba24b34cfd7374cf706b834479324c917 (patch) | |
tree | 21e3e735d7e43c35e5779d5647600c31def193d9 /src | |
parent | 0cceb331992a0fd41aac9aaf448ecc40b7899a16 (diff) |
Added pcm_link and pcm_unlink functions
The link function is necessary for time sychronization between multiple PCMs.
Diffstat (limited to 'src')
-rw-r--r-- | src/pcm.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -1053,6 +1053,38 @@ int pcm_is_ready(const struct pcm *pcm) return pcm->fd >= 0; } +/** Links two PCMs. + * After this function is called, the two PCMs will prepare, start and stop in sync (at the same time). + * If an error occurs, the error message will be written to @p pcm1. + * @param pcm1 A PCM handle. + * @param pcm2 Another PCM handle. + * @return On success, zero; on failure, a negative number. + * @ingroup libtinyalsa-pcm + */ +int pcm_link(struct pcm *pcm1, struct pcm *pcm2) +{ + int err = ioctl(pcm1->fd, SNDRV_PCM_IOCTL_LINK, pcm2->fd); + if (err == -1) { + return oops(pcm1, errno, "cannot link PCM"); + } + return 0; +} + +/** Unlinks a PCM. + * @see @ref pcm_link + * @param pcm A PCM handle. + * @return On success, zero; on failure, a negative number. + * @ingroup libtinyalsa-pcm + */ +int pcm_unlink(struct pcm *pcm) +{ + int err = ioctl(pcm->fd, SNDRV_PCM_IOCTL_UNLINK); + if (err == -1) { + return oops(pcm, errno, "cannot unlink PCM"); + } + return 0; +} + /** Prepares a PCM, if it has not been prepared already. * @param pcm A PCM handle. * @return On success, zero; on failure, a negative number. |