Add barely working sound for Solaris (screams like hell)
This commit is contained in:
parent
b0f8744c4a
commit
ffdd2d5d7f
2 changed files with 34 additions and 12 deletions
|
@ -24,39 +24,58 @@ static void (*parent_callback)(long *stream, size_t frames_total);
|
||||||
static bool audioDone = false;
|
static bool audioDone = false;
|
||||||
|
|
||||||
static void* soundcheckthread(void*) {
|
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;
|
unsigned long for_as_long_as_it_seems_we_should = 0;
|
||||||
uint16_t out[0x400 * 2];
|
uint16_t out[0x400 * 2];
|
||||||
|
bool firstTime = true;
|
||||||
|
int oldeof;
|
||||||
while(1) {
|
while(1) {
|
||||||
|
//printf("Starting audio thread loop\n");
|
||||||
bool ready = false;
|
bool ready = false;
|
||||||
audio_info_t audioInfo;
|
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);
|
usleep(for_as_long_as_it_seems_we_should);
|
||||||
|
//printf("i live again\n");
|
||||||
while(ready == false) {
|
/*
|
||||||
|
while(ready == false && firstTime == false) {
|
||||||
ioctl(sndfp, AUDIO_GETINFO, &audioInfo);
|
ioctl(sndfp, AUDIO_GETINFO, &audioInfo);
|
||||||
if(audioInfo.play.eof > oldeof) {
|
if(audioInfo.play.eof > oldeof) {
|
||||||
ready = true;
|
ready = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
long mix[0x400 * 2];
|
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
|
// park the main thread since the game probably expects it to not be
|
||||||
// doing anything else while we're requesting audio frames.
|
// doing anything else while we're requesting audio frames.
|
||||||
audioDone = false;
|
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
|
// unpark the main thread now that we're not using game state anymore
|
||||||
audioDone = true;
|
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)) {
|
unsigned long SoftwareMixerBackend_Init(void (*callback)(long *stream, size_t frames_total)) {
|
||||||
|
parent_callback = callback;
|
||||||
sndfp = open("/dev/audio", 0, O_WRONLY);
|
sndfp = open("/dev/audio", 0, O_WRONLY);
|
||||||
|
|
||||||
if(sndfp == -1) {
|
if(sndfp == -1) {
|
||||||
|
@ -81,9 +101,11 @@ unsigned long SoftwareMixerBackend_Init(void (*callback)(long *stream, size_t fr
|
||||||
info.precision = 8;
|
info.precision = 8;
|
||||||
info.encoding = AUDIO_ENCODING_LINEAR;
|
info.encoding = AUDIO_ENCODING_LINEAR;
|
||||||
info.port = AUDIO_SPEAKER;
|
info.port = AUDIO_SPEAKER;
|
||||||
|
info.gain = 32;
|
||||||
|
|
||||||
audioInfo.play = info;
|
audioInfo.play = info;
|
||||||
ioctl(sndfp, AUDIO_SETINFO, &audioInfo);
|
ioctl(sndfp, AUDIO_SETINFO, &audioInfo);
|
||||||
|
close(sndfp);
|
||||||
|
|
||||||
if(signal(parkSignal, threadPark) == SIG_ERR) {
|
if(signal(parkSignal, threadPark) == SIG_ERR) {
|
||||||
Backend_PrintError("Failed to register thread park signal handler for audio system.\n");
|
Backend_PrintError("Failed to register thread park signal handler for audio system.\n");
|
||||||
|
|
|
@ -73,7 +73,7 @@ BOOL Flip_SystemTask(void)
|
||||||
|
|
||||||
// Framerate limiter
|
// Framerate limiter
|
||||||
timeNow = Backend_GetTicks();
|
timeNow = Backend_GetTicks();
|
||||||
|
//break;
|
||||||
if (timeNow >= timePrev + 20)
|
if (timeNow >= timePrev + 20)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue