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(){
|
void AudioInputWave::Start(){
|
||||||
isRecording=true;
|
if(!isRecording){
|
||||||
|
isRecording=true;
|
||||||
MMRESULT res;
|
|
||||||
for(int i=0;i<4;i++){
|
MMRESULT res;
|
||||||
res=waveInPrepareHeader(hWaveIn, &buffers[i], sizeof(WAVEHDR));
|
for(int i=0;i<4;i++){
|
||||||
CHECK_ERROR(res, "waveInPrepareHeader failed");
|
res=waveInPrepareHeader(hWaveIn, &buffers[i], sizeof(WAVEHDR));
|
||||||
res=waveInAddBuffer(hWaveIn, &buffers[i], sizeof(WAVEHDR));
|
CHECK_ERROR(res, "waveInPrepareHeader failed");
|
||||||
CHECK_ERROR(res, "waveInAddBuffer 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(){
|
void AudioInputWave::Stop(){
|
||||||
isRecording=false;
|
if(isRecording){
|
||||||
|
isRecording=false;
|
||||||
MMRESULT res=waveInStop(hWaveIn);
|
|
||||||
CHECK_ERROR(res, "waveInStop failed");
|
MMRESULT res=waveInStop(hWaveIn);
|
||||||
res=waveInReset(hWaveIn);
|
CHECK_ERROR(res, "waveInStop failed");
|
||||||
CHECK_ERROR(res, "waveInReset failed");
|
res=waveInReset(hWaveIn);
|
||||||
for(int i=0;i<4;i++){
|
CHECK_ERROR(res, "waveInReset failed");
|
||||||
res=waveInUnprepareHeader(hWaveIn, &buffers[i], sizeof(WAVEHDR));
|
for(int i=0;i<4;i++){
|
||||||
CHECK_ERROR(res, "waveInUnprepareHeader failed");
|
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){
|
if(uMsg==WIM_DATA){
|
||||||
((AudioInputWave*)dwInstance)->OnData((WAVEHDR*)dwParam1);
|
((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(){
|
void AudioOutputWave::Start(){
|
||||||
isPlaying=true;
|
if(!isPlaying){
|
||||||
|
isPlaying=true;
|
||||||
for(int i=0;i<4;i++){
|
|
||||||
MMRESULT res=waveOutPrepareHeader(hWaveOut, &buffers[i], sizeof(WAVEHDR));
|
for(int i=0;i<4;i++){
|
||||||
CHECK_ERROR(res, "waveOutPrepareHeader failed");
|
MMRESULT res=waveOutPrepareHeader(hWaveOut, &buffers[i], sizeof(WAVEHDR));
|
||||||
//InvokeCallback((unsigned char*)buffers[i].lpData, buffers[i].dwBufferLength);
|
CHECK_ERROR(res, "waveOutPrepareHeader failed");
|
||||||
ZeroMemory(buffers[i].lpData, buffers[i].dwBufferLength);
|
//InvokeCallback((unsigned char*)buffers[i].lpData, buffers[i].dwBufferLength);
|
||||||
res=waveOutWrite(hWaveOut, &buffers[i], sizeof(WAVEHDR));
|
ZeroMemory(buffers[i].lpData, buffers[i].dwBufferLength);
|
||||||
CHECK_ERROR(res, "waveOutWrite failed");
|
res=waveOutWrite(hWaveOut, &buffers[i], sizeof(WAVEHDR));
|
||||||
|
CHECK_ERROR(res, "waveOutWrite failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioOutputWave::Stop(){
|
void AudioOutputWave::Stop(){
|
||||||
isPlaying=false;
|
if(isPlaying){
|
||||||
|
isPlaying=false;
|
||||||
|
|
||||||
MMRESULT res=waveOutReset(hWaveOut);
|
MMRESULT res=waveOutReset(hWaveOut);
|
||||||
CHECK_ERROR(res, "waveOutReset failed");
|
CHECK_ERROR(res, "waveOutReset failed");
|
||||||
for(int i=0;i<4;i++){
|
for(int i=0;i<4;i++){
|
||||||
res=waveOutUnprepareHeader(hWaveOut, &buffers[i], sizeof(WAVEHDR));
|
res=waveOutUnprepareHeader(hWaveOut, &buffers[i], sizeof(WAVEHDR));
|
||||||
CHECK_ERROR(res, "waveOutUnprepareHeader failed");
|
CHECK_ERROR(res, "waveOutUnprepareHeader failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user