Change: DOS music loading for non-Windows music drivers
This commit is contained in:
committed by
Michael Lutz
parent
458e441a4c
commit
a8080f14a9
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user