aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Bacca2002-03-15 02:23:44 +0000
committerNicolas Bacca2002-03-15 02:23:44 +0000
commit829bad142c2757a7025c292055bd769dd87f2995 (patch)
tree1c85feb1ebe83c219d5a57bc846b6dd747c8e016
parent7a4121a61a13f59ac9f4cc7bc0b2f909d845f33f (diff)
downloadscummvm-rg350-829bad142c2757a7025c292055bd769dd87f2995.tar.gz
scummvm-rg350-829bad142c2757a7025c292055bd769dd87f2995.tar.bz2
scummvm-rg350-829bad142c2757a7025c292055bd769dd87f2995.zip
Make mp3 sound work (pretty good btw) with WinCE
svn-id: r3761
-rw-r--r--sound.cpp16
-rw-r--r--wince/missing/missing.cpp9
2 files changed, 23 insertions, 2 deletions
diff --git a/sound.cpp b/sound.cpp
index bfdc16750b..104af5bfce 100644
--- a/sound.cpp
+++ b/sound.cpp
@@ -23,6 +23,11 @@
#include "scumm.h"
#include "sound.h"
+#ifdef _WIN32_WCE
+extern void *bsearch(const void *, const void *, size_t,
+ size_t, int (*x)(const void *, const void *));
+#endif
+
void Scumm::addSoundToQueue(int sound) {
if(!(_features & GF_AFTER_V7)) {
_vars[VAR_LAST_SOUND] = sound;
@@ -161,10 +166,11 @@ void Scumm::startTalkSound(uint32 offset, uint32 b, int mode) {
#ifdef COMPRESSED_SOUND_FILE
if (offset_table != NULL) {
- OffsetTable *result, key;
+ OffsetTable *result = NULL, key;
key.org_offset = offset;
result = (OffsetTable *) bsearch(&key, offset_table, num_sound_effects, sizeof(OffsetTable), compar);
+
if (result == NULL) {
warning("startTalkSound: did not find sound at offset %d !", offset);
return;
@@ -358,7 +364,7 @@ void Scumm::startSfxSound(void *file, int file_size) {
char ident[8];
int block_type;
byte work[8];
- uint size,i;
+ uint size = 0,i;
int rate,comp;
byte *data;
@@ -543,6 +549,12 @@ void Scumm::playSfxSound_MP3(void *sound, uint32 size) {
mc->_sfx_sound = sound;
mad_stream_init(&mc->sound_data.mp3.stream);
+
+#ifdef _WIN32_WCE
+ // 11 kHz on WinCE
+ mad_stream_options((mad_stream*)&mc->sound_data.mp3.stream, MAD_OPTION_HALFSAMPLERATE);
+#endif
+
mad_frame_init(&mc->sound_data.mp3.frame);
mad_synth_init(&mc->sound_data.mp3.synth);
mc->sound_data.mp3.position = 0;
diff --git a/wince/missing/missing.cpp b/wince/missing/missing.cpp
index d139584f54..5adabda22a 100644
--- a/wince/missing/missing.cpp
+++ b/wince/missing/missing.cpp
@@ -366,3 +366,12 @@ char* getenv(char* name)
return "";
}
+void *bsearch(const void *key, const void *base, size_t nmemb,
+ size_t size, int (*compar)(const void *, const void *)) {
+ size_t i;
+
+ for (i=0; i<nmemb; i++)
+ if (compar(key, (void*)((size_t)base + size * i)) == 0)
+ return (void*)((size_t)base + size * i);
+ return NULL;
+}