From 2362c376a47bc7ae693c0cd868f6bab03bb718df Mon Sep 17 00:00:00 2001 From: avolkov Date: Sat, 24 Oct 2009 05:37:41 +0000 Subject: [PATCH] Scope fixes: 0-init scope data; do not put critical calls into an assert() ;-) git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3236 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/libs/sound/stream.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sc2/src/libs/sound/stream.c b/sc2/src/libs/sound/stream.c index 98c2caee6..cabe24a07 100644 --- a/sc2/src/libs/sound/stream.c +++ b/sc2/src/libs/sound/stream.c @@ -64,7 +64,7 @@ PlayStream (TFB_SoundSample *sample, uint32 source, bool looping, bool scope, // realloc it a zillion times soundSource[source].sbuf_size = sample->num_buffers * decoder->buffer_size + PAD_SCOPE_BYTES; - soundSource[source].sbuffer = HMalloc (soundSource[source].sbuf_size); + soundSource[source].sbuffer = HCalloc (soundSource[source].sbuf_size); } for (i = 0; i < sample->num_buffers; ++i) @@ -616,7 +616,13 @@ GraphForegroundStream (uint8 *data, sint32 width, sint32 height) } decoder = source->sample->decoder; - assert (audio_GetFormatInfo (decoder->format, &channels, &sample_size)); + if (!audio_GetFormatInfo (decoder->format, &channels, &sample_size)) + { + UnlockMutex (source->stream_mutex); + log_add (log_Debug, "GraphForegroundStream(): uknown format %u", + (unsigned)decoder->format); + return 0; + } full_sample = channels * sample_size; // See how far into the buffer we should be now