From 74901527146fef1de6f26f5e28152cf0f2c59917 Mon Sep 17 00:00:00 2001 From: Nicolas Bacca Date: Mon, 26 Jan 2004 22:38:08 +0000 Subject: Fix Ogg Vorbis, Zak and low sample rate svn-id: r12629 --- backends/wince/wince-sdl.cpp | 74 ++++++++++++++++++++++++++++++++++++++------ backends/wince/wince-sdl.h | 7 +++++ 2 files changed, 71 insertions(+), 10 deletions(-) diff --git a/backends/wince/wince-sdl.cpp b/backends/wince/wince-sdl.cpp index 67574b6868..c79157a338 100644 --- a/backends/wince/wince-sdl.cpp +++ b/backends/wince/wince-sdl.cpp @@ -42,6 +42,9 @@ #include "sound/fmopl.h" +#ifdef USE_VORBIS +#include +#endif using namespace CEGUI; @@ -81,6 +84,7 @@ int SDL_main(int argc, char **argv) { // ******************************************************************************************** void drawError(char *error) { + OutputDebugString(TEXT("Error !\r\n")); } bool isSmartphone(void) { @@ -117,6 +121,9 @@ void OSystem_WINCE3::swap_panel_visibility() { if (!_forcePanelInvisible && !_panelStateForced) { _panelVisible = !_panelVisible; _toolbarHandler.setVisible(_panelVisible); + // FIXME + add_dirty_rect(0, 200, 320, 40); + update_screen(); } } @@ -163,25 +170,59 @@ void OSystem_WINCE3::private_sound_proc(void *param, byte *buf, int len) { memset(buf, 0, len); } -bool OSystem_WINCE3::set_sound_proc(SoundProc proc, void *param, SoundFormat format) { - SDL_AudioSpec desired; - int thread_priority; - - memset(&desired, 0, sizeof(desired)); +#ifdef USE_VORBIS +bool OSystem_WINCE3::checkOggHighSampleRate() { + char trackFile[255]; + FILE *testFile; + OggVorbis_File *test_ov_file = new OggVorbis_File; + + sprintf(trackFile,"%sTrack1.ogg", ConfMan.get("path").c_str()); + // Check if we have an OGG audio track + testFile = fopen(trackFile, "rb"); + if (testFile) { + if (!ov_open(testFile, test_ov_file, NULL, 0)) { + bool highSampleRate = (ov_info(test_ov_file, -1)->rate == 22050); + ov_clear(test_ov_file); + return highSampleRate; + } + } + + // Do not test for OGG samples - too big and too slow anyway :) + + return false; +} +#endif - _originalSoundProc = proc; +void OSystem_WINCE3::get_sample_rate() { // See if the output frequency is forced by the game if ((_gameDetector._game.features & Scumm::GF_DIGI_IMUSE) || _gameDetector._targetName == "queen" || strncmp(_gameDetector._targetName.c_str(), "sword", 5) == 0 || strncmp(_gameDetector._targetName.c_str(), "sky", 3) == 0) - desired.freq = SAMPLES_PER_SEC_NEW; + _sampleRate = SAMPLES_PER_SEC_NEW; else { if (ConfMan.getBool("CE_high_sample_rate")) - desired.freq = SAMPLES_PER_SEC_NEW; + _sampleRate = SAMPLES_PER_SEC_NEW; else - desired.freq = SAMPLES_PER_SEC_OLD; + _sampleRate = SAMPLES_PER_SEC_OLD; } + +#ifdef USE_VORBIS + // Modify the sample rate on the fly if OGG is involved + if (_sampleRate == SAMPLES_PER_SEC_OLD) + if (checkOggHighSampleRate()) + _sampleRate = SAMPLES_PER_SEC_NEW; +#endif +} + +bool OSystem_WINCE3::set_sound_proc(SoundProc proc, void *param, SoundFormat format) { + SDL_AudioSpec desired; + int thread_priority; + + memset(&desired, 0, sizeof(desired)); + + _originalSoundProc = proc; + desired.freq = _sampleRate; desired.format = AUDIO_S16SYS; desired.channels = 2; //desired.samples = 2048; @@ -570,12 +611,17 @@ void OSystem_WINCE3::update_screen() { SDL_Rect dst; uint32 srcPitch, dstPitch; SDL_Rect *last_rect = _dirty_rect_list + _num_dirty_rects; + bool toolbarVisible = _toolbarHandler.visible(); if (_scaler_proc == Normal1x && !_adjustAspectRatio) { SDL_Surface *target = _overlayVisible ? _tmpscreen : _screen; for (r = _dirty_rect_list; r != last_rect; ++r) { dst = *r; - + + // Check if the toolbar is overwritten + if (!_forceFull && toolbarVisible && r->y + r->h >= 200) + _toolbarHandler.forceRedraw(); + if (_overlayVisible) { // FIXME: I don't understand why this is necessary... dst.x--; @@ -607,6 +653,10 @@ void OSystem_WINCE3::update_screen() { register int dst_h = 0; register int orig_dst_y = 0; + // Check if the toolbar is overwritten + if (!_forceFull && toolbarVisible && r->y + r->h >= 200) + _toolbarHandler.forceRedraw(); + if (dst_y < _screenHeight) { dst_h = r->h; if (dst_h > _screenHeight - dst_y) @@ -731,6 +781,10 @@ uint32 OSystem_WINCE3::property(int param, Property *value) { default: return 0; } + } else if (param == PROP_GET_SAMPLE_RATE) { + if (!_sampleRate) + get_sample_rate(); + return _sampleRate; } else if (param == PROP_GET_FMOPL_ENV_BITS) { // imuse FM quality if (ConfMan.getBool("CE_FM_high_quality")) return FMOPL_ENV_BITS_HQ; diff --git a/backends/wince/wince-sdl.h b/backends/wince/wince-sdl.h index 420d017b76..a980394325 100644 --- a/backends/wince/wince-sdl.h +++ b/backends/wince/wince-sdl.h @@ -84,16 +84,23 @@ protected: private: +#ifdef USE_VORBIS + bool checkOggHighSampleRate(); +#endif + static void private_sound_proc(void *param, byte *buf, int len); static SoundProc _originalSoundProc; void create_toolbar(); void update_game_settings(); void update_keyboard(); + void get_sample_rate(); CEKEYS::KeysBuffer *_keysBuffer; CEGUI::ToolbarHandler _toolbarHandler; + uint16 _sampleRate; // current audio sample rate + bool _freeLook; // freeLook mode (do not send mouse button events) bool _forceHideMouse; // force invisible mouse cursor -- cgit v1.2.3