Fixed MFC for my previous commit

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@826 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
bgk 2008-12-26 20:11:33 +00:00
parent 1eebdc6dbe
commit b7197a8a92
10 changed files with 66 additions and 66 deletions

View File

@ -365,6 +365,7 @@ void flush_samples(Multi_Buffer * buffer)
soundResume(); soundResume();
soundDriver->write(soundFinalWave, soundBufferLen); soundDriver->write(soundFinalWave, soundBufferLen);
systemOnWriteDataToSoundBuffer(soundFinalWave, soundBufferLen);
} }
} }
@ -469,19 +470,27 @@ static void remake_stereo_buffer()
void soundShutdown() void soundShutdown()
{ {
delete soundDriver; if (soundDriver)
{
delete soundDriver;
soundDriver = 0;
}
systemOnSoundShutdown();
} }
void soundPause() void soundPause()
{ {
soundPaused = true; soundPaused = true;
soundDriver->pause(); if (soundDriver)
soundDriver->pause();
} }
void soundResume() void soundResume()
{ {
soundPaused = false; soundPaused = false;
soundDriver->resume(); if (soundDriver)
soundDriver->resume();
} }
void soundSetVolume( float volume ) void soundSetVolume( float volume )
@ -532,6 +541,11 @@ bool soundInit()
return true; return true;
} }
int soundGetQuality()
{
return soundQuality;
}
void soundSetQuality(int quality) void soundSetQuality(int quality)
{ {
if ( soundQuality != quality ) if ( soundQuality != quality )

View File

@ -36,6 +36,7 @@ void soundShutdown();
//// GBA sound options //// GBA sound options
// Sets sample rate to 44100 / quality // Sets sample rate to 44100 / quality
int soundGetQuality();
void soundSetQuality( int quality ); void soundSetQuality( int quality );
// Sound settings // Sound settings

View File

@ -67,6 +67,8 @@ extern u32 systemGetClock();
extern void systemMessage(int, const char *, ...); extern void systemMessage(int, const char *, ...);
extern void systemSetTitle(const char *); extern void systemSetTitle(const char *);
extern SoundDriver * systemSoundInit(); extern SoundDriver * systemSoundInit();
extern void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length);
extern void systemOnSoundShutdown();
extern void systemScreenMessage(const char *); extern void systemScreenMessage(const char *);
extern void systemUpdateMotionSensor(); extern void systemUpdateMotionSensor();
extern int systemGetSensorX(); extern int systemGetSensorX();

View File

@ -161,6 +161,14 @@ SoundDriver * systemSoundInit()
return new SoundSDL(); return new SoundSDL();
} }
void systemOnSoundShutdown()
{
}
void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length)
{
}
void debuggerMain() void debuggerMain()
{ {
} }

View File

@ -2716,3 +2716,11 @@ SoundDriver * systemSoundInit()
return new SoundSDL(); return new SoundSDL();
} }
void systemOnSoundShutdown()
{
}
void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length)
{
}

View File

@ -10,6 +10,7 @@
#include "../agb/GBA.h" #include "../agb/GBA.h"
#include "../Globals.h" #include "../Globals.h"
#include "../Sound.h" #include "../Sound.h"
#include "../common/SoundDriver.h"
// DirectSound8 // DirectSound8
#include <dsound.h> #include <dsound.h>

View File

@ -1531,8 +1531,8 @@ void MainWnd::OnUpdateOptionsEmulatorGameoverrides(CCmdUI* pCmdUI)
void MainWnd::OnOptionsSoundHardwareacceleration() void MainWnd::OnOptionsSoundHardwareacceleration()
{ {
theApp.dsoundDisableHardwareAcceleration = !theApp.dsoundDisableHardwareAcceleration; theApp.dsoundDisableHardwareAcceleration = !theApp.dsoundDisableHardwareAcceleration;
systemSoundShutdown(); soundShutdown();
systemSoundInit(); soundInit();
} }
void MainWnd::OnUpdateOptionsSoundHardwareacceleration(CCmdUI *pCmdUI) void MainWnd::OnUpdateOptionsSoundHardwareacceleration(CCmdUI *pCmdUI)
@ -1556,8 +1556,8 @@ void MainWnd::OnOutputapiDirectsound()
{ {
if( theApp.audioAPI != DIRECTSOUND ) { if( theApp.audioAPI != DIRECTSOUND ) {
theApp.audioAPI = DIRECTSOUND; theApp.audioAPI = DIRECTSOUND;
systemSoundShutdown(); soundShutdown();
systemSoundInit(); soundInit();
} }
} }
@ -1572,8 +1572,8 @@ void MainWnd::OnOutputapiXaudio2()
#ifndef NO_XAUDIO2 #ifndef NO_XAUDIO2
if( theApp.audioAPI != XAUDIO2 ) { if( theApp.audioAPI != XAUDIO2 ) {
theApp.audioAPI = XAUDIO2; theApp.audioAPI = XAUDIO2;
systemSoundShutdown(); soundShutdown();
systemSoundInit(); soundInit();
} }
#endif #endif
} }
@ -1593,8 +1593,8 @@ void MainWnd::OnOutputapiOpenal()
#ifndef NO_OAL #ifndef NO_OAL
if( theApp.audioAPI != OPENAL_SOUND ) { if( theApp.audioAPI != OPENAL_SOUND ) {
theApp.audioAPI = OPENAL_SOUND; theApp.audioAPI = OPENAL_SOUND;
systemSoundShutdown(); soundShutdown();
systemSoundInit(); soundInit();
} }
#endif #endif
} }
@ -1618,7 +1618,7 @@ void MainWnd::OnOutputapiOalconfiguration()
dlg.bufferCount = theApp.oalBufferCount; dlg.bufferCount = theApp.oalBufferCount;
if( dlg.DoModal() == IDOK ) { if( dlg.DoModal() == IDOK ) {
systemSoundShutdown(); soundShutdown();
// do this before changing any values OpenAL // do this before changing any values OpenAL
// might need for successful cleanup // might need for successful cleanup
@ -1631,7 +1631,7 @@ void MainWnd::OnOutputapiOalconfiguration()
_tcscpy( theApp.oalDevice, dlg.selectedDevice.GetBuffer() ); _tcscpy( theApp.oalDevice, dlg.selectedDevice.GetBuffer() );
theApp.oalBufferCount = dlg.bufferCount; theApp.oalBufferCount = dlg.bufferCount;
systemSoundInit(); soundInit();
} }
#endif #endif
} }
@ -1655,13 +1655,13 @@ void MainWnd::OnOutputapiXaudio2config()
dlg.m_enable_upmixing = theApp.xa2Upmixing; dlg.m_enable_upmixing = theApp.xa2Upmixing;
if( dlg.DoModal() == IDOK ) { if( dlg.DoModal() == IDOK ) {
systemSoundShutdown(); soundShutdown();
theApp.xa2Device = dlg.m_selected_device_index; theApp.xa2Device = dlg.m_selected_device_index;
theApp.xa2BufferCount = dlg.m_buffer_count; theApp.xa2BufferCount = dlg.m_buffer_count;
theApp.xa2Upmixing = dlg.m_enable_upmixing; theApp.xa2Upmixing = dlg.m_enable_upmixing;
systemSoundInit(); soundInit();
} }
#endif #endif
} }

View File

@ -397,7 +397,7 @@ void MainWnd::OnToolsRecordStartavirecording()
// add audio stream // add audio stream
ret = theApp.aviRecorder->CreateAudioStream( ret = theApp.aviRecorder->CreateAudioStream(
2, 2,
44100 / soundQuality, 44100 / soundGetQuality(),
16, 16,
this->GetSafeHwnd() this->GetSafeHwnd()
); );

View File

@ -30,6 +30,7 @@
#include "../dmg/gbGlobals.h" #include "../dmg/gbGlobals.h"
#include "../dmg/gbPrinter.h" #include "../dmg/gbPrinter.h"
#include "../dmg/gbSound.h" #include "../dmg/gbSound.h"
#include "../common/SoundDriver.h"
/* Link /* Link
---------------------*/ ---------------------*/
@ -291,7 +292,6 @@ VBA::VBA()
soundRecording = false; soundRecording = false;
soundRecorder = NULL; soundRecorder = NULL;
dsoundDisableHardwareAcceleration = true; dsoundDisableHardwareAcceleration = true;
sound = NULL;
aviRecording = false; aviRecording = false;
aviRecorder = NULL; aviRecorder = NULL;
painting = false; painting = false;
@ -960,9 +960,8 @@ void VBA::updateThrottle( unsigned short throttle )
systemFrameSkip = 0; systemFrameSkip = 0;
} }
if( theApp.sound ) { soundShutdown();
theApp.sound->setThrottle( throttle ); soundInit();
}
} }
@ -1235,39 +1234,37 @@ int systemGetSensorY()
} }
bool systemSoundInit() SoundDriver * systemSoundInit()
{ {
systemSoundShutdown(); SoundDriver * drv = 0;
soundShutdown();
switch( theApp.audioAPI ) switch( theApp.audioAPI )
{ {
case DIRECTSOUND: case DIRECTSOUND:
theApp.sound = newDirectSound(); drv = newDirectSound();
break; break;
#ifndef NO_OAL #ifndef NO_OAL
case OPENAL_SOUND: case OPENAL_SOUND:
theApp.sound = newOpenAL(); drv = newOpenAL();
break; break;
#endif #endif
#ifndef NO_XAUDIO2 #ifndef NO_XAUDIO2
case XAUDIO2: case XAUDIO2:
theApp.sound = newXAudio2_Output(); drv = newXAudio2_Output();
break; break;
#endif #endif
} }
bool retVal = theApp.sound->init(soundQuality); if( drv ) {
soundBufferLen = theApp.sound->getBufferLength(); drv->setThrottle( theApp.throttle );
if( retVal ) {
theApp.sound->setThrottle( theApp.throttle );
} }
return retVal; return drv;
} }
void systemSoundShutdown() void systemOnSoundShutdown()
{ {
if( theApp.aviRecorder ) { if( theApp.aviRecorder ) {
delete theApp.aviRecorder; delete theApp.aviRecorder;
@ -1281,38 +1278,13 @@ void systemSoundShutdown()
theApp.soundRecorder = NULL; theApp.soundRecorder = NULL;
} }
theApp.soundRecording = false; theApp.soundRecording = false;
if( theApp.sound ) {
delete theApp.sound;
theApp.sound = NULL;
}
} }
void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length)
void systemSoundPause()
{
if(theApp.sound)
theApp.sound->pause();
}
void systemSoundReset()
{
if(theApp.sound)
theApp.sound->reset();
}
void systemSoundResume()
{
if(theApp.sound)
theApp.sound->resume();
}
void systemWriteDataToSoundBuffer()
{ {
if( theApp.soundRecording ) { if( theApp.soundRecording ) {
if( theApp.soundRecorder ) { if( theApp.soundRecorder ) {
theApp.soundRecorder->AddSound( (const u8 *)soundFinalWave, soundBufferLen ); theApp.soundRecorder->AddSound( (const u8 *)finalWave, length );
} else { } else {
WAVEFORMATEX format; WAVEFORMATEX format;
format.cbSize = 0; format.cbSize = 0;
@ -1333,7 +1305,7 @@ void systemWriteDataToSoundBuffer()
if( theApp.skipAudioFrames ) { if( theApp.skipAudioFrames ) {
theApp.skipAudioFrames--; theApp.skipAudioFrames--;
} else { } else {
if( false == theApp.aviRecorder->AddAudioFrame( soundFinalWave ) ) { if( false == theApp.aviRecorder->AddAudioFrame( ( u8 *)finalWave ) ) {
systemMessage( IDS_AVI_CANNOT_WRITE_AUDIO, "Cannot write audio frame to AVI file." ); systemMessage( IDS_AVI_CANNOT_WRITE_AUDIO, "Cannot write audio frame to AVI file." );
delete theApp.aviRecorder; delete theApp.aviRecorder;
theApp.aviRecorder = NULL; theApp.aviRecorder = NULL;
@ -1341,10 +1313,6 @@ void systemWriteDataToSoundBuffer()
} }
} }
} }
if( theApp.sound ) {
theApp.sound->write(soundFinalWave, soundBufferLen);
}
} }
bool systemCanChangeSoundQuality() bool systemCanChangeSoundQuality()

View File

@ -11,7 +11,6 @@
#include "Display.h" #include "Display.h"
#include "Input.h" #include "Input.h"
#include "IUpdate.h" #include "IUpdate.h"
#include "../common/SoundDriver.h"
#include "../System.h" #include "../System.h"
#include "../Util.h" #include "../Util.h"
@ -170,7 +169,6 @@ class VBA : public CWinApp
WavWriter *soundRecorder; WavWriter *soundRecorder;
CString soundRecordName; CString soundRecordName;
bool dsoundDisableHardwareAcceleration; bool dsoundDisableHardwareAcceleration;
SoundDriver *sound;
bool aviRecording; bool aviRecording;
AVIWrite *aviRecorder; AVIWrite *aviRecorder;
CString aviRecordName; CString aviRecordName;