#include <AvailabilityMacros.h>
#include <QuickTime/QuickTime.h>
#include "../stdafx.h"
#include "qtmidi.h"
#include <assert.h>
#include <unistd.h>
#include <fcntl.h>
#include "../debug.h"
Go to the source code of this file.
Defines | |
#define | MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_3 |
#define | WindowClass OSX_WindowClass |
#define | OTTD_Random OSX_OTTD_Random |
#define | VOLUME ((short)((0x00FF & _quicktime_volume) << 1)) |
Maps OpenTTD volume to QuickTime notion of volume. | |
Enumerations | |
enum | { midiType = 'Midi' } |
enum | { QT_STATE_IDLE, QT_STATE_PLAY, QT_STATE_STOP } |
Possible states of the QuickTime music driver. More... | |
Functions | |
static void | SetMIDITypeIfNeeded (const FSRef *ref) |
Sets the OSType of a given file to 'Midi' , but only if it's not already set. | |
static bool | LoadMovieForMIDIFile (const char *path, Movie *moov) |
Loads a MIDI file and returns it as a QuickTime Movie structure. | |
static void | InitQuickTimeIfNeeded () |
Initialize QuickTime if needed. | |
Variables | |
static FMusicDriver_QtMidi | iFMusicDriver_QtMidi |
static bool | _quicktime_started = false |
Flag which has the true value when QuickTime is available and initialized. | |
static Movie | _quicktime_movie |
Current QuickTime Movie . | |
static byte | _quicktime_volume = 127 |
Current volume. | |
static int | _quicktime_state = QT_STATE_IDLE |
Current player state. |
This music player should work in all MacOS X releases starting from 10.0, as QuickTime is an integral part of the system since the old days of the Motorola 68k-based Macintoshes. The only extra dependency apart from QuickTime itself is Carbon, which is included since 10.0 as well.
QuickTime gets fooled with the MIDI files from Transport Tycoon Deluxe because of the .gm suffix. To force QuickTime to load the MIDI files without the need of dealing with the individual QuickTime components needed to play music (data source, MIDI parser, note allocators, synthesizers and the like) some Carbon functions are used to set the file type as seen by QuickTime, using
FSpSetFInfo()
(which modifies the file's resource fork).
Definition in file qtmidi.cpp.
anonymous enum |
anonymous enum |
Possible states of the QuickTime music driver.
QT_STATE_IDLE | No file loaded. |
QT_STATE_PLAY | File loaded, playing. |
QT_STATE_STOP | File loaded, stopped. |
Definition at line 174 of file qtmidi.cpp.
static void InitQuickTimeIfNeeded | ( | ) | [static] |
Initialize QuickTime if needed.
This function sets the _quicktime_started flag to true
if QuickTime is present in the system and it was initialized properly.
Definition at line 158 of file qtmidi.cpp.
References _quicktime_started.
static bool LoadMovieForMIDIFile | ( | const char * | path, | |
Movie * | moov | |||
) | [static] |
Loads a MIDI file and returns it as a QuickTime Movie structure.
*path | String with the path of an existing MIDI file. | |
*moov | Pointer to a Movie where the result will be stored. |
Movie
successfully created. Definition at line 96 of file qtmidi.cpp.
References SetMIDITypeIfNeeded().
static void SetMIDITypeIfNeeded | ( | const FSRef * | ref | ) | [static] |
Sets the OSType
of a given file to 'Midi'
, but only if it's not already set.
*spec | A FSSpec structure referencing a file. |
Definition at line 66 of file qtmidi.cpp.
References midiType.
Referenced by LoadMovieForMIDIFile().