diff --git a/src/Backends/Audio/SoftwareMixer/Solaris.cpp b/src/Backends/Audio/SoftwareMixer/Solaris.cpp index 19fdb72d..b4fe24cb 100644 --- a/src/Backends/Audio/SoftwareMixer/Solaris.cpp +++ b/src/Backends/Audio/SoftwareMixer/Solaris.cpp @@ -24,39 +24,58 @@ static void (*parent_callback)(long *stream, size_t frames_total); static bool audioDone = false; static void* soundcheckthread(void*) { + printf("Entered sound thread.\n"); + //sndfp = open("/dev/audio", 0, O_WRONLY); + FILE* sndfile = fopen("/dev/audio", "wb"); + audioDone = true; unsigned long for_as_long_as_it_seems_we_should = 0; uint16_t out[0x400 * 2]; + bool firstTime = true; + int oldeof; while(1) { + //printf("Starting audio thread loop\n"); bool ready = false; audio_info_t audioInfo; - ioctl(sndfp, AUDIO_GETINFO, &audioInfo); - int oldeof = audioInfo.play.eof; + //printf("eepy\n"); usleep(for_as_long_as_it_seems_we_should); - - while(ready == false) { + //printf("i live again\n"); +/* + while(ready == false && firstTime == false) { ioctl(sndfp, AUDIO_GETINFO, &audioInfo); if(audioInfo.play.eof > oldeof) { ready = true; } } - +*/ long mix[0x400 * 2]; - memset(mix, 0, 0x400 * 2); - + memset(mix, 0, 0x400 * 2 * 4); + //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); + //pthread_kill(mainThread, parkSignal); + //printf("Unparked thread\n"); - parent_callback(mix, 0x400 * 2); + parent_callback(mix, 0x400); // unpark the main thread now that we're not using game state anymore audioDone = true; + //printf("Audio done\n"); - write(sndfp, mix, 0x400 * 2); + for(int i = 0; i < 0x400 * 2; i++) { + if(i % 2 == 0) { + fputc((mix[i] >> 8) & 0xFF, sndfile); + } + } + //write(sndfp, mix, 0x400 * 2); + //write(sndfp, NULL, 0); - for_as_long_as_it_seems_we_should = (0x400 / 48000) * 1000000; + ioctl(sndfp, AUDIO_GETINFO, &audioInfo); + oldeof = audioInfo.play.eof; + + for_as_long_as_it_seems_we_should = ((float)0x400 / (float)8000) * 1000000; + firstTime = false; } } @@ -65,6 +84,7 @@ static void threadPark(int signo) { } unsigned long SoftwareMixerBackend_Init(void (*callback)(long *stream, size_t frames_total)) { + parent_callback = callback; sndfp = open("/dev/audio", 0, O_WRONLY); if(sndfp == -1) { @@ -81,9 +101,11 @@ unsigned long SoftwareMixerBackend_Init(void (*callback)(long *stream, size_t fr info.precision = 8; info.encoding = AUDIO_ENCODING_LINEAR; info.port = AUDIO_SPEAKER; + info.gain = 32; audioInfo.play = info; ioctl(sndfp, AUDIO_SETINFO, &audioInfo); + close(sndfp); if(signal(parkSignal, threadPark) == SIG_ERR) { Backend_PrintError("Failed to register thread park signal handler for audio system.\n"); diff --git a/src/Draw.cpp b/src/Draw.cpp index 46ee4f17..a57caeb2 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -73,7 +73,7 @@ BOOL Flip_SystemTask(void) // Framerate limiter timeNow = Backend_GetTicks(); - + //break; if (timeNow >= timePrev + 20) break;