void cancelPcmOutput (PcmDevice *pcm) { int code; if ((code = snd_pcm_playback_drain(pcm->handle)) < 0) { logPcmError(LOG_WARNING, "drain", code); } }
Error AlsaPMO::Reset(bool user_stop) { if (user_stop) snd_pcm_playback_drain(m_handle); else snd_pcm_playback_flush(m_handle); snd_pcm_playback_prepare(m_handle); return kError_NoErr; }
/* stop playing, keep buffers (for pause) */ static void audio_pause(void) { int err; if ((err = snd_pcm_playback_drain(alsa_handler)) < 0) { mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PauseDrainError, snd_strerror(err)); return; } if ((err = snd_pcm_channel_flush(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0) { mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PauseFlushError, snd_strerror(err)); return; } }
static void alsa_release (void *dp) { alsa_driver * const d = dp; free(d->sndbuf); d->sndbuf = NULL; audio_poll_remove(d->polltag); d->polltag = NULL; if(d->soundfd != 0) { snd_pcm_playback_drain(d->soundfd); snd_pcm_close(d->soundfd); d->soundfd = 0; } }
/* stop playing and empty buffers (for seeking/pause) */ static void reset(void) { int err; if ((err = snd_pcm_playback_drain(alsa_handler)) < 0) { mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_ResetDrainError, snd_strerror(err)); return; } if ((err = snd_pcm_channel_flush(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0) { mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_ResetFlushError, snd_strerror(err)); return; } if ((err = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0) { mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_ResetChanPrepareError, snd_strerror(err)); return; } }
/* close audio device */ static void uninit(int immed) { int err; if ((err = snd_pcm_playback_drain(alsa_handler)) < 0) { mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_DrainError, snd_strerror(err)); return; } if ((err = snd_pcm_channel_flush(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0) { mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_FlushError, snd_strerror(err)); return; } if ((err = snd_pcm_close(alsa_handler)) < 0) { mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PcmCloseError, snd_strerror(err)); return; } }