Fix bug: snd_pcm_state: Assertion `pcm' failed.

This commit is contained in:
Johns 2012-01-13 19:33:59 +01:00
parent 81d7ef9755
commit baf577aba5
2 changed files with 13 additions and 27 deletions

2
Todo
View File

@ -60,7 +60,7 @@ audio/alsa:
done? video/audio asyncron done? video/audio asyncron
random crashes in av_parser_parse2, when switching channels random crashes in av_parser_parse2, when switching channels
sometimes alsa hangs sometimes alsa hangs
snd_pcm_state: Assertion `pcm' failed. while switching channels fixed? snd_pcm_state: Assertion `pcm' failed. while switching channels
(thread problem) (thread problem)
better downmix of >2 channels on 2 channel hardware better downmix of >2 channels on 2 channel hardware

38
audio.c
View File

@ -856,23 +856,9 @@ static int AlsaSetup(int *freq, int *channels)
if (!AlsaPCMHandle) { // alsa not running yet if (!AlsaPCMHandle) { // alsa not running yet
return -1; return -1;
} }
#if 1 #if 1 // easy alsa hw setup way
// flush any buffered data // flush any buffered data
#ifndef SEARCH_HDMI_BUG2 AudioFlushBuffers();
#ifdef USE_AUDIO_THREAD
if (AudioRunning) {
while (AudioRunning) {
AlsaFlushBuffer = 1;
usleep(1 * 1000);
}
AlsaFlushBuffer = 0;
} else
#endif
{
AlsaFlushBuffers();
}
#endif
AudioPTS = INT64_C(0x8000000000000000);
if (1) { // close+open to fix hdmi no sound bugs if (1) { // close+open to fix hdmi no sound bugs
handle = AlsaPCMHandle; handle = AlsaPCMHandle;
@ -1449,7 +1435,6 @@ static int OssSetup(int *freq, int *channels)
AudioRunning = 0; AudioRunning = 0;
OssFlushBuffers(); OssFlushBuffers();
} }
AudioPTS = INT64_C(0x8000000000000000);
ret = 0; ret = 0;
@ -1711,17 +1696,18 @@ void AudioFlushBuffers(void)
{ {
#ifdef USE_ALSA #ifdef USE_ALSA
#ifdef USE_AUDIO_THREAD #ifdef USE_AUDIO_THREAD
if (AudioRunning) { // signal thread to flush buffers
while (AudioRunning) { if (AudioThread) {
AlsaFlushBuffer = 1; AlsaFlushBuffer = 1;
do {
AudioRunning = 1; // wakeup in case of sleeping
pthread_cond_signal(&AudioStartCond);
usleep(1 * 1000); usleep(1 * 1000);
} } while (AlsaFlushBuffer); // wait until flushed
AlsaFlushBuffer = 0;
} else
#endif
{
AlsaFlushBuffers();
} }
#else
AlsaFlushBuffers();
#endif
#endif #endif
#ifdef USE_OSS #ifdef USE_OSS
OssFlushBuffers(); OssFlushBuffers();