Fix bug when bgm.ogg doesn't exist
This commit is contained in:
@@ -464,6 +464,11 @@ bool load_preview(Entry_List_s list, int * preview_offset)
|
|||||||
Result load_audio(Entry_s entry, audio_s *audio)
|
Result load_audio(Entry_s entry, audio_s *audio)
|
||||||
{
|
{
|
||||||
audio->filesize = load_data("/bgm.ogg", entry, &audio->filebuf);
|
audio->filesize = load_data("/bgm.ogg", entry, &audio->filebuf);
|
||||||
|
if (audio->filesize == 0) {
|
||||||
|
free(audio);
|
||||||
|
DEBUG("File not found!\n");
|
||||||
|
return MAKERESULT(RL_FATAL, RS_NOTFOUND, RM_APPLICATION, RD_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
audio->mix[0] = audio->mix[1] = 1.0f; // Determines volume for the 12 (?) different outputs. See http://smealum.github.io/ctrulib/channel_8h.html#a30eb26f1972cc3ec28370263796c0444
|
audio->mix[0] = audio->mix[1] = 1.0f; // Determines volume for the 12 (?) different outputs. See http://smealum.github.io/ctrulib/channel_8h.html#a30eb26f1972cc3ec28370263796c0444
|
||||||
|
|
||||||
@@ -496,7 +501,7 @@ Result load_audio(Entry_s entry, audio_s *audio)
|
|||||||
} else {
|
} else {
|
||||||
free(audio->filebuf);
|
free(audio->filebuf);
|
||||||
free(audio);
|
free(audio);
|
||||||
DEBUG("File not found!\n");
|
DEBUG("fmemopen failed!\n");
|
||||||
return MAKERESULT(RL_FATAL, RS_NOTFOUND, RM_APPLICATION, RD_NOT_FOUND);
|
return MAKERESULT(RL_FATAL, RS_NOTFOUND, RM_APPLICATION, RD_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -438,8 +438,8 @@ int main(void)
|
|||||||
if(current_mode == MODE_THEMES)
|
if(current_mode == MODE_THEMES)
|
||||||
{
|
{
|
||||||
audio = calloc(1, sizeof(audio_s));
|
audio = calloc(1, sizeof(audio_s));
|
||||||
load_audio(current_list->entries[current_list->selected_entry], audio);
|
Result r = load_audio(current_list->entries[current_list->selected_entry], audio);
|
||||||
play_audio(audio);
|
if (R_SUCCEEDED(r)) play_audio(audio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user