summaryrefslogtreecommitdiff
path: root/src/music
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2013-05-20 13:35:38 +0000
committermichi_cc <michi_cc@openttd.org>2013-05-20 13:35:38 +0000
commita959f0c23e49afe47ad542fb01252bb3a6c58c4b (patch)
treecac20dfae1ba86fcb6e3ee33dc4499d02d292271 /src/music
parented858c08ca74f15a825aba3c5bccf0dbf9a17d3e (diff)
downloadopenttd-a959f0c23e49afe47ad542fb01252bb3a6c58c4b.tar.xz
(svn r25268) -Codechange: [Win32] Simplify resource deallocation in case initializing the DirectMusic driver fails.
Diffstat (limited to 'src/music')
-rw-r--r--src/music/dmusic.cpp18
-rw-r--r--src/music/dmusic.h2
2 files changed, 8 insertions, 12 deletions
diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp
index cb255e7c0..152bbb249 100644
--- a/src/music/dmusic.cpp
+++ b/src/music/dmusic.cpp
@@ -82,24 +82,16 @@ const char *MusicDriver_DMusic::Start(const char * const *parm)
IID_IDirectMusicPerformance,
(LPVOID*)&performance
))) {
- proc.CoUninitialize();
return "Failed to create the performance object";
}
/* initialize it */
if (FAILED(performance->Init(NULL, NULL, NULL))) {
- performance->Release();
- performance = NULL;
- proc.CoUninitialize();
return "Failed to initialize performance object";
}
/* choose default Windows synth */
if (FAILED(performance->AddPort(NULL))) {
- performance->CloseDown();
- performance->Release();
- performance = NULL;
- proc.CoUninitialize();
return "AddPort failed";
}
@@ -111,10 +103,6 @@ const char *MusicDriver_DMusic::Start(const char * const *parm)
IID_IDirectMusicLoader,
(LPVOID*)&loader
))) {
- performance->CloseDown();
- performance->Release();
- performance = NULL;
- proc.CoUninitialize();
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()
{
seeking = false;
diff --git a/src/music/dmusic.h b/src/music/dmusic.h
index b3fc99610..29eee8ed0 100644
--- a/src/music/dmusic.h
+++ b/src/music/dmusic.h
@@ -17,6 +17,8 @@
/** Music player making use of DirectX. */
class MusicDriver_DMusic: public MusicDriver {
public:
+ virtual ~MusicDriver_DMusic();
+
/* virtual */ const char *Start(const char * const *param);
/* virtual */ void Stop();