more clean up, starting to add recording support to sound stream
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2762 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
542bd73ba8
commit
a0e9e53d0c
|
@ -48,4 +48,34 @@ SoundStream *InitSoundStream(std::string backend, CMixer *mixer) {
|
||||||
return soundStream;
|
return soundStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
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");
|
||||||
|
backends.push_back("NullSound");
|
||||||
|
|
||||||
|
return backends;
|
||||||
|
}
|
||||||
|
|
||||||
} // Namespace
|
} // Namespace
|
||||||
|
|
|
@ -13,6 +13,8 @@ extern SoundStream *soundStream;
|
||||||
namespace AudioCommon {
|
namespace AudioCommon {
|
||||||
|
|
||||||
SoundStream *InitSoundStream(std::string backend, CMixer *mixer = NULL);
|
SoundStream *InitSoundStream(std::string backend, CMixer *mixer = NULL);
|
||||||
|
void ShutdownSoundStream();
|
||||||
|
std::vector<std::string> GetSoundBackends();
|
||||||
} // Namespace
|
} // Namespace
|
||||||
|
|
||||||
#endif // AUDIO_COMMON
|
#endif // AUDIO_COMMON
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Mixer.h"
|
#include "Mixer.h"
|
||||||
|
#include "WaveFile.h"
|
||||||
|
|
||||||
class SoundStream
|
class SoundStream
|
||||||
{
|
{
|
||||||
|
@ -29,7 +30,9 @@ protected:
|
||||||
// We set this to shut down the sound thread.
|
// We set this to shut down the sound thread.
|
||||||
// 0=keep playing, 1=stop playing NOW.
|
// 0=keep playing, 1=stop playing NOW.
|
||||||
volatile int threadData;
|
volatile int threadData;
|
||||||
|
bool m_logAudio;
|
||||||
|
WaveFileWriter g_wave_writer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SoundStream(CMixer *mixer) : m_mixer(mixer), threadData(0) {}
|
SoundStream(CMixer *mixer) : m_mixer(mixer), threadData(0) {}
|
||||||
virtual ~SoundStream() { delete m_mixer;}
|
virtual ~SoundStream() { delete m_mixer;}
|
||||||
|
@ -40,6 +43,26 @@ public:
|
||||||
virtual void SoundLoop() {}
|
virtual void SoundLoop() {}
|
||||||
virtual void Stop() {}
|
virtual void Stop() {}
|
||||||
virtual void Update() {}
|
virtual void Update() {}
|
||||||
|
virtual void StartLogAudio(const char *filename) {
|
||||||
|
if (! m_logAudio) {
|
||||||
|
m_logAudio = true;
|
||||||
|
g_wave_writer.Start(filename);
|
||||||
|
g_wave_writer.SetSkipSilence(false);
|
||||||
|
NOTICE_LOG(DSPHLE, "Starting Audio logging");
|
||||||
|
} else {
|
||||||
|
WARN_LOG(DSPHLE, "Audio logging already started");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void StopLogAudio() {
|
||||||
|
if (m_logAudio) {
|
||||||
|
m_logAudio = false;
|
||||||
|
g_wave_writer.Stop();
|
||||||
|
NOTICE_LOG(DSPHLE, "Starting Audio logging");
|
||||||
|
} else {
|
||||||
|
WARN_LOG(DSPHLE, "Audio logging already stopped");
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,16 +27,12 @@ CDebugger* m_frame = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ChunkFile.h"
|
#include "ChunkFile.h"
|
||||||
#include "WaveFile.h"
|
|
||||||
#include "HLEMixer.h"
|
#include "HLEMixer.h"
|
||||||
#include "DSPHandler.h"
|
#include "DSPHandler.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Setup.h"
|
#include "Setup.h"
|
||||||
#include "StringUtil.h"
|
#include "StringUtil.h"
|
||||||
#include "AudioCommon.h"
|
#include "AudioCommon.h"
|
||||||
#include "AOSoundStream.h"
|
|
||||||
#include "DSoundStream.h"
|
|
||||||
#include "NullSoundStream.h"
|
|
||||||
|
|
||||||
|
|
||||||
// Declarations and definitions
|
// Declarations and definitions
|
||||||
|
@ -47,11 +43,6 @@ extern std::vector<std::string> sMailLog, sMailTime;
|
||||||
|
|
||||||
SoundStream *soundStream = NULL;
|
SoundStream *soundStream = NULL;
|
||||||
|
|
||||||
// Set this if you want to log audio. search for log_ai in this file to see the filename.
|
|
||||||
bool log_ai = false;
|
|
||||||
WaveFileWriter g_wave_writer;
|
|
||||||
|
|
||||||
|
|
||||||
// Mailbox utility
|
// Mailbox utility
|
||||||
struct DSPState
|
struct DSPState
|
||||||
{
|
{
|
||||||
|
@ -181,13 +172,13 @@ void DllConfig(HWND _hParent)
|
||||||
// (shuffle2) TODO: reparent dlg with DolphinApp
|
// (shuffle2) TODO: reparent dlg with DolphinApp
|
||||||
ConfigDialog dlg(NULL);
|
ConfigDialog dlg(NULL);
|
||||||
|
|
||||||
// Add avaliable output options
|
// add backends
|
||||||
if (DSound::isValid())
|
std::vector<std::string> backends = AudioCommon::GetSoundBackends();
|
||||||
dlg.AddBackend("DSound");
|
|
||||||
if (AOSound::isValid())
|
|
||||||
dlg.AddBackend("AOSound");
|
|
||||||
dlg.AddBackend("NullSound");
|
|
||||||
|
|
||||||
|
for (std::vector<std::string>::const_iterator iter = backends.begin();
|
||||||
|
iter != backends.end(); ++iter) {
|
||||||
|
dlg.AddBackend((*iter).c_str());
|
||||||
|
}
|
||||||
// Show the window
|
// Show the window
|
||||||
dlg.ShowModal();
|
dlg.ShowModal();
|
||||||
#endif
|
#endif
|
||||||
|
@ -208,43 +199,20 @@ void Initialize(void *init)
|
||||||
soundStream->GetMixer()->SetThrottle(g_Config.m_EnableThrottle);
|
soundStream->GetMixer()->SetThrottle(g_Config.m_EnableThrottle);
|
||||||
|
|
||||||
// Start the sound recording
|
// Start the sound recording
|
||||||
if (log_ai)
|
/*
|
||||||
{
|
if (g_Config.record) {
|
||||||
g_wave_writer.Start("ai_log.wav");
|
soundStream->StartLogAudio(FULL_DUMP_DIR g_Config.recordFile);
|
||||||
g_wave_writer.SetSkipSilence(false);
|
}
|
||||||
}
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSP_StopSoundStream()
|
void DSP_StopSoundStream()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (!soundStream)
|
|
||||||
PanicAlert("Can't stop non running SoundStream!");
|
|
||||||
soundStream->Stop();
|
|
||||||
delete soundStream;
|
|
||||||
soundStream = NULL;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown()
|
void Shutdown()
|
||||||
{
|
{
|
||||||
NOTICE_LOG(DSPHLE, "Shutting down DSP plugin");
|
AudioCommon::ShutdownSoundStream();
|
||||||
|
|
||||||
if (soundStream) {
|
|
||||||
soundStream->Stop();
|
|
||||||
delete soundStream;
|
|
||||||
soundStream = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that soundstream already is stopped.
|
|
||||||
while (soundStream) {
|
|
||||||
ERROR_LOG(DSPHLE, "Waiting for sound stream");
|
|
||||||
Common::SleepCurrentThread(2000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop the sound recording
|
|
||||||
if (log_ai)
|
|
||||||
g_wave_writer.Stop();
|
|
||||||
|
|
||||||
// Delete the UCodes
|
// Delete the UCodes
|
||||||
CDSPHandler::Destroy();
|
CDSPHandler::Destroy();
|
||||||
|
@ -259,7 +227,7 @@ void Shutdown()
|
||||||
m_frame->sMailEnd.clear();
|
m_frame->sMailEnd.clear();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
INFO_LOG(DSPHLE, "Done shutting down DSP plugin");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoState(unsigned char **ptr, int mode)
|
void DoState(unsigned char **ptr, int mode)
|
||||||
|
@ -373,9 +341,9 @@ void DSP_SendAIBuffer(unsigned int address, int sample_rate)
|
||||||
samples[i] = Memory_Read_U16(address + i * 2);
|
samples[i] = Memory_Read_U16(address + i * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the audio to a file
|
// FIXME: Write the audio to a file
|
||||||
if (log_ai)
|
//if (log_ai)
|
||||||
g_wave_writer.AddStereoSamples(samples, 8);
|
// g_wave_writer.AddStereoSamples(samples, 8);
|
||||||
}
|
}
|
||||||
soundStream->GetMixer()->PushSamples(samples, 32 / 4);
|
soundStream->GetMixer()->PushSamples(samples, 32 / 4);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
|
|
||||||
#include "Common.h" // Common
|
#include "Common.h" // Common
|
||||||
#include "WaveFile.h"
|
|
||||||
#include "CommonTypes.h"
|
#include "CommonTypes.h"
|
||||||
#include "Mixer.h"
|
#include "Mixer.h"
|
||||||
|
|
||||||
|
@ -32,10 +31,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "AudioCommon.h"
|
#include "AudioCommon.h"
|
||||||
#include "AOSoundStream.h"
|
|
||||||
#include "DSoundStream.h"
|
|
||||||
#include "NullSoundStream.h"
|
|
||||||
|
|
||||||
#include "Logging/Logging.h" // For Logging
|
#include "Logging/Logging.h" // For Logging
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -64,11 +59,6 @@ bool AXTask(u32& _uMail);
|
||||||
|
|
||||||
bool bCanWork = false;
|
bool bCanWork = false;
|
||||||
|
|
||||||
// Set this if you want to log audio. search for log_ai in this file to see the filename.
|
|
||||||
static bool log_ai = false;
|
|
||||||
WaveFileWriter g_wave_writer;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
|
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
|
||||||
DWORD dwReason, // reason called
|
DWORD dwReason, // reason called
|
||||||
|
@ -124,12 +114,13 @@ void DllConfig(HWND _hParent)
|
||||||
// (shuffle2) TODO: reparent dlg with DolphinApp
|
// (shuffle2) TODO: reparent dlg with DolphinApp
|
||||||
ConfigDialog dlg(NULL);
|
ConfigDialog dlg(NULL);
|
||||||
|
|
||||||
// Add avaliable output options
|
// add backends
|
||||||
if (DSound::isValid())
|
std::vector<std::string> backends = AudioCommon::GetSoundBackends();
|
||||||
dlg.AddBackend("DSound");
|
|
||||||
if (AOSound::isValid())
|
for (std::vector<std::string>::const_iterator iter = backends.begin();
|
||||||
dlg.AddBackend("AOSound");
|
iter != backends.end(); ++iter) {
|
||||||
dlg.AddBackend("NullSound");
|
dlg.AddBackend((*iter).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// Show the window
|
// Show the window
|
||||||
dlg.ShowModal();
|
dlg.ShowModal();
|
||||||
|
@ -251,12 +242,6 @@ void Initialize(void *init)
|
||||||
soundStream = AudioCommon::InitSoundStream(g_Config.sBackend);
|
soundStream = AudioCommon::InitSoundStream(g_Config.sBackend);
|
||||||
|
|
||||||
soundStream->GetMixer()->SetThrottle(g_Config.m_EnableThrottle);
|
soundStream->GetMixer()->SetThrottle(g_Config.m_EnableThrottle);
|
||||||
// Start the sound recording
|
|
||||||
if (log_ai)
|
|
||||||
{
|
|
||||||
g_wave_writer.Start("ai_log.wav");
|
|
||||||
g_wave_writer.SetSkipSilence(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSP_StopSoundStream()
|
void DSP_StopSoundStream()
|
||||||
|
@ -265,25 +250,7 @@ void DSP_StopSoundStream()
|
||||||
|
|
||||||
void Shutdown(void)
|
void Shutdown(void)
|
||||||
{
|
{
|
||||||
NOTICE_LOG(DSPHLE, "Shutting down DSP plugin");
|
AudioCommon::ShutdownSoundStream();
|
||||||
|
|
||||||
if (soundStream) {
|
|
||||||
soundStream->Stop();
|
|
||||||
delete soundStream;
|
|
||||||
soundStream = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that soundstream already is stopped.
|
|
||||||
while (soundStream) {
|
|
||||||
ERROR_LOG(DSPHLE, "Waiting for sound stream");
|
|
||||||
Common::SleepCurrentThread(2000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop the sound recording
|
|
||||||
if (log_ai)
|
|
||||||
g_wave_writer.Stop();
|
|
||||||
|
|
||||||
INFO_LOG(DSPHLE, "Done shutting down DSP plugin");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 DSP_WriteControlRegister(u16 _uFlag)
|
u16 DSP_WriteControlRegister(u16 _uFlag)
|
||||||
|
@ -401,8 +368,8 @@ void DSP_SendAIBuffer(unsigned int address, int sample_rate)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the audio to a file
|
// Write the audio to a file
|
||||||
if (log_ai)
|
//if (log_ai)
|
||||||
g_wave_writer.AddStereoSamples(samples, 8);
|
// g_wave_writer.AddStereoSamples(samples, 8);
|
||||||
}
|
}
|
||||||
soundStream->GetMixer()->PushSamples(samples, 32 / 4);
|
soundStream->GetMixer()->PushSamples(samples, 32 / 4);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue