(svn r25268) -Codechange: [Win32] Simplify resource deallocation in case initializing the DirectMusic driver fails.

pull/155/head
michi_cc 12 years ago
parent 5eb7ec17b7
commit 4afea75116

@ -82,24 +82,16 @@ const char *MusicDriver_DMusic::Start(const char * const *parm)
IID_IDirectMusicPerformance, IID_IDirectMusicPerformance,
(LPVOID*)&performance (LPVOID*)&performance
))) { ))) {
proc.CoUninitialize();
return "Failed to create the performance object"; return "Failed to create the performance object";
} }
/* initialize it */ /* initialize it */
if (FAILED(performance->Init(NULL, NULL, NULL))) { if (FAILED(performance->Init(NULL, NULL, NULL))) {
performance->Release();
performance = NULL;
proc.CoUninitialize();
return "Failed to initialize performance object"; return "Failed to initialize performance object";
} }
/* choose default Windows synth */ /* choose default Windows synth */
if (FAILED(performance->AddPort(NULL))) { if (FAILED(performance->AddPort(NULL))) {
performance->CloseDown();
performance->Release();
performance = NULL;
proc.CoUninitialize();
return "AddPort failed"; return "AddPort failed";
} }
@ -111,10 +103,6 @@ const char *MusicDriver_DMusic::Start(const char * const *parm)
IID_IDirectMusicLoader, IID_IDirectMusicLoader,
(LPVOID*)&loader (LPVOID*)&loader
))) { ))) {
performance->CloseDown();
performance->Release();
performance = NULL;
proc.CoUninitialize();
return "Failed to create loader object"; return "Failed to create loader object";
} }
@ -122,6 +110,12 @@ const char *MusicDriver_DMusic::Start(const char * const *parm)
} }
MusicDriver_DMusic::~MusicDriver_DMusic()
{
this->Stop();
}
void MusicDriver_DMusic::Stop() void MusicDriver_DMusic::Stop()
{ {
seeking = false; seeking = false;

@ -17,6 +17,8 @@
/** Music player making use of DirectX. */ /** Music player making use of DirectX. */
class MusicDriver_DMusic: public MusicDriver { class MusicDriver_DMusic: public MusicDriver {
public: public:
virtual ~MusicDriver_DMusic();
/* virtual */ const char *Start(const char * const *param); /* virtual */ const char *Start(const char * const *param);
/* virtual */ void Stop(); /* virtual */ void Stop();

Loading…
Cancel
Save