From 8104f63c7784d9943c88af782e993a007baabeb2 Mon Sep 17 00:00:00 2001 From: spacy51 Date: Sat, 15 Dec 2007 15:55:00 +0000 Subject: [PATCH] make sound & AVI recording independent from sound output --- src/win32/DirectSound.cpp | 30 ------------------------------ src/win32/VBA.cpp | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/win32/DirectSound.cpp b/src/win32/DirectSound.cpp index 80812ee5..8e7394b9 100644 --- a/src/win32/DirectSound.cpp +++ b/src/win32/DirectSound.cpp @@ -264,41 +264,11 @@ void DirectSound::write() HRESULT hr; DWORD status = 0; DWORD play = 0; - WAVEFORMATEX format; LPVOID lpvPtr1; DWORD dwBytes1 = 0; LPVOID lpvPtr2; DWORD dwBytes2 = 0; - - if( theApp.soundRecording ) { - if( dsbSecondary ) { - if( theApp.soundRecorder ) { - theApp.soundRecorder->AddSound( (u8 *)soundFinalWave, soundBufferLen ); - } else { - theApp.soundRecorder = new WavWriter; - dsbSecondary->GetFormat( &format, sizeof(format), NULL ); - if( theApp.soundRecorder->Open( theApp.soundRecordName ) ) { - theApp.soundRecorder->SetFormat( &format ); - } - } - } - } - - - if( theApp.aviRecording ) { - if( theApp.aviRecorder ) { - if( dsbSecondary ) { - if( !theApp.aviRecorder->IsSoundAdded() ) { - dsbSecondary->GetFormat( &format, sizeof(format), NULL ); - theApp.aviRecorder->SetSoundFormat( &format ); - } - } - theApp.aviRecorder->AddSound( (const char *)soundFinalWave, soundBufferLen ); - } - } - - if( !speedup && synchronize && !theApp.throttle ) { hr = dsbSecondary->GetStatus(&status); if( status & DSBSTATUS_PLAYING ) { diff --git a/src/win32/VBA.cpp b/src/win32/VBA.cpp index 855b7f98..7fbbbc84 100644 --- a/src/win32/VBA.cpp +++ b/src/win32/VBA.cpp @@ -1252,8 +1252,43 @@ void systemSoundResume() void systemWriteDataToSoundBuffer() { - if(theApp.sound) - theApp.sound->write(); + if( theApp.soundRecording ) { + if( theApp.soundRecorder ) { + theApp.soundRecorder->AddSound( (const u8 *)soundFinalWave, soundBufferLen ); + } else { + WAVEFORMATEX format; + format.cbSize = 0; + format.wFormatTag = WAVE_FORMAT_PCM; + format.nChannels = 2; + format.nSamplesPerSec = 44100 / soundQuality; + format.wBitsPerSample = 16; + format.nBlockAlign = format.nChannels * ( format.wBitsPerSample >> 3 ); + format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign; + theApp.soundRecorder = new WavWriter; + if( theApp.soundRecorder->Open( theApp.soundRecordName ) ) { + theApp.soundRecorder->SetFormat( &format ); + } + } + } + + if( theApp.aviRecording && theApp.aviRecorder ) { + if( !theApp.aviRecorder->IsSoundAdded() ) { + WAVEFORMATEX format; + format.cbSize = 0; + format.wFormatTag = WAVE_FORMAT_PCM; + format.nChannels = 2; + format.nSamplesPerSec = 44100 / soundQuality; + format.wBitsPerSample = 16; + format.nBlockAlign = format.nChannels * ( format.wBitsPerSample >> 3 ); + format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign; + theApp.aviRecorder->SetSoundFormat( &format ); + } + theApp.aviRecorder->AddSound( (const char *)soundFinalWave, soundBufferLen ); + } + + if( theApp.sound ) { + theApp.sound->write(); + } } bool systemCanChangeSoundQuality()