summaryrefslogtreecommitdiff
path: root/src/music/cocoa_m.cpp
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2018-03-21 17:12:29 +0100
committerMichael Lutz <michi@icosahedron.de>2018-06-05 22:58:35 +0200
commita8080f14a9c75a1175976ee8d0cd17c677b55119 (patch)
treedc57362c439d6958f01c680f8f538da28fd3bf4e /src/music/cocoa_m.cpp
parent458e441a4ca5d451941958e056189a059f2eee76 (diff)
downloadopenttd-a8080f14a9c75a1175976ee8d0cd17c677b55119.tar.xz
Change: DOS music loading for non-Windows music drivers
Diffstat (limited to 'src/music/cocoa_m.cpp')
-rw-r--r--src/music/cocoa_m.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/music/cocoa_m.cpp b/src/music/cocoa_m.cpp
index 9dcd12cf0..8d97aedf0 100644
--- a/src/music/cocoa_m.cpp
+++ b/src/music/cocoa_m.cpp
@@ -18,6 +18,7 @@
#include "../stdafx.h"
#include "../os/macosx/macos.h"
#include "cocoa_m.h"
+#include "midifile.hpp"
#include "../debug.h"
#include "../base_media_base.h"
@@ -142,13 +143,13 @@ void MusicDriver_Cocoa::Stop()
/**
* Starts playing a new song.
*
- * @param filename Path to a MIDI file.
+ * @param song Description of music to load and play
*/
void MusicDriver_Cocoa::PlaySong(const MusicSongInfo &song)
{
- if (song.filetype != MTT_STANDARDMIDI) return;
+ std::string filename = MidiFile::GetSMFFile(song);
- DEBUG(driver, 2, "cocoa_m: trying to play '%s'", filename);
+ DEBUG(driver, 2, "cocoa_m: trying to play '%s'", filename.c_str());
this->StopSong();
if (_sequence != NULL) {
@@ -156,12 +157,14 @@ void MusicDriver_Cocoa::PlaySong(const MusicSongInfo &song)
_sequence = NULL;
}
+ if (filename.empty()) return;
+
if (NewMusicSequence(&_sequence) != noErr) {
DEBUG(driver, 0, "cocoa_m: Failed to create music sequence");
return;
}
- const char *os_file = OTTD2FS(song.filename);
+ const char *os_file = OTTD2FS(filename.c_str());
CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8*)os_file, strlen(os_file), false);
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
@@ -221,7 +224,7 @@ void MusicDriver_Cocoa::PlaySong(const MusicSongInfo &song)
if (MusicPlayerStart(_player) != noErr) return;
_playing = true;
- DEBUG(driver, 3, "cocoa_m: playing '%s'", filename);
+ DEBUG(driver, 3, "cocoa_m: playing '%s'", filename.c_str());
}