From 0c85df67171638e52241595237bbfbd6d183581a Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 7 Apr 2013 18:04:27 +0000 Subject: [PATCH] audio: don't die when failing to load a sample with SDL. --- src/sample.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/sample.cpp b/src/sample.cpp index 3cf74aa3..2f91709c 100644 --- a/src/sample.cpp +++ b/src/sample.cpp @@ -112,11 +112,7 @@ Sample::Sample(char const *path) } if (!data->m_chunk) { -#if !LOL_RELEASE Log::Error("could not load sample %s\n", path); -#endif - SDL_Quit(); - exit(1); } data->m_channel = -1; #endif @@ -127,7 +123,8 @@ Sample::~Sample() #if __CELLOS_LV2__ /* Nothing to do */ #elif defined USE_SDL_MIXER - Mix_FreeChunk(data->m_chunk); + if (data->m_chunk) + Mix_FreeChunk(data->m_chunk); #endif delete data; } @@ -174,7 +171,8 @@ void Sample::Play() CELL_MS_SPEAKER_FR, CELL_MS_CHANNEL_0, 1.0f); cellMSStreamPlay(data->m_channel); #elif defined USE_SDL_MIXER - data->m_channel = Mix_PlayChannel(-1, data->m_chunk, 0); + if (data->m_chunk) + data->m_channel = Mix_PlayChannel(-1, data->m_chunk, 0); #endif } @@ -184,7 +182,8 @@ void Sample::Loop() /* FIXME: not implemented */ Play(); #elif defined USE_SDL_MIXER - data->m_channel = Mix_PlayChannel(-1, data->m_chunk, -1); + if (data->m_chunk) + data->m_channel = Mix_PlayChannel(-1, data->m_chunk, -1); #endif }