uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit a05fc3ae5dce17f4702bff5ca81a0e98d5177ec5
parent 4da5e165012567f07a91f6cb439d9a137729ec15
Author: neauoire <aliceffekt@gmail.com>
Date:   Wed,  4 Aug 2021 10:05:11 -0700

Merge branch 'master' of git.sr.ht:~rabbits/uxn

Diffstat:
Msrc/uxnemu.c | 28++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -168,10 +168,24 @@ static int init(void) { SDL_AudioSpec as; + SDL_zero(as); + as.freq = SAMPLE_FREQUENCY; + as.format = AUDIO_S16; + as.channels = 2; + as.callback = audio_callback; + as.samples = 512; + as.userdata = NULL; if(!ppu_init(&ppu, 64, 40)) return error("ppu", "Init failure"); - if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) - return error("sdl", SDL_GetError()); + if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) { + error("sdl", SDL_GetError()); + if(SDL_Init(SDL_INIT_VIDEO) < 0) + return error("sdl", SDL_GetError()); + } else { + audio_id = SDL_OpenAudioDevice(NULL, 0, &as, NULL, 0); + if(!audio_id) + error("sdl_audio", SDL_GetError()); + } gWindow = SDL_CreateWindow("Uxn", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom, SDL_WINDOW_SHOWN); if(gWindow == NULL) return error("sdl_window", SDL_GetError()); @@ -196,16 +210,6 @@ init(void) ppu.pixels = idxSurface->pixels; SDL_StartTextInput(); SDL_ShowCursor(SDL_DISABLE); - SDL_zero(as); - as.freq = SAMPLE_FREQUENCY; - as.format = AUDIO_S16; - as.channels = 2; - as.callback = audio_callback; - as.samples = 512; - as.userdata = NULL; - audio_id = SDL_OpenAudioDevice(NULL, 0, &as, NULL, 0); - if(!audio_id) - error("sdl_audio", SDL_GetError()); return 1; }