mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2025-08-08 08:35:40 +02:00
Merge pull request #290 from Detanup01/voicechat-fix
fix VoiceSystem initialization
This commit is contained in:
commit
1d2e40f29b
2 changed files with 10 additions and 8 deletions
|
@ -1,12 +1,14 @@
|
||||||
#include "dll/voicechat.h"
|
#include "dll/voicechat.h"
|
||||||
|
|
||||||
|
static std::atomic<bool> isInited{ false };
|
||||||
|
|
||||||
bool VoiceChat::InitVoiceSystem() {
|
bool VoiceChat::InitVoiceSystem() {
|
||||||
static std::atomic<int> initCount{ 0 };
|
if (!isInited) {
|
||||||
if (initCount++ == 0) {
|
|
||||||
if (Pa_Initialize() != paNoError) {
|
if (Pa_Initialize() != paNoError) {
|
||||||
PRINT_DEBUG("PortAudio initialization failed");
|
PRINT_DEBUG("PortAudio initialization failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
isInited = true;
|
||||||
}
|
}
|
||||||
isRecording = false;
|
isRecording = false;
|
||||||
isPlaying = false;
|
isPlaying = false;
|
||||||
|
@ -17,9 +19,9 @@ bool VoiceChat::InitVoiceSystem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoiceChat::ShutdownVoiceSystem() {
|
void VoiceChat::ShutdownVoiceSystem() {
|
||||||
static std::atomic<int> initCount{ 1 };
|
if (isInited) {
|
||||||
if (--initCount == 0) {
|
|
||||||
Pa_Terminate();
|
Pa_Terminate();
|
||||||
|
isInited = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue