From 18735d4aea12e1d311646d884ab9d04e2fcae3c3 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Thu, 2 Feb 2017 14:43:39 +0800 Subject: [PATCH] [Bug Fix] MusicManager Bug Fixed in MusicManager. Now the sample code can play the music. --- App.cpp | 11 ++++++++--- MusicManager.cpp | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/App.cpp b/App.cpp index c9cd26d..4259cf3 100644 --- a/App.cpp +++ b/App.cpp @@ -20,9 +20,14 @@ namespace App rnd.update(); MusicPlayer player; - Music m("res/music.mp3"); - player.add(m,-1); - player.play(); + Music m; + int ret=m.load("res/music.mp3"); + printf("ret=%d\n",ret); + ret=player.add(m,-1); + printf("ret=%d\n",ret); + ret=player.play(); + printf("ret=%d\n",ret); + printf("%s\n",Mix_GetError()); while(1) SDL_PollEvent(0); diff --git a/MusicManager.cpp b/MusicManager.cpp index 3ceb088..964c30e 100644 --- a/MusicManager.cpp +++ b/MusicManager.cpp @@ -25,8 +25,10 @@ int Music::load(const char* MusicFileName) } int Music::unload() { + printf("Unloaded.\n"); if(pimpl->sMusic.get()) { + printf("Reset to NULL\n"); pimpl->sMusic.reset(); return 0; } @@ -38,7 +40,7 @@ bool Music::ready() } Music::~Music() { - unload(); + }