From 3b0418a25f7c86b67f22bdfad42482649ff48402 Mon Sep 17 00:00:00 2001 From: John Lorentzson Date: Tue, 8 Apr 2025 22:00:54 +0200 Subject: [PATCH] some clean up and violent thrashing --- src/Backends/Audio/SoftwareMixer/Solaris.cpp | 51 ++++++-------------- 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/src/Backends/Audio/SoftwareMixer/Solaris.cpp b/src/Backends/Audio/SoftwareMixer/Solaris.cpp index 1b3f84cb..d9a9592f 100644 --- a/src/Backends/Audio/SoftwareMixer/Solaris.cpp +++ b/src/Backends/Audio/SoftwareMixer/Solaris.cpp @@ -17,7 +17,7 @@ #include #include -static const int samplesPerGo = 0x400; +static const int samplesPerGo = 0x200; static const int parkSignal = SIGUSR1; static pthread_t mainThread; static int sndfp; @@ -30,42 +30,28 @@ static void soundSetup() { static void* soundcheckthread(void*) { printf("Entered sound thread.\n"); - //sndfp = open("/dev/audio", 0, O_WRONLY); - audioDone = true; unsigned long for_as_long_as_it_seems_we_should = 0; - uint16_t out[samplesPerGo * 2]; bool firstTime = true; - int oldeof; + int counter = 0; while(1) { - //printf("Starting audio thread loop\n"); - bool ready = false; - audio_info_t audioInfo; - - //printf("eepy\n"); - usleep(for_as_long_as_it_seems_we_should); - //printf("i live again\n"); -/* - while(ready == false && firstTime == false) { - ioctl(sndfp, AUDIO_GETINFO, &audioInfo); - if(audioInfo.play.eof > oldeof) { - ready = true; - } - } -*/ long mix[samplesPerGo * 2]; memset(mix, 0, samplesPerGo * 2 * sizeof(long)); - //printf("Cleared mix buffer\n"); - // park the main thread since the game probably expects it to not be - // doing anything else while we're requesting audio frames. - audioDone = false; - //pthread_kill(mainThread, parkSignal); - //printf("Unparked thread\n"); parent_callback(mix, samplesPerGo); - // unpark the main thread now that we're not using game state anymore - audioDone = true; - //printf("Audio done\n"); + for_as_long_as_it_seems_we_should = ((float)(samplesPerGo) / (float)8000) * 1000000; + + audio_info_t audioInfo; + ioctl(sndfp, AUDIO_GETINFO, &audioInfo); + //printf("%d\n", audioInfo.play.error); + + if(counter > 4 && audioInfo.play.error == 0) { + usleep(for_as_long_as_it_seems_we_should); + } else { + printf("ae\n"); + audioInfo.play.error = 0; + ioctl(sndfp, AUDIO_SETINFO, &audioInfo); + } for(int i = 0; i < samplesPerGo * 2; i++) { //if(i % 2 == 0) { @@ -80,13 +66,8 @@ static void* soundcheckthread(void*) { fputc(sample & 0xFF, sndfile); //} } - //write(sndfp, mix, samplesPerGo * 2); - //write(sndfp, NULL, 0); - //ioctl(sndfp, AUDIO_GETINFO, &audioInfo); - //oldeof = audioInfo.play.eof; - - for_as_long_as_it_seems_we_should = ((float)(samplesPerGo - 0x7F) / (float)8000) * 1000000; + counter += 1; firstTime = false; } }