mirror of
https://projects.vdr-developer.org/git/vdr-plugin-softhddevice.git
synced 2023-10-10 19:16:51 +02:00
Fix audio crash in ThreadExit and snd_pcm_prepare.
This commit is contained in:
parent
f6df79e8e6
commit
5e005eeff5
9
audio.c
9
audio.c
@ -296,6 +296,7 @@ static int AlsaPlayRingbuffer(void)
|
|||||||
if (first) {
|
if (first) {
|
||||||
// happens with broken alsa drivers
|
// happens with broken alsa drivers
|
||||||
Error(_("audio/alsa: broken driver %d\n"), avail);
|
Error(_("audio/alsa: broken driver %d\n"), avail);
|
||||||
|
usleep(5 * 1000);
|
||||||
}
|
}
|
||||||
Debug(4, "audio/alsa: break state %s\n",
|
Debug(4, "audio/alsa: break state %s\n",
|
||||||
snd_pcm_state_name(snd_pcm_state(AlsaPCMHandle)));
|
snd_pcm_state_name(snd_pcm_state(AlsaPCMHandle)));
|
||||||
@ -373,14 +374,20 @@ static int AlsaPlayRingbuffer(void)
|
|||||||
static void AlsaFlushBuffers(void)
|
static void AlsaFlushBuffers(void)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
snd_pcm_state_t state;
|
||||||
|
|
||||||
RingBufferReadAdvance(AlsaRingBuffer, RingBufferUsedBytes(AlsaRingBuffer));
|
RingBufferReadAdvance(AlsaRingBuffer, RingBufferUsedBytes(AlsaRingBuffer));
|
||||||
|
state = snd_pcm_state(AlsaPCMHandle);
|
||||||
|
Debug(3, "audio/alsa: state %d - %s\n", state, snd_pcm_state_name(state));
|
||||||
|
if (state != SND_PCM_STATE_OPEN) {
|
||||||
if ((err = snd_pcm_drop(AlsaPCMHandle)) < 0) {
|
if ((err = snd_pcm_drop(AlsaPCMHandle)) < 0) {
|
||||||
Error(_("audio: snd_pcm_drop(): %s\n"), snd_strerror(err));
|
Error(_("audio: snd_pcm_drop(): %s\n"), snd_strerror(err));
|
||||||
}
|
}
|
||||||
|
// ****ing alsa crash, when in open state here
|
||||||
if ((err = snd_pcm_prepare(AlsaPCMHandle)) < 0) {
|
if ((err = snd_pcm_prepare(AlsaPCMHandle)) < 0) {
|
||||||
Error(_("audio: snd_pcm_prepare(): %s\n"), snd_strerror(err));
|
Error(_("audio: snd_pcm_prepare(): %s\n"), snd_strerror(err));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
AudioPTS = INT64_C(0x8000000000000000);
|
AudioPTS = INT64_C(0x8000000000000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1662,6 +1669,7 @@ static void AudioExitThread(void)
|
|||||||
{
|
{
|
||||||
void *retval;
|
void *retval;
|
||||||
|
|
||||||
|
if (AudioThread) {
|
||||||
if (pthread_cancel(AudioThread)) {
|
if (pthread_cancel(AudioThread)) {
|
||||||
Error(_("audio: can't queue cancel play thread\n"));
|
Error(_("audio: can't queue cancel play thread\n"));
|
||||||
}
|
}
|
||||||
@ -1670,6 +1678,7 @@ static void AudioExitThread(void)
|
|||||||
}
|
}
|
||||||
pthread_cond_destroy(&AudioStartCond);
|
pthread_cond_destroy(&AudioStartCond);
|
||||||
pthread_mutex_destroy(&AudioMutex);
|
pthread_mutex_destroy(&AudioMutex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user