diff options
| author | omegadox <omegadox@gmail.com> | 2009-03-29 00:48:46 +0000 |
|---|---|---|
| committer | omegadox <omegadox@gmail.com> | 2009-03-29 00:48:46 +0000 |
| commit | 2a5866d5f114a32c799dc8c26bb9c02eed82c61c (patch) | |
| tree | 159d17ffd681c19dd175e0142934e1a36c01daad /Source/Core/AudioCommon/Src/AudioCommon.cpp | |
| parent | 5d9871e85e601a1c392691f487f5e383fab66f61 (diff) | |
AudioCommon.cpp cleanup
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2784 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/AudioCommon/Src/AudioCommon.cpp')
| -rw-r--r-- | Source/Core/AudioCommon/Src/AudioCommon.cpp | 117 |
1 files changed, 49 insertions, 68 deletions
diff --git a/Source/Core/AudioCommon/Src/AudioCommon.cpp b/Source/Core/AudioCommon/Src/AudioCommon.cpp index fae1a405e0..227035a817 100644 --- a/Source/Core/AudioCommon/Src/AudioCommon.cpp +++ b/Source/Core/AudioCommon/Src/AudioCommon.cpp @@ -17,88 +17,69 @@ #include "AudioCommon.h"
#include "Mixer.h"
-#include "AOSoundStream.h"
#include "DSoundStream.h"
+#include "AOSoundStream.h"
#include "NullSoundStream.h"
#include "OpenALStream.h"
namespace AudioCommon
{
-SoundStream *InitSoundStream(std::string backend, CMixer *mixer) {
+ SoundStream *InitSoundStream(std::string backend, CMixer *mixer)
+ {
+ if (!mixer)
+ mixer = new CMixer();
- if (!mixer) {
- mixer = new CMixer();
- }
+ if (backend == BACKEND_DIRECTSOUND && DSound::isValid()) soundStream = new DSound(mixer, g_dspInitialize.hWnd);
+ if (backend == BACKEND_AOSOUND && AOSound::isValid()) soundStream = new AOSound(mixer);
+ if (backend == BACKEND_OPENAL && OpenALStream::isValid()) soundStream = new OpenALStream(mixer);
+ if (backend == BACKEND_NULL && NullSound::isValid()) soundStream = new NullSound(mixer);
+
+ if (soundStream != NULL) {
+ if (soundStream->Start())
+ return soundStream;
+ PanicAlert("Could not initialize backend %s, falling back to NULL", backend.c_str());
+ }
+
+ PanicAlert("Sound backend %s is not valid, falling back to NULL", backend.c_str());
- if (backend == "DSound") {
- if (DSound::isValid())
- soundStream = new DSound(mixer, g_dspInitialize.hWnd);
- }
- else if (backend == "AOSound") {
- if (AOSound::isValid())
- soundStream = new AOSound(mixer);
- }
- else if (backend == "OpenAL") {
- if (OpenALStream::isValid())
- soundStream = new OpenALStream(mixer);
- }
- else if (backend == "NullSound") {
- soundStream = new NullSound(mixer);
- }
- else {
- PanicAlert("Cannot recognize backend %s", backend.c_str());
- return NULL;
- }
-
- if (soundStream) {
- if (!soundStream->Start()) {
- PanicAlert("Could not initialize backend %s, falling back to NULL",
- backend.c_str());
- delete soundStream;
- soundStream = new NullSound(mixer);
- soundStream->Start();
- }
- }
- else {
- PanicAlert("Sound backend %s is not valid, falling back to NULL",
- backend.c_str());
delete soundStream;
soundStream = new NullSound(mixer);
soundStream->Start();
+
+ return NULL;
}
- return soundStream;
-}
-void ShutdownSoundStream() {
- NOTICE_LOG(DSPHLE, "Shutting down sound stream");
+ void ShutdownSoundStream()
+ {
+ NOTICE_LOG(DSPHLE, "Shutting down sound stream");
- if (soundStream) {
- soundStream->Stop();
- soundStream->StopLogAudio();
- delete soundStream;
- soundStream = NULL;
- }
-
- // Check that soundstream already is stopped.
- while (soundStream) {
- ERROR_LOG(DSPHLE, "Waiting for sound stream");
- Common::SleepCurrentThread(2000);
+ if (soundStream)
+ {
+ soundStream->Stop();
+ soundStream->StopLogAudio();
+ delete soundStream;
+ soundStream = NULL;
+ }
+
+ // Check that soundstream already is stopped.
+ while (soundStream)
+ {
+ ERROR_LOG(DSPHLE, "Waiting for sound stream");
+ Common::SleepCurrentThread(2000);
+ }
+
+ INFO_LOG(DSPHLE, "Done shutting down sound stream");
}
- INFO_LOG(DSPHLE, "Done shutting down sound stream");
-}
-std::vector<std::string> GetSoundBackends() {
- std::vector<std::string> backends;
- // Add avaliable output options
- if (DSound::isValid())
- backends.push_back("DSound");
- if (AOSound::isValid())
- backends.push_back("AOSound");
- if (OpenALStream::isValid())
- backends.push_back("OpenAL");
- backends.push_back("NullSound");
-
- return backends;
-}
+ std::vector<std::string> GetSoundBackends()
+ {
+ std::vector<std::string> backends;
-} // Namespace
+ if (DSound::isValid()) backends.push_back(BACKEND_DIRECTSOUND);
+ if (DSound::isValid()) backends.push_back(BACKEND_AOSOUND);
+ if (DSound::isValid()) backends.push_back(BACKEND_OPENAL);
+ if (DSound::isValid()) backends.push_back(BACKEND_NULL);
+
+ return backends;
+ }
+}
|
