From 5d9871e85e601a1c392691f487f5e383fab66f61 Mon Sep 17 00:00:00 2001 From: nakeee Date: Sat, 28 Mar 2009 23:04:57 +0000 Subject: [PATCH] Fixed Null sound git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2783 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/AudioCommon/Src/DSoundStream.cpp | 5 ----- Source/Core/AudioCommon/Src/Mixer.cpp | 3 --- Source/Core/AudioCommon/Src/Mixer.h | 4 ++-- Source/Core/AudioCommon/Src/NullSoundStream.h | 15 ++++++++++++++- Source/Core/AudioCommon/Src/WaveFile.cpp | 1 + 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Source/Core/AudioCommon/Src/DSoundStream.cpp b/Source/Core/AudioCommon/Src/DSoundStream.cpp index b3ff5941b6..9ed4d592f4 100644 --- a/Source/Core/AudioCommon/Src/DSoundStream.cpp +++ b/Source/Core/AudioCommon/Src/DSoundStream.cpp @@ -21,7 +21,6 @@ #include "../../../PluginSpecs/pluginspecs_dsp.h" -//extern bool log_ai; extern DSPInitialize g_dspInitialize; bool DSound::CreateBuffer() @@ -66,10 +65,6 @@ bool DSound::WriteDataToBuffer(DWORD dwOffset, // Our own write DWORD dwSoundBytes) // Size of block to copy. { // I want to record the regular audio to, how do I do that? - // Well, it's gonna be a bit tricky. For future work :) - //std::string Data = ArrayToString((const u8*)soundData, dwSoundBytes); - //Console::Print("Data: %s\n\n", Data.c_str()); - //if (log_ai) g_wave_writer.AddStereoSamples((const short*)soundData, dwSoundBytes); void *ptr1, *ptr2; DWORD numBytes1, numBytes2; diff --git a/Source/Core/AudioCommon/Src/Mixer.cpp b/Source/Core/AudioCommon/Src/Mixer.cpp index 38ce13dc2c..3247e610a0 100644 --- a/Source/Core/AudioCommon/Src/Mixer.cpp +++ b/Source/Core/AudioCommon/Src/Mixer.cpp @@ -64,9 +64,6 @@ void CMixer::Mix(short *samples, int numSamples) void CMixer::PushSamples(short *samples, int num_stereo_samples, int core_sample_rate) { - if (!soundStream) - return; - push_sync.Enter(); if (m_queueSize == 0) { diff --git a/Source/Core/AudioCommon/Src/Mixer.h b/Source/Core/AudioCommon/Src/Mixer.h index 41dd544585..3d9c2cc31a 100644 --- a/Source/Core/AudioCommon/Src/Mixer.h +++ b/Source/Core/AudioCommon/Src/Mixer.h @@ -31,10 +31,10 @@ public: CMixer() : m_sampleRate(48000),m_bits(16),m_channels(2), m_mode(2), m_HLEready(false),m_queueSize(0) {} // Called from audio threads - void Mix(short *sample, int numSamples); + virtual void Mix(short *sample, int numSamples); // Called from main thread - void PushSamples(short* samples, int num_stereo_samples, int core_sample_rate); + virtual void PushSamples(short* samples, int num_stereo_samples, int core_sample_rate); virtual void Premix(short *samples, int numSamples) {} diff --git a/Source/Core/AudioCommon/Src/NullSoundStream.h b/Source/Core/AudioCommon/Src/NullSoundStream.h index b8a9807725..76f62b9f2f 100644 --- a/Source/Core/AudioCommon/Src/NullSoundStream.h +++ b/Source/Core/AudioCommon/Src/NullSoundStream.h @@ -19,11 +19,24 @@ #define _NULLSOUNDSTREAM_H_ #include "SoundStream.h" +#include "Mixer.h" + +class NullMixer : public CMixer { +public: + virtual void Mix(short *sample, int numSamples) {} + virtual void PushSamples(short* samples, int num_stereo_samples, + int core_sample_rate) {} +}; class NullSound : public SoundStream { public: - NullSound(CMixer *mixer) : SoundStream(mixer) {} + NullSound(CMixer *mixer) : SoundStream(mixer) + { + delete m_mixer; + m_mixer = new NullMixer(); + + } virtual ~NullSound() {} diff --git a/Source/Core/AudioCommon/Src/WaveFile.cpp b/Source/Core/AudioCommon/Src/WaveFile.cpp index 94653300de..d5d96371cd 100644 --- a/Source/Core/AudioCommon/Src/WaveFile.cpp +++ b/Source/Core/AudioCommon/Src/WaveFile.cpp @@ -22,6 +22,7 @@ enum {BUF_SIZE = 32*1024}; WaveFileWriter::WaveFileWriter() { + file = NULL; conv_buffer = 0; skip_silence = false; }