* Dump AVI output on every VI (fixes issue #4064).

* Add audio dumping (fixes issue #1638).


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7131 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
smelenchuk
2011-02-11 18:59:42 +00:00
parent ca78d3639b
commit b0fa0a83f8
13 changed files with 132 additions and 30 deletions

View File

@ -16,6 +16,7 @@
// http://code.google.com/p/dolphin-emu/
#include "AudioCommon.h"
#include "FileUtil.h"
#include "Mixer.h"
#include "NullSoundStream.h"
#include "DSoundStream.h"
@ -53,11 +54,13 @@ namespace AudioCommon
ac_Config.Update();
if (soundStream->Start())
{
#if 0
// Start the sound recording
if (ac_Config.record)
soundStream->StartLogAudio(FULL_DUMP_DIR g_Config.recordFile);
#endif
if (ac_Config.m_DumpAudio) {
char audio_file_name[255];
snprintf(audio_file_name, 255, "%saudiodump.wav", File::GetUserPath(D_DUMPAUDIO_IDX));
mixer->StartLogAudio(audio_file_name);
//soundStream->StartLogAudio(audio_file_name);
}
return soundStream;
}
PanicAlertT("Could not initialize backend %s.", backend.c_str());
@ -76,10 +79,9 @@ namespace AudioCommon
if (soundStream)
{
soundStream->Stop();
#if 0
if (ac_Config.record)
soundStream->StopLogAudio();
#endif
if (ac_Config.m_DumpAudio)
soundStream->GetMixer()->StopLogAudio();
//soundStream->StopLogAudio();
delete soundStream;
soundStream = NULL;
}

View File

@ -33,6 +33,7 @@ void AudioCommonConfig::Load()
file.Get("Config", "EnableDTKMusic", &m_EnableDTKMusic, true);
file.Get("Config", "EnableThrottle", &m_EnableThrottle, true);
file.Get("Config", "EnableJIT", &m_EnableJIT, true);
file.Get("Config", "DumpAudio", &m_DumpAudio, false);
#if defined __linux__ && HAVE_ALSA
file.Get("Config", "Backend", &sBackend, BACKEND_ALSA);
#elif defined __APPLE__
@ -55,6 +56,7 @@ void AudioCommonConfig::SaveSettings()
file.Set("Config", "EnableDTKMusic", m_EnableDTKMusic);
file.Set("Config", "EnableThrottle", m_EnableThrottle);
file.Set("Config", "EnableJIT", m_EnableJIT);
file.Set("Config", "DumpAudio", m_DumpAudio);
file.Set("Config", "Backend", sBackend);
file.Set("Config", "Frequency", sFrequency);
file.Set("Config", "Volume", m_Volume);

View File

@ -36,6 +36,7 @@ struct AudioCommonConfig
bool m_EnableDTKMusic;
bool m_EnableThrottle;
bool m_EnableJIT;
bool m_DumpAudio;
int m_Volume;
std::string sBackend;
int sFrequency;

View File

@ -125,15 +125,29 @@ unsigned int CMixer::Mix(short* samples, unsigned int numSamples)
if (numSamples > numLeft)
memset(&samples[numLeft * 2], 0, (numSamples - numLeft) * 4);
// Add the DSPHLE sound, re-sampling is done inside
Premix(samples, numSamples);
//when logging, also throttle HLE audio
if (m_logAudio) {
if (m_AIplaying) {
Premix(samples, numLeft);
// Add the DTK Music
if (m_EnableDTKMusic)
{
// Re-sampling is done inside
AudioInterface::Callback_GetStreaming(samples, numSamples, m_sampleRate);
if (m_EnableDTKMusic)
AudioInterface::Callback_GetStreaming(samples, numLeft, m_sampleRate);
g_wave_writer.AddStereoSamples(samples, numLeft);
}
}
else { //or mix as usual
// Add the DSPHLE sound, re-sampling is done inside
Premix(samples, numSamples);
// Add the DTK Music
if (m_EnableDTKMusic)
{
// Re-sampling is done inside
AudioInterface::Callback_GetStreaming(samples, numSamples, m_sampleRate);
}
}
Common::AtomicAdd(m_numSamples, -(s32)numLeft);

View File

@ -18,6 +18,8 @@
#ifndef _MIXER_H_
#define _MIXER_H_
#include "WaveFile.h"
// 16 bit Stereo
#define MAX_SAMPLES (1024 * 8)
#define INDEX_MASK (MAX_SAMPLES * 2 - 1)
@ -36,6 +38,7 @@ public:
, m_indexW(0)
, m_indexR(0)
, m_AIplaying(true)
, m_logAudio(0)
{
// AyuanX: The internal (Core & DSP) sample rate is fixed at 32KHz
// So when AI/DAC sample rate differs than 32KHz, we have to do re-sampling
@ -63,14 +66,40 @@ public:
void SetHLEReady(bool ready) { m_HLEready = ready;}
// ---------------------
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, "Stopping Audio logging");
} else {
WARN_LOG(DSPHLE, "Audio logging already stopped");
}
}
protected:
unsigned int m_sampleRate;
unsigned int m_aiSampleRate;
unsigned int m_dacSampleRate;
int m_bits;
int m_channels;
WaveFileWriter g_wave_writer;
bool m_HLEready;
bool m_logAudio;
bool m_EnableDTKMusic;
bool m_throttle;