void continue_sb() { if (!AudioDevice) return ; init_soundcard() ; // outp(audio.picport+1,inp(audio.picport+1)&~audio.maskirq) ; // dma_play() ; }
void init_sound(void) { int audiodevice ; char *ptr ; init_record() ; if (!isSound) return ; audiodevice = detect_audiodevice() ; if (!audiodevice) { printf("Unable to found any suported soundcard.\n") ; isSound = FALSE ; return ; } if (!allocdosmem(samples_to_generate*2+65536+32, &lowmemsample)) { printf("*** Can't allocate lowmem area for sound emulation.\n") ; isSound = FALSE ; return ; } if (isMIDI&&(audiodevice == AUDIODEVICE_SOUNDBLASTER)) { printf("ST MIDI emulation enabled.\n") ; isSound = FALSE ; return ; } isMIDI = FALSE ; ptr = (char *)((lowmemsample.linear_base+65536)&0xffff0000) ; audio_buffer1 = ptr ; audio_buffer2 = audio_buffer1 + samples_to_generate ; memset(audio_buffer1,0x80,(samples_to_generate*2)+32) ; AudioDevice = audiodevice ; Reset_Sound() ; Ym2149Init() ; init_soundcard() ; if (AudioDevice == AUDIODEVICE_SOUNDBLASTER) { audio.vector = (audio.irq<8) ? audio.irq+8 : audio.irq+0x68 ; audio.picport= (audio.irq<8) ? 0x20 : 0xa0 ; audio.maskirq=1<<(audio.irq&7) ; prev_sound_handler = _dos_getvect(audio.vector) ; _dos_setvect(audio.vector,inthandler) ; outp(audio.picport+1,inp(audio.picport+1)&~audio.maskirq) ; } pause_sound() ; printf("soundchip emulation initialized. (c) Arnaud Carre.\n") ; if (isSamples) printf("STF samples support added (still *very* buggy - you've been warned)\n") ; else printf("no STF samples support.\n") ; printf("MIDI emulation disabled.\n") ; }
// Video thread void* threadVideo(void* _arg) { intptr_t exit_code = 0; Runtime* runtime = (Runtime*)_arg; CodecEngine* ce; FBOutput* fb; int res = 0; struct timespec last_fps_report_time; ImageDescription srcImageDesc; ImageDescription dstImageDesc; if (runtime == NULL) { exit_code = EINVAL; goto exit; } if ((ce = runtimeModCodecEngine(runtime)) == NULL || (fb = runtimeModFBOutput(runtime)) == NULL) { exit_code = EINVAL; goto exit; } if ((res = codecEngineOpen(ce, runtimeCfgCodecEngine(runtime))) != 0) { fprintf(stderr, "codecEngineOpen() failed: %d\n", res); exit_code = res; goto exit; } if ((res = fbOutputOpen(fb, runtimeCfgFBOutput(runtime))) != 0) { fprintf(stderr, "fbOutputOpen() failed: %d\n", res); exit_code = res; goto exit_ce_close; } if ((res = fbOutputGetFormat(fb, &dstImageDesc)) != 0) { fprintf(stderr, "fbOutputGetFormat() failed: %d\n", res); exit_code = res; goto exit_fb_close; } memcpy(&srcImageDesc, &dstImageDesc, sizeof(srcImageDesc)); srcImageDesc.m_format = ImageSourceFormat; srcImageDesc.m_imageSize = FrameSourceSize; if ((res = codecEngineStart(ce, runtimeCfgCodecEngine(runtime), &srcImageDesc, &dstImageDesc)) != 0) { fprintf(stderr, "codecEngineStart() failed: %d\n", res); exit_code = res; goto exit_fb_close; } if ((res = fbOutputStart(fb)) != 0) { fprintf(stderr, "fbOutputStart() failed: %d\n", res); exit_code = res; goto exit_ce_close; } if ((res = clock_gettime(CLOCK_MONOTONIC, &last_fps_report_time)) != 0) { fprintf(stderr, "clock_gettime(CLOCK_MONOTONIC) failed: %d\n", errno); exit_code = res; goto exit_fb_stop; } printf("Open default soundcard\n"); init_soundcard(); printf("Entering video thread loop\n"); while (!runtimeGetTerminate(runtime)) { struct timespec now; long long last_fps_report_elapsed_ms; if ((res = clock_gettime(CLOCK_MONOTONIC, &now)) != 0) { fprintf(stderr, "clock_gettime(CLOCK_MONOTONIC) failed: %d\n", errno); exit_code = res; goto exit_fb_stop; } last_fps_report_elapsed_ms = (now.tv_sec - last_fps_report_time.tv_sec )*1000 + (now.tv_nsec - last_fps_report_time.tv_nsec)/1000000; if (last_fps_report_elapsed_ms >= 10*1000) { last_fps_report_time.tv_sec += 10; if ((res = codecEngineReportLoad(ce, last_fps_report_elapsed_ms)) != 0) fprintf(stderr, "codecEngineReportLoad() failed: %d\n", res); if ((res = InputReportFPS(last_fps_report_elapsed_ms)) != 0) fprintf(stderr, "InputReportFPS() failed: %d\n", res); } if ((res = threadVideoSelectLoop(runtime, ce, fb)) != 0) { fprintf(stderr, "threadVideoSelectLoop() failed: %d\n", res); exit_code = res; goto exit_fb_stop; } } printf("Left video thread loop\n"); exit_fb_stop: if ((res = fbOutputStop(fb)) != 0) fprintf(stderr, "fbOutputStop() failed: %d\n", res); exit_ce_stop: if ((res = codecEngineStop(ce)) != 0) fprintf(stderr, "codecEngineStop() failed: %d\n", res); exit_fb_close: if ((res = fbOutputClose(fb)) != 0) fprintf(stderr, "fbOutputClose() failed: %d\n", res); exit_ce_close: if ((res = codecEngineClose(ce)) != 0) fprintf(stderr, "codecEngineClose() failed: %d\n", res); exit: runtimeSetTerminate(runtime); printf("Close default soundcard\n"); close_soundcard(); return (void*)exit_code; }