1
0
Fork 0
mirror of https://github.com/Detanup01/gbe_fork.git synced 2025-08-08 00:25:38 +02:00

Merge pull request #290 from Detanup01/voicechat-fix

fix VoiceSystem initialization
This commit is contained in:
Detanup01 2025-07-20 20:56:56 +02:00 committed by GitHub
commit 1d2e40f29b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 8 deletions

View file

@ -1,12 +1,14 @@
#include "dll/voicechat.h"
static std::atomic<bool> isInited{ false };
bool VoiceChat::InitVoiceSystem() {
static std::atomic<int> initCount{ 0 };
if (initCount++ == 0) {
if (!isInited) {
if (Pa_Initialize() != paNoError) {
PRINT_DEBUG("PortAudio initialization failed");
return false;
}
isInited = true;
}
isRecording = false;
isPlaying = false;
@ -17,9 +19,9 @@ bool VoiceChat::InitVoiceSystem() {
}
void VoiceChat::ShutdownVoiceSystem() {
static std::atomic<int> initCount{ 1 };
if (--initCount == 0) {
if (isInited) {
Pa_Terminate();
isInited = false;
}
}