]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Add snd_pcm_ioplug_set_state() function
authorTakashi Iwai <tiwai@suse.de>
Fri, 14 Dec 2007 14:19:03 +0000 (15:19 +0100)
committerTakashi Iwai <tiwai@suse.de>
Fri, 14 Dec 2007 14:19:03 +0000 (15:19 +0100)
Added an exported function snd_pcm_ioplug_set_state() to change
the PCM state of ioplug from the plugin side (e.g. from another
thread).

include/pcm_ioplug.h
src/pcm/pcm_ioplug.c

index f8a23f693bc6a5c291749354699978e225a4cec5..f740a1973d2624cf4ac7861f9f17b10f9c7c0df0 100644 (file)
@@ -208,6 +208,9 @@ void snd_pcm_ioplug_params_reset(snd_pcm_ioplug_t *io);
 int snd_pcm_ioplug_set_param_minmax(snd_pcm_ioplug_t *io, int type, unsigned int min, unsigned int max);
 int snd_pcm_ioplug_set_param_list(snd_pcm_ioplug_t *io, int type, unsigned int num_list, const unsigned int *list);
 
+/* change PCM status */
+int snd_pcm_ioplug_set_state(snd_pcm_ioplug_t *ioplug, snd_pcm_state_t state);
+
 /** \} */
 
 #endif /* __ALSA_PCM_IOPLUG_H */
index 19dab979d6dda6b55f6ee16c6ee3c18ae1b7bb39..7bf19ca1f73365e8d0e49fde0ed5513e47bb0bf3 100644 (file)
@@ -614,6 +614,8 @@ static snd_pcm_sframes_t snd_pcm_ioplug_avail_update(snd_pcm_t *pcm)
        snd_pcm_uframes_t avail;
 
        snd_pcm_ioplug_hw_ptr_update(pcm);
+       if (io->data->state == SNDRV_PCM_STATE_XRUN)
+               return -EPIPE;
        if (pcm->stream == SND_PCM_STREAM_CAPTURE &&
            pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED &&
            pcm->access != SND_PCM_ACCESS_RW_NONINTERLEAVED) {
@@ -1037,3 +1039,19 @@ const snd_pcm_channel_area_t *snd_pcm_ioplug_mmap_areas(snd_pcm_ioplug_t *ioplug
                return snd_pcm_mmap_areas(ioplug->pcm);
        return NULL;
 }
+
+/**
+ * \brief Change the ioplug PCM status
+ * \param ioplug the ioplug handle
+ * \param state the PCM status
+ * \return zero if successful or a negative error code
+ *
+ * Changes the PCM status of the ioplug to the given value.
+ * This function can be used for external plugins to notify the status
+ * change, e.g. XRUN.
+ */
+int snd_pcm_ioplug_set_state(snd_pcm_ioplug_t *ioplug, snd_pcm_state_t state)
+{
+       ioplug->state = state;
+       return 0;
+}