Skip to content

Commit

Permalink
Fix for raw audio output on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
synesthesiam committed Nov 6, 2023
1 parent 1d3e8b2 commit 91b8d42
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
#include <windows.h>
#endif

#ifdef _WIN32
#include <io.h>
#include <fcntl.h>
#endif

#ifdef __APPLE__
#include <mach-o/dyld.h>
#endif
Expand Down Expand Up @@ -307,6 +312,12 @@ int main(int argc, char *argv[]) {
vector<int16_t> audioBuffer;
vector<int16_t> sharedAudioBuffer;

#ifdef _WIN32
// Needed on Windows to avoid terminal conversions
setmode(fileno(stdout),O_BINARY);
setmode(fileno(stdin),O_BINARY);
#endif

thread rawOutputThread(rawOutputProc, ref(sharedAudioBuffer),
ref(mutAudio), ref(cvAudio), ref(audioReady),
ref(audioFinished));
Expand Down

0 comments on commit 91b8d42

Please sign in to comment.