Fix bug: AudioEnqueue crash without sound card.

This commit is contained in:
Johns 2012-03-05 15:06:46 +01:00
parent da5c5cd5fd
commit 3812fa8d38
2 changed files with 13 additions and 3 deletions

View File

@ -1,3 +1,8 @@
User johns
Date:
Fix bug: AudioEnqueue crash without sound card.
User johns User johns
Date: Sun Mar 4 22:35:36 CET 2012 Date: Sun Mar 4 22:35:36 CET 2012

11
audio.c
View File

@ -701,7 +701,7 @@ static void AlsaThread(void)
*/ */
static void AlsaThreadEnqueue(const void *samples, int count) static void AlsaThreadEnqueue(const void *samples, int count)
{ {
if (!AlsaRingBuffer || !AlsaPCMHandle || !AudioSampleRate) { if (!AlsaRingBuffer || !AlsaPCMHandle) {
Debug(3, "audio/alsa: enqueue not ready\n"); Debug(3, "audio/alsa: enqueue not ready\n");
return; return;
} }
@ -1552,7 +1552,7 @@ static void OssThread(void)
*/ */
static void OssThreadEnqueue(const void *samples, int count) static void OssThreadEnqueue(const void *samples, int count)
{ {
if (!OssRingBuffer || OssPcmFildes == -1 || !AudioSampleRate) { if (!OssRingBuffer || OssPcmFildes == -1) {
Debug(3, "audio/oss: enqueue not ready\n"); Debug(3, "audio/oss: enqueue not ready\n");
return; return;
} }
@ -2080,7 +2080,9 @@ static void *AudioPlayHandlerThread(void *dummy)
} while (!AudioRunning); } while (!AudioRunning);
Debug(3, "audio: ----> %d ms\n", (AudioUsedBytes() * 1000) Debug(3, "audio: ----> %d ms\n", (AudioUsedBytes() * 1000)
/ (AudioSampleRate * AudioChannels * AudioBytesProSample)); / (!AudioSampleRate
|| !AudioChannels +
AudioSampleRate * AudioChannels * AudioBytesProSample));
pthread_mutex_unlock(&AudioMutex); pthread_mutex_unlock(&AudioMutex);
@ -2182,6 +2184,9 @@ static const AudioModule *AudioModules[] = {
*/ */
void AudioEnqueue(const void *samples, int count) void AudioEnqueue(const void *samples, int count)
{ {
if (!AudioSampleRate || !AudioChannels) {
return; // not setup
}
if (0) { if (0) {
static uint32_t last; static uint32_t last;
static uint32_t tick; static uint32_t tick;