mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
AudioCommon: Migrate threadData to OpenALStream and AOSoundStream
This is only ever used in these two sound streams. Seems silly to have it as a class member. Converted it to an atomic as well.
This commit is contained in:
parent
78e59d08fe
commit
4920dbed13
@ -32,7 +32,7 @@ void AOSound::SoundLoop()
|
||||
|
||||
buf_size = format.bits/8 * format.channels * format.rate;
|
||||
|
||||
while (!threadData)
|
||||
while (m_run_thread.load())
|
||||
{
|
||||
m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);
|
||||
|
||||
@ -47,6 +47,7 @@ void AOSound::SoundLoop()
|
||||
|
||||
bool AOSound::Start()
|
||||
{
|
||||
m_run_thread.store(true);
|
||||
memset(realtimeBuffer, 0, sizeof(realtimeBuffer));
|
||||
|
||||
thread = std::thread(&AOSound::SoundLoop, this);
|
||||
@ -60,7 +61,7 @@ void AOSound::Update()
|
||||
|
||||
void AOSound::Stop()
|
||||
{
|
||||
threadData = 1;
|
||||
m_run_thread.store(false);
|
||||
soundSyncEvent.Set();
|
||||
|
||||
{
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
@ -19,6 +20,7 @@ class AOSound final : public SoundStream
|
||||
{
|
||||
#if defined(HAVE_AO) && HAVE_AO
|
||||
std::thread thread;
|
||||
std::atomic<bool> m_run_thread;
|
||||
std::mutex soundCriticalSection;
|
||||
Common::Event soundSyncEvent;
|
||||
|
||||
|
@ -23,6 +23,7 @@ static soundtouch::SoundTouch soundTouch;
|
||||
//
|
||||
bool OpenALStream::Start()
|
||||
{
|
||||
m_run_thread.store(true);
|
||||
bool bReturn = false;
|
||||
|
||||
ALDeviceList pDeviceList;
|
||||
@ -72,7 +73,7 @@ bool OpenALStream::Start()
|
||||
|
||||
void OpenALStream::Stop()
|
||||
{
|
||||
threadData = 1;
|
||||
m_run_thread.store(false);
|
||||
// kick the thread if it's waiting
|
||||
soundSyncEvent.Set();
|
||||
|
||||
@ -183,7 +184,7 @@ void OpenALStream::SoundLoop()
|
||||
soundTouch.setSetting(SETTING_SEEKWINDOW_MS, 28);
|
||||
soundTouch.setSetting(SETTING_OVERLAP_MS, 12);
|
||||
|
||||
while (!threadData)
|
||||
while (m_run_thread.load())
|
||||
{
|
||||
// num_samples_to_render in this update - depends on SystemTimers::AUDIO_DMA_PERIOD.
|
||||
const u32 stereo_16_bit_size = 4;
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
|
||||
#include "AudioCommon/SoundStream.h"
|
||||
@ -72,6 +73,8 @@ public:
|
||||
|
||||
private:
|
||||
std::thread thread;
|
||||
std::atomic<bool> m_run_thread;
|
||||
|
||||
Common::Event soundSyncEvent;
|
||||
|
||||
short realtimeBuffer[OAL_MAX_SAMPLES * STEREO_CHANNELS];
|
||||
|
@ -11,17 +11,13 @@
|
||||
class SoundStream
|
||||
{
|
||||
protected:
|
||||
|
||||
CMixer* m_mixer;
|
||||
// We set this to shut down the sound thread.
|
||||
// 0=keep playing, 1=stop playing NOW.
|
||||
volatile int threadData;
|
||||
bool m_logAudio;
|
||||
WaveFileWriter g_wave_writer;
|
||||
bool m_muted;
|
||||
|
||||
public:
|
||||
SoundStream(CMixer* mixer) : m_mixer(mixer), threadData(0), m_logAudio(false), m_muted(false) {}
|
||||
SoundStream(CMixer* mixer) : m_mixer(mixer), m_logAudio(false), m_muted(false) {}
|
||||
virtual ~SoundStream() { delete m_mixer; }
|
||||
|
||||
static bool isValid() { return false; }
|
||||
|
Loading…
Reference in New Issue
Block a user