make sound & AVI recording independent from sound output

This commit is contained in:
spacy51 2007-12-15 15:55:00 +00:00
parent 45f7eddcc5
commit 8104f63c77
2 changed files with 37 additions and 32 deletions

View File

@ -264,41 +264,11 @@ void DirectSound::write()
HRESULT hr; HRESULT hr;
DWORD status = 0; DWORD status = 0;
DWORD play = 0; DWORD play = 0;
WAVEFORMATEX format;
LPVOID lpvPtr1; LPVOID lpvPtr1;
DWORD dwBytes1 = 0; DWORD dwBytes1 = 0;
LPVOID lpvPtr2; LPVOID lpvPtr2;
DWORD dwBytes2 = 0; 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 ) { if( !speedup && synchronize && !theApp.throttle ) {
hr = dsbSecondary->GetStatus(&status); hr = dsbSecondary->GetStatus(&status);
if( status & DSBSTATUS_PLAYING ) { if( status & DSBSTATUS_PLAYING ) {

View File

@ -1252,8 +1252,43 @@ void systemSoundResume()
void systemWriteDataToSoundBuffer() void systemWriteDataToSoundBuffer()
{ {
if(theApp.sound) 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(); theApp.sound->write();
}
} }
bool systemCanChangeSoundQuality() bool systemCanChangeSoundQuality()