aboutsummaryrefslogtreecommitdiff
path: root/backends/mixer
diff options
context:
space:
mode:
authorMax Horn2010-11-28 14:57:04 +0000
committerMax Horn2010-11-28 14:57:04 +0000
commitf1cdb318c6817e0c63e397f6bdf7524bb02af2d7 (patch)
tree950676b56c4c92802add4cf8c5d7d99aa3e1caed /backends/mixer
parent7760077cf530c35c969f9286145d9a36d0440d70 (diff)
downloadscummvm-rg350-f1cdb318c6817e0c63e397f6bdf7524bb02af2d7.tar.gz
scummvm-rg350-f1cdb318c6817e0c63e397f6bdf7524bb02af2d7.tar.bz2
scummvm-rg350-f1cdb318c6817e0c63e397f6bdf7524bb02af2d7.zip
SYMBIAN: Fixes & improvements for SymbianSdlMixerManager (untested)
svn-id: r54519
Diffstat (limited to 'backends/mixer')
-rw-r--r--backends/mixer/sdl/sdl-mixer.cpp6
-rw-r--r--backends/mixer/sdl/sdl-mixer.h2
-rw-r--r--backends/mixer/symbiansdl/symbiansdl-mixer.cpp46
-rw-r--r--backends/mixer/symbiansdl/symbiansdl-mixer.h6
4 files changed, 17 insertions, 43 deletions
diff --git a/backends/mixer/sdl/sdl-mixer.cpp b/backends/mixer/sdl/sdl-mixer.cpp
index 3c826bfed8..fa2bf3e232 100644
--- a/backends/mixer/sdl/sdl-mixer.cpp
+++ b/backends/mixer/sdl/sdl-mixer.cpp
@@ -58,7 +58,7 @@ void SdlMixerManager::init() {
}
// Get the desired audio specs
- SDL_AudioSpec desired = getAudioSpec();
+ SDL_AudioSpec desired = getAudioSpec(SAMPLES_PER_SEC);
// Start SDL audio with the desired specs
if (SDL_OpenAudio(&desired, &_obtainedRate) != 0) {
@@ -78,7 +78,7 @@ void SdlMixerManager::init() {
}
}
-SDL_AudioSpec SdlMixerManager::getAudioSpec() {
+SDL_AudioSpec SdlMixerManager::getAudioSpec(uint32 outputRate) {
SDL_AudioSpec desired;
// Determine the desired output sampling frequency.
@@ -86,7 +86,7 @@ SDL_AudioSpec SdlMixerManager::getAudioSpec() {
if (ConfMan.hasKey("output_rate"))
samplesPerSec = ConfMan.getInt("output_rate");
if (samplesPerSec <= 0)
- samplesPerSec = SAMPLES_PER_SEC;
+ samplesPerSec = outputRate;
// Determine the sample buffer size. We want it to store enough data for
// at least 1/16th of a second (though at most 8192 samples). Note
diff --git a/backends/mixer/sdl/sdl-mixer.h b/backends/mixer/sdl/sdl-mixer.h
index 1b3a3543dc..ca0cbbf93f 100644
--- a/backends/mixer/sdl/sdl-mixer.h
+++ b/backends/mixer/sdl/sdl-mixer.h
@@ -83,7 +83,7 @@ protected:
/**
* Returns the desired audio specification
*/
- virtual SDL_AudioSpec getAudioSpec();
+ virtual SDL_AudioSpec getAudioSpec(uint32 rate);
/**
* Starts SDL audio
diff --git a/backends/mixer/symbiansdl/symbiansdl-mixer.cpp b/backends/mixer/symbiansdl/symbiansdl-mixer.cpp
index 0cbae85cb9..ef81b464ac 100644
--- a/backends/mixer/symbiansdl/symbiansdl-mixer.cpp
+++ b/backends/mixer/symbiansdl/symbiansdl-mixer.cpp
@@ -36,56 +36,32 @@
SymbianSdlMixerManager::SymbianSdlMixerManager()
:
- _stereo_mix_buffer(0) {
+ _stereoMixBuffer(0) {
}
SymbianSdlMixerManager::~SymbianSdlMixerManager() {
- delete[] _stereo_mix_buffer;
+ delete[] _stereoMixBuffer;
}
-void SymbianSdlMixerManager::init() {
- // Start SDL Audio subsystem
- if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) {
- error("Could not initialize SDL: %s", SDL_GetError());
+void SymbianSdlMixerManager::startAudio() {
+ // Need to create mixbuffer for stereo mix to downmix
+ if (_obtainedRate.channels != 2) {
+ _stereoMixBuffer = new byte [_obtainedRate.size * 2]; // * 2 for stereo values
}
- // Get the desired audio specs
- SDL_AudioSpec desired = getAudioSpec();
-
- // Start SDL audio with the desired specs
- if (SDL_OpenAudio(&desired, &_obtainedRate) != 0) {
- warning("Could not open audio device: %s", SDL_GetError());
-
- _mixer = new Audio::MixerImpl(g_system, desired.freq);
- assert(_mixer);
- _mixer->setReady(false);
- } else {
- debug(1, "Output sample rate: %d Hz", _obtainedRate.freq);
-
- _channels = _obtainedRate.channels;
-
- // Need to create mixbuffer for stereo mix to downmix
- if (_channels != 2) {
- _stereo_mix_buffer = new byte [_obtainedRate.size * 2]; // * 2 for stereo values
- }
-
- _mixer = new Audio::MixerImpl(g_system, _obtainedRate.freq);
- assert(_mixer);
- _mixer->setReady(true);
-
- startAudio();
- }
+ SdlMixerManager::startAudio();
}
void SymbianSdlMixerManager::callbackHandler(byte *samples, int len) {
+ assert(_mixer);
#if defined (S60) && !defined(S60V3)
// If not stereo then we need to downmix
- if (_mixer->_channels != 2) {
- _mixer->mixCallback(_stereo_mix_buffer, len * 2);
+ if (_obtainedRate.channels != 2) {
+ _mixer->mixCallback(_stereoMixBuffer, len * 2);
int16 *bitmixDst = (int16 *)samples;
- int16 *bitmixSrc = (int16 *)_stereo_mix_buffer;
+ int16 *bitmixSrc = (int16 *)_stereoMixBuffer;
for (int loop = len / 2; loop >= 0; loop --) {
*bitmixDst = (*bitmixSrc + *(bitmixSrc + 1)) >> 1;
diff --git a/backends/mixer/symbiansdl/symbiansdl-mixer.h b/backends/mixer/symbiansdl/symbiansdl-mixer.h
index 6a0d281b1a..9164d95ba2 100644
--- a/backends/mixer/symbiansdl/symbiansdl-mixer.h
+++ b/backends/mixer/symbiansdl/symbiansdl-mixer.h
@@ -36,12 +36,10 @@ public:
SymbianSdlMixerManager();
virtual ~SymbianSdlMixerManager();
- virtual void init();
-
protected:
- int _channels;
- byte *_stereo_mix_buffer;
+ byte *_stereoMixBuffer;
+ virtual void startAudio();
virtual void callbackHandler(byte *samples, int len);
};