mirror of
https://github.com/openharmony/third_party_tinyalsa.git
synced 2026-07-19 23:33:30 -04:00
pcm: add pcm_start/stop() functions for streams
This is essential for streams such as loopback devices that do not transfer data.
This commit is contained in:
@@ -97,6 +97,10 @@ unsigned int pcm_get_latency(struct pcm *pcm);
|
||||
int pcm_write(struct pcm *pcm, void *data, unsigned int count);
|
||||
int pcm_read(struct pcm *pcm, void *data, unsigned int count);
|
||||
|
||||
/* Start and stop a PCM channel that doesn't transfer data */
|
||||
int pcm_start(struct pcm *pcm);
|
||||
int pcm_stop(struct pcm *pcm);
|
||||
|
||||
|
||||
/*
|
||||
* MIXER API
|
||||
|
||||
@@ -350,3 +350,22 @@ int pcm_is_ready(struct pcm *pcm)
|
||||
{
|
||||
return pcm->fd >= 0;
|
||||
}
|
||||
|
||||
int pcm_start(struct pcm *pcm)
|
||||
{
|
||||
if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_PREPARE) < 0)
|
||||
return oops(pcm, errno, "cannot prepare channel");
|
||||
if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_START) < 0)
|
||||
return oops(pcm, errno, "cannot start channel");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pcm_stop(struct pcm *pcm)
|
||||
{
|
||||
if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_DROP) < 0)
|
||||
return oops(pcm, errno, "cannot stop channel");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user