From 5900e3bb6e3fba79b83298a257ef03e1a54ad802 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 17 Jan 2022 14:36:40 -0500 Subject: [PATCH] extra error messages for audio init fail --- src/audio/sdl.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/audio/sdl.cpp b/src/audio/sdl.cpp index 872432c9..ff073838 100644 --- a/src/audio/sdl.cpp +++ b/src/audio/sdl.cpp @@ -1,4 +1,5 @@ #include +#include "../ta-log.h" #include "sdl.h" void taSDLProcess(void* inst, unsigned char* buf, int nframes) { @@ -49,8 +50,14 @@ bool TAAudioSDL::setRun(bool run) { } bool TAAudioSDL::init(TAAudioDesc& request, TAAudioDesc& response) { - if (initialized) return false; - if (SDL_Init(SDL_INIT_AUDIO)<0) return false; + if (initialized) { + logE("audio already initialized\n"); + return false; + } + if (SDL_Init(SDL_INIT_AUDIO)<0) { + logE("could not initialize SDL\n"); + return false; + } desc=request; desc.outFormat=TA_AUDIO_FORMAT_F32; @@ -63,7 +70,10 @@ bool TAAudioSDL::init(TAAudioDesc& request, TAAudioDesc& response) { ac.userdata=this; ai=SDL_OpenAudioDevice(NULL,0,&ac,&ar,SDL_AUDIO_ALLOW_FREQUENCY_CHANGE); - if (ai==0) return false; + if (ai==0) { + logE("could not open audio device: %s\n",SDL_GetError()); + return false; + } desc.name=""; desc.rate=ar.freq;