diff options
| author | ayuanx <ayuanx@gmail.com> | 2009-12-22 07:26:30 +0000 |
|---|---|---|
| committer | ayuanx <ayuanx@gmail.com> | 2009-12-22 07:26:30 +0000 |
| commit | 24d88397938f13d2d55493a0fc2d7032dd2e531e (patch) | |
| tree | 0c6150cd07d4d1535328952177a3ae7169f45155 /Source/Core/AudioCommon | |
| parent | a1fefe870c2566cbc6ede9b4fed8b48417305ba5 (diff) | |
Sound System Rework: Phase 1
. Fixed Sample Rate for DSP
(Now if your CPU is capable to run game at 100%, you will get pure sound without buzz or static noise)
. Fixed Sample Rate for AI
(Now if your CPU is capable to run game at 100%, you will get sync'ed video and audio)
. Fixed Backend list for DSPLLE
. Improved Aduio DMA a bit
(There might be a completely redesign in following phases)
WARNING: The whole rework will take time to complete.
This commit is compilable, but could be unstable.
So you can try it and test it but don't take it as a release rev!
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4717 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/AudioCommon')
| -rw-r--r-- | Source/Core/AudioCommon/Src/AudioCommon.cpp | 30 | ||||
| -rw-r--r-- | Source/Core/AudioCommon/Src/Mixer.cpp | 22 | ||||
| -rw-r--r-- | Source/Core/AudioCommon/Src/Mixer.h | 12 |
3 files changed, 44 insertions, 20 deletions
diff --git a/Source/Core/AudioCommon/Src/AudioCommon.cpp b/Source/Core/AudioCommon/Src/AudioCommon.cpp index 1bea5458ff..4a52615134 100644 --- a/Source/Core/AudioCommon/Src/AudioCommon.cpp +++ b/Source/Core/AudioCommon/Src/AudioCommon.cpp @@ -34,19 +34,19 @@ namespace AudioCommon mixer = new CMixer(); std::string backend = ac_Config.sBackend; - if (backend == BACKEND_COREAUDIO && CoreAudioSound::isValid()) - soundStream = new CoreAudioSound(mixer); - if (backend == BACKEND_DIRECTSOUND && DSound::isValid()) + if (backend == BACKEND_OPENAL && OpenALStream::isValid()) + soundStream = new OpenALStream(mixer); + else if (backend == BACKEND_DIRECTSOUND && DSound::isValid()) soundStream = new DSound(mixer, g_dspInitialize.hWnd); - if (backend == BACKEND_AOSOUND && AOSound::isValid()) + else if (backend == BACKEND_AOSOUND && AOSound::isValid()) soundStream = new AOSound(mixer); - if (backend == BACKEND_OPENAL && OpenALStream::isValid()) - soundStream = new OpenALStream(mixer); - if (backend == BACKEND_ALSA && AlsaSound::isValid()) + else if (backend == BACKEND_ALSA && AlsaSound::isValid()) soundStream = new AlsaSound(mixer); - if (backend == BACKEND_PULSEAUDIO && PulseAudio::isValid()) + else if (backend == BACKEND_COREAUDIO && CoreAudioSound::isValid()) + soundStream = new CoreAudioSound(mixer); + else if (backend == BACKEND_PULSEAUDIO && PulseAudio::isValid()) soundStream = new PulseAudio(mixer); - if (backend == BACKEND_NULL && NullSound::isValid()) + else if (backend == BACKEND_NULL && NullSound::isValid()) soundStream = new NullSound(mixer); if (soundStream != NULL) @@ -60,12 +60,10 @@ namespace AudioCommon soundStream->StartLogAudio(FULL_DUMP_DIR g_Config.recordFile); } */ - 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()); delete soundStream; @@ -77,7 +75,7 @@ namespace AudioCommon void ShutdownSoundStream() { - NOTICE_LOG(DSPHLE, "Shutting down sound stream"); + INFO_LOG(DSPHLE, "Shutting down sound stream"); if (soundStream) { @@ -94,16 +92,16 @@ namespace AudioCommon { std::vector<std::string> backends; - if (CoreAudioSound::isValid()) - backends.push_back(BACKEND_COREAUDIO); if (DSound::isValid()) backends.push_back(BACKEND_DIRECTSOUND); - if (AOSound::isValid()) - backends.push_back(BACKEND_AOSOUND); if (OpenALStream::isValid()) backends.push_back(BACKEND_OPENAL); + if (AOSound::isValid()) + backends.push_back(BACKEND_AOSOUND); if (AlsaSound::isValid()) backends.push_back(BACKEND_ALSA); + if (CoreAudioSound::isValid()) + backends.push_back(BACKEND_COREAUDIO); if (PulseAudio::isValid()) backends.push_back(BACKEND_PULSEAUDIO); if (NullSound::isValid()) diff --git a/Source/Core/AudioCommon/Src/Mixer.cpp b/Source/Core/AudioCommon/Src/Mixer.cpp index d120159e2c..63bc8c7088 100644 --- a/Source/Core/AudioCommon/Src/Mixer.cpp +++ b/Source/Core/AudioCommon/Src/Mixer.cpp @@ -81,9 +81,6 @@ void CMixer::PushSamples(short *samples, int num_stereo_samples, int core_sample sample_queue.push((s16)0); } push_sync.Leave(); - static int PV1l=0,PV2l=0,PV3l=0,PV4l=0; - static int PV1r=0,PV2r=0,PV3r=0,PV4r=0; - static int acc=0; #ifdef _WIN32 if (GetAsyncKeyState(VK_TAB)) @@ -113,6 +110,23 @@ void CMixer::PushSamples(short *samples, int num_stereo_samples, int core_sample // ----------------------------------------------------------------------- push_sync.Enter(); + while (num_stereo_samples) + { + sample_queue.push(Common::swap16(*samples)); + samples++; + sample_queue.push(Common::swap16(*samples)); + samples++; + m_queueSize += 2; + num_stereo_samples--; + } + push_sync.Leave(); + return; + +/* + static int PV1l=0,PV2l=0,PV3l=0,PV4l=0; + static int PV1r=0,PV2r=0,PV3r=0,PV4r=0; + static int acc=0; + while (num_stereo_samples) { acc += core_sample_rate; while (num_stereo_samples && (acc >= 48000)) { @@ -170,6 +184,8 @@ void CMixer::PushSamples(short *samples, int num_stereo_samples, int core_sample m_queueSize += 2; } push_sync.Leave(); +*/ + } int CMixer::GetNumSamples() diff --git a/Source/Core/AudioCommon/Src/Mixer.h b/Source/Core/AudioCommon/Src/Mixer.h index 3c4d66cc76..4fcf1c7d16 100644 --- a/Source/Core/AudioCommon/Src/Mixer.h +++ b/Source/Core/AudioCommon/Src/Mixer.h @@ -29,7 +29,17 @@ class CMixer { public: - CMixer() : m_sampleRate(48000),m_bits(16),m_channels(2), m_mode(2), m_HLEready(false),m_queueSize(0) {} + // AyuanX: Mixer sample rate is fixed to 32khz for now + // if any game sets DSP sample rate to 48khz, we are doomed + // TODO: Fix this somehow! + CMixer(unsigned int SampleRate = 32000) + : m_sampleRate(SampleRate) + , m_bits(16) + , m_channels(2) + , m_mode(2) + , m_HLEready(false) + , m_queueSize(0) + {} // Called from audio threads virtual int Mix(short *sample, int numSamples); |
