summaryrefslogtreecommitdiff
path: root/src/music/dmusic.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/music/dmusic.cpp')
-rw-r--r--src/music/dmusic.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp
index 4b9a22c72..bf8657ef4 100644
--- a/src/music/dmusic.cpp
+++ b/src/music/dmusic.cpp
@@ -19,7 +19,7 @@
#include "../debug.h"
#include "../os/windows/win32.h"
#include "../core/mem_func.hpp"
-#include "../thread/thread.h"
+#include "../thread.h"
#include "../fileio_func.h"
#include "../base_media_base.h"
#include "dmusic.h"
@@ -139,7 +139,7 @@ static struct {
} _playback;
/** Handle to our worker thread. */
-static ThreadObject *_dmusic_thread = NULL;
+static std::thread _dmusic_thread;
/** Event to signal the thread that it should look at a state change. */
static HANDLE _thread_event = NULL;
/** Lock access to playback data that is not thread-safe. */
@@ -597,7 +597,7 @@ static void TransmitNotesOff(IDirectMusicBuffer *buffer, REFERENCE_TIME block_ti
Sleep(Clamp((block_time - cur_time) / MS_TO_REFTIME, 5, 1000));
}
-static void MidiThreadProc(void *)
+static void MidiThreadProc()
{
DEBUG(driver, 2, "DMusic: Entering playback thread");
@@ -1169,7 +1169,7 @@ const char *MusicDriver_DMusic::Start(const char * const *parm)
_thread_event = CreateEvent(NULL, FALSE, FALSE, NULL);
if (_thread_event == NULL) return "Can't create thread shutdown event";
- if (!ThreadObject::New(&MidiThreadProc, this, &_dmusic_thread, "ottd:dmusic")) return "Can't create MIDI output thread";
+ if (!StartNewThread(&_dmusic_thread, "ottd:dmusic", &MidiThreadProc)) return "Can't create MIDI output thread";
return NULL;
}
@@ -1183,10 +1183,10 @@ MusicDriver_DMusic::~MusicDriver_DMusic()
void MusicDriver_DMusic::Stop()
{
- if (_dmusic_thread != NULL) {
+ if (_dmusic_thread.joinable()) {
_playback.shutdown = true;
SetEvent(_thread_event);
- _dmusic_thread->Join();
+ _dmusic_thread.join();
}
/* Unloaded any instruments we loaded. */