clear on pause

This commit is contained in:
2025-05-08 23:50:01 -05:00
parent 101fcf4781
commit 53695cbc60
2 changed files with 43 additions and 2 deletions

View File

@@ -249,6 +249,40 @@
};
ChatServerVoice = pkgs.stdenvNoCC.mkDerivation {
name = "ChatServerVoice";
src = ./.;
nativeBuildInputs = with pkgs; [
clang
];
buildInputs = with pkgs; [
gamenetworkingsockets
];
buildPhase = ''
clang++ \
modules/examples/ChatServerVoice/src/*.cpp \
modules/ServerModule/src/*.cpp \
-fpic -shared \
-I ${pkgs.gamenetworkingsockets}/include/GameNetworkingSockets \
-I src -I include -I . \
-lGameNetworkingSockets \
-DCHATSERVERVOICE_DYNAMIC \
-Wall \
-o $name
'';
installPhase = ''
mkdir -p $out/bin
cp $name $out/bin
'';
};
ChatClient = pkgs.stdenvNoCC.mkDerivation {
name = "ChatClient";

View File

@@ -132,6 +132,7 @@ void ChatClientVoice::run() {
SDL_SetAudioStreamGain(mic, micVol);
} else if(!cm->isConnected()) {
SDL_PauseAudioStreamDevice(mic);
SDL_ClearAudioStream(mic);
}
if(!SDL_AudioStreamDevicePaused(speaker)) {
@@ -142,6 +143,8 @@ void ChatClientVoice::run() {
SDL_SetAudioStreamGain(speaker, speakerVol);
} else if(!cm->isConnected()) {
SDL_PauseAudioStreamDevice(speaker);
SDL_ClearAudioStream(speaker);
}
static int avail = 0;
@@ -157,8 +160,10 @@ void ChatClientVoice::run() {
// if not testing, send to server.
avail = SDL_min(len, SDL_GetAudioStreamAvailable(mic));
avail = SDL_GetAudioStreamData(mic, buf, avail);
//cm->sendReliable(buf, avail);
if(avail > 10) {
avail = SDL_GetAudioStreamData(mic, buf, avail);
cm->sendReliable(buf, avail);
}
}
@@ -212,6 +217,8 @@ bool ChatClientVoice::onEvent(const Archimedes::Event& event) {
SDL_PauseAudioStreamDevice(mic);
SDL_PauseAudioStreamDevice(speaker);
SDL_ClearAudioStream(mic);
SDL_ClearAudioStream(speaker);
break;
}