Skip to content

Commit

Permalink
Merge pull request #1187 from lioncash/global
Browse files Browse the repository at this point in the history
AudioCommon: Prefix soundStream global with g_
  • Loading branch information
skidau committed Oct 1, 2014
2 parents 19fbefd + 7f7fb5e commit ffe160a
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 43 deletions.
64 changes: 32 additions & 32 deletions Source/Core/AudioCommon/AudioCommon.cpp
Expand Up @@ -21,7 +21,7 @@
#include "Core/Movie.h"

// This shouldn't be a global, at least not here.
SoundStream *soundStream = nullptr;
SoundStream* g_sound_stream = nullptr;

namespace AudioCommon
{
Expand All @@ -33,38 +33,38 @@ namespace AudioCommon

std::string backend = SConfig::GetInstance().sBackend;
if (backend == BACKEND_OPENAL && OpenALStream::isValid())
soundStream = new OpenALStream(mixer);
g_sound_stream = new OpenALStream(mixer);
else if (backend == BACKEND_NULLSOUND && NullSound::isValid())
soundStream = new NullSound(mixer);
g_sound_stream = new NullSound(mixer);
else if (backend == BACKEND_XAUDIO2)
{
if (XAudio2::isValid())
soundStream = new XAudio2(mixer);
g_sound_stream = new XAudio2(mixer);
else if (XAudio2_7::isValid())
soundStream = new XAudio2_7(mixer);
g_sound_stream = new XAudio2_7(mixer);
}
else if (backend == BACKEND_AOSOUND && AOSound::isValid())
soundStream = new AOSound(mixer);
g_sound_stream = new AOSound(mixer);
else if (backend == BACKEND_ALSA && AlsaSound::isValid())
soundStream = new AlsaSound(mixer);
g_sound_stream = new AlsaSound(mixer);
else if (backend == BACKEND_COREAUDIO && CoreAudioSound::isValid())
soundStream = new CoreAudioSound(mixer);
g_sound_stream = new CoreAudioSound(mixer);
else if (backend == BACKEND_PULSEAUDIO && PulseAudio::isValid())
soundStream = new PulseAudio(mixer);
g_sound_stream = new PulseAudio(mixer);
else if (backend == BACKEND_OPENSLES && OpenSLESStream::isValid())
soundStream = new OpenSLESStream(mixer);
g_sound_stream = new OpenSLESStream(mixer);

if (!soundStream && NullSound::isValid())
if (!g_sound_stream && NullSound::isValid())
{
WARN_LOG(DSPHLE, "Could not initialize backend %s, using %s instead.",
backend.c_str(), BACKEND_NULLSOUND);
soundStream = new NullSound(mixer);
g_sound_stream = new NullSound(mixer);
}

if (soundStream)
if (g_sound_stream)
{
UpdateSoundStream();
if (soundStream->Start())
if (g_sound_stream->Start())
{
if (SConfig::GetInstance().m_DumpAudio)
{
Expand All @@ -73,30 +73,30 @@ namespace AudioCommon
mixer->StartLogAudio(audio_file_name);
}

return soundStream;
return g_sound_stream;
}
PanicAlertT("Could not initialize backend %s.", backend.c_str());
}

PanicAlertT("Sound backend %s is not valid.", backend.c_str());

delete soundStream;
soundStream = nullptr;
delete g_sound_stream;
g_sound_stream = nullptr;
return nullptr;
}

void ShutdownSoundStream()
{
INFO_LOG(DSPHLE, "Shutting down sound stream");

if (soundStream)
if (g_sound_stream)
{
soundStream->Stop();
g_sound_stream->Stop();
if (SConfig::GetInstance().m_DumpAudio)
soundStream->GetMixer()->StopLogAudio();
//soundStream->StopLogAudio();
delete soundStream;
soundStream = nullptr;
g_sound_stream->GetMixer()->StopLogAudio();
//g_sound_stream->StopLogAudio();
delete g_sound_stream;
g_sound_stream = nullptr;
}

INFO_LOG(DSPHLE, "Done shutting down sound stream");
Expand Down Expand Up @@ -127,12 +127,12 @@ namespace AudioCommon

void PauseAndLock(bool doLock, bool unpauseOnUnlock)
{
if (soundStream)
if (g_sound_stream)
{
// audio typically doesn't maintain its own "paused" state
// (that's already handled by the CPU and whatever else being paused)
// so it should be good enough to only lock/unlock here.
CMixer* pMixer = soundStream->GetMixer();
CMixer* pMixer = g_sound_stream->GetMixer();
if (pMixer)
{
std::mutex& csMixing = pMixer->MixerCritical();
Expand All @@ -145,30 +145,30 @@ namespace AudioCommon
}
void UpdateSoundStream()
{
if (soundStream)
if (g_sound_stream)
{
soundStream->SetVolume(SConfig::GetInstance().m_Volume);
g_sound_stream->SetVolume(SConfig::GetInstance().m_Volume);
}
}

void ClearAudioBuffer(bool mute)
{
if (soundStream)
soundStream->Clear(mute);
if (g_sound_stream)
g_sound_stream->Clear(mute);
}

void SendAIBuffer(short *samples, unsigned int num_samples)
{
if (!soundStream)
if (!g_sound_stream)
return;

CMixer* pMixer = soundStream->GetMixer();
CMixer* pMixer = g_sound_stream->GetMixer();

if (pMixer && samples)
{
pMixer->PushSamples(samples, num_samples);
}

soundStream->Update();
g_sound_stream->Update();
}
}
2 changes: 1 addition & 1 deletion Source/Core/AudioCommon/AudioCommon.h
Expand Up @@ -10,7 +10,7 @@

class CMixer;

extern SoundStream *soundStream;
extern SoundStream *g_sound_stream;

namespace AudioCommon
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/Core.cpp
Expand Up @@ -690,9 +690,9 @@ void UpdateTitle()
std::string SMessage = StringFromFormat("%s | %s", SSettings.c_str(), SFPS.c_str());

// Update the audio timestretcher with the current speed
if (soundStream)
if (g_sound_stream)
{
CMixer* pMixer = soundStream->GetMixer();
CMixer* pMixer = g_sound_stream->GetMixer();
pMixer->UpdateSpeed((float)Speed / 100);
}

Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/HW/AudioInterface.cpp
Expand Up @@ -197,7 +197,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
DEBUG_LOG(AUDIO_INTERFACE, "Change AISFR to %s", tmpAICtrl.AISFR ? "48khz":"32khz");
m_Control.AISFR = tmpAICtrl.AISFR;
g_AISSampleRate = tmpAICtrl.AISFR ? 48000 : 32000;
soundStream->GetMixer()->SetStreamInputSampleRate(g_AISSampleRate);
g_sound_stream->GetMixer()->SetStreamInputSampleRate(g_AISSampleRate);
g_CPUCyclesPerSample = SystemTimers::GetTicksPerSecond() / g_AISSampleRate;
}
// Set frequency of DMA
Expand All @@ -206,7 +206,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
DEBUG_LOG(AUDIO_INTERFACE, "Change AIDFR to %s", tmpAICtrl.AIDFR ? "32khz":"48khz");
m_Control.AIDFR = tmpAICtrl.AIDFR;
g_AIDSampleRate = tmpAICtrl.AIDFR ? 32000 : 48000;
soundStream->GetMixer()->SetDMAInputSampleRate(g_AIDSampleRate);
g_sound_stream->GetMixer()->SetDMAInputSampleRate(g_AIDSampleRate);
}


Expand Down Expand Up @@ -245,7 +245,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
MMIO::DirectRead<u32>(&m_Volume.hex),
MMIO::ComplexWrite<u32>([](u32, u32 val) {
m_Volume.hex = val;
soundStream->GetMixer()->SetStreamingVolume(m_Volume.left, m_Volume.right);
g_sound_stream->GetMixer()->SetStreamingVolume(m_Volume.left, m_Volume.right);
})
);

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/DVDInterface.cpp
Expand Up @@ -320,7 +320,7 @@ static void DTKStreamingCallback(u64 userdata, int cyclesLate)
memset(tempPCM, 0, sizeof(tempPCM));
samples_processed = NUM_SAMPLES;
}
soundStream->GetMixer()->PushStreamingSamples(tempPCM, samples_processed);
g_sound_stream->GetMixer()->PushStreamingSamples(tempPCM, samples_processed);

int ticks_to_dtk = int(SystemTimers::GetTicksPerSecond() * u64(samples_processed) / 48000);
CoreTiming::ScheduleEvent(ticks_to_dtk - cyclesLate, dtk);
Expand Down
8 changes: 4 additions & 4 deletions Source/Core/Core/HW/WiimoteEmu/Speaker.cpp
Expand Up @@ -81,9 +81,9 @@ void Wiimote::SpeakerData(wm_speaker_data* sd)

// Speaker Pan
unsigned int vol = (unsigned int)(m_options->settings[4]->GetValue() * 100);
soundStream->GetMixer()->SetWiimoteSpeakerVolume(128 + vol, 128 - vol);
g_sound_stream->GetMixer()->SetWiimoteSpeakerVolume(128 + vol, 128 - vol);

soundStream->GetMixer()->PushWiimoteSpeakerSamples(samples, sd->length, 1500);
g_sound_stream->GetMixer()->PushWiimoteSpeakerSamples(samples, sd->length, 1500);
}
else if (m_reg_speaker.format == 0x00)
{
Expand All @@ -96,9 +96,9 @@ void Wiimote::SpeakerData(wm_speaker_data* sd)

// Speaker Pan
unsigned int vol = (unsigned int)(m_options->settings[4]->GetValue() * 100);
soundStream->GetMixer()->SetWiimoteSpeakerVolume(128 + vol, 128 - vol);
g_sound_stream->GetMixer()->SetWiimoteSpeakerVolume(128 + vol, 128 - vol);

soundStream->GetMixer()->PushWiimoteSpeakerSamples(samples, sd->length, 3000);
g_sound_stream->GetMixer()->PushWiimoteSpeakerSamples(samples, sd->length, 3000);
}

#ifdef WIIMOTE_SPEAKER_DUMP
Expand Down

0 comments on commit ffe160a

Please sign in to comment.