mirror of
https://github.com/danog/libtgvoip.git
synced 2025-01-22 13:01:21 +01:00
Fixed audio on Windows XP
This commit is contained in:
parent
6a8f543cca
commit
6ba1241cfe
44
os/windows/AudioInputWave.cpp
Normal file → Executable file
44
os/windows/AudioInputWave.cpp
Normal file → Executable file
@ -42,33 +42,37 @@ void AudioInputWave::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint
|
||||
}
|
||||
|
||||
void AudioInputWave::Start(){
|
||||
isRecording=true;
|
||||
|
||||
MMRESULT res;
|
||||
for(int i=0;i<4;i++){
|
||||
res=waveInPrepareHeader(hWaveIn, &buffers[i], sizeof(WAVEHDR));
|
||||
CHECK_ERROR(res, "waveInPrepareHeader failed");
|
||||
res=waveInAddBuffer(hWaveIn, &buffers[i], sizeof(WAVEHDR));
|
||||
CHECK_ERROR(res, "waveInAddBuffer failed");
|
||||
if(!isRecording){
|
||||
isRecording=true;
|
||||
|
||||
MMRESULT res;
|
||||
for(int i=0;i<4;i++){
|
||||
res=waveInPrepareHeader(hWaveIn, &buffers[i], sizeof(WAVEHDR));
|
||||
CHECK_ERROR(res, "waveInPrepareHeader failed");
|
||||
res=waveInAddBuffer(hWaveIn, &buffers[i], sizeof(WAVEHDR));
|
||||
CHECK_ERROR(res, "waveInAddBuffer failed");
|
||||
}
|
||||
res=waveInStart(hWaveIn);
|
||||
CHECK_ERROR(res, "waveInStart failed");
|
||||
}
|
||||
res=waveInStart(hWaveIn);
|
||||
CHECK_ERROR(res, "waveInStart failed");
|
||||
}
|
||||
|
||||
void AudioInputWave::Stop(){
|
||||
isRecording=false;
|
||||
|
||||
MMRESULT res=waveInStop(hWaveIn);
|
||||
CHECK_ERROR(res, "waveInStop failed");
|
||||
res=waveInReset(hWaveIn);
|
||||
CHECK_ERROR(res, "waveInReset failed");
|
||||
for(int i=0;i<4;i++){
|
||||
res=waveInUnprepareHeader(hWaveIn, &buffers[i], sizeof(WAVEHDR));
|
||||
CHECK_ERROR(res, "waveInUnprepareHeader failed");
|
||||
if(isRecording){
|
||||
isRecording=false;
|
||||
|
||||
MMRESULT res=waveInStop(hWaveIn);
|
||||
CHECK_ERROR(res, "waveInStop failed");
|
||||
res=waveInReset(hWaveIn);
|
||||
CHECK_ERROR(res, "waveInReset failed");
|
||||
for(int i=0;i<4;i++){
|
||||
res=waveInUnprepareHeader(hWaveIn, &buffers[i], sizeof(WAVEHDR));
|
||||
CHECK_ERROR(res, "waveInUnprepareHeader failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioInputWave::WaveInProc(HWAVEIN hwi, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2){
|
||||
void CALLBACK AudioInputWave::WaveInProc(HWAVEIN hwi, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2){
|
||||
if(uMsg==WIM_DATA){
|
||||
((AudioInputWave*)dwInstance)->OnData((WAVEHDR*)dwParam1);
|
||||
}
|
||||
|
34
os/windows/AudioOutputWave.cpp
Normal file → Executable file
34
os/windows/AudioOutputWave.cpp
Normal file → Executable file
@ -40,26 +40,30 @@ void AudioOutputWave::Configure(uint32_t sampleRate, uint32_t bitsPerSample, uin
|
||||
}
|
||||
|
||||
void AudioOutputWave::Start(){
|
||||
isPlaying=true;
|
||||
|
||||
for(int i=0;i<4;i++){
|
||||
MMRESULT res=waveOutPrepareHeader(hWaveOut, &buffers[i], sizeof(WAVEHDR));
|
||||
CHECK_ERROR(res, "waveOutPrepareHeader failed");
|
||||
//InvokeCallback((unsigned char*)buffers[i].lpData, buffers[i].dwBufferLength);
|
||||
ZeroMemory(buffers[i].lpData, buffers[i].dwBufferLength);
|
||||
res=waveOutWrite(hWaveOut, &buffers[i], sizeof(WAVEHDR));
|
||||
CHECK_ERROR(res, "waveOutWrite failed");
|
||||
if(!isPlaying){
|
||||
isPlaying=true;
|
||||
|
||||
for(int i=0;i<4;i++){
|
||||
MMRESULT res=waveOutPrepareHeader(hWaveOut, &buffers[i], sizeof(WAVEHDR));
|
||||
CHECK_ERROR(res, "waveOutPrepareHeader failed");
|
||||
//InvokeCallback((unsigned char*)buffers[i].lpData, buffers[i].dwBufferLength);
|
||||
ZeroMemory(buffers[i].lpData, buffers[i].dwBufferLength);
|
||||
res=waveOutWrite(hWaveOut, &buffers[i], sizeof(WAVEHDR));
|
||||
CHECK_ERROR(res, "waveOutWrite failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioOutputWave::Stop(){
|
||||
isPlaying=false;
|
||||
if(isPlaying){
|
||||
isPlaying=false;
|
||||
|
||||
MMRESULT res=waveOutReset(hWaveOut);
|
||||
CHECK_ERROR(res, "waveOutReset failed");
|
||||
for(int i=0;i<4;i++){
|
||||
res=waveOutUnprepareHeader(hWaveOut, &buffers[i], sizeof(WAVEHDR));
|
||||
CHECK_ERROR(res, "waveOutUnprepareHeader failed");
|
||||
MMRESULT res=waveOutReset(hWaveOut);
|
||||
CHECK_ERROR(res, "waveOutReset failed");
|
||||
for(int i=0;i<4;i++){
|
||||
res=waveOutUnprepareHeader(hWaveOut, &buffers[i], sizeof(WAVEHDR));
|
||||
CHECK_ERROR(res, "waveOutUnprepareHeader failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user