31 #include "../stdafx.h"
36 #define Point OTTDPoint
37 #include <QuickTime/QuickTime.h>
41 #include "../safeguards.h"
57 FSCatalogInfo catalogInfo;
61 if (noErr != FSGetCatalogInfo(ref, kFSCatInfoNodeFlags | kFSCatInfoFinderInfo, &catalogInfo, NULL, NULL, NULL))
return;
62 if (!(catalogInfo.nodeFlags & kFSNodeIsDirectoryMask)) {
63 FileInfo *
const info = (FileInfo *) catalogInfo.finderInfo;
64 if (info->fileType !=
MIDI_TYPE && !(info->finderFlags & kIsAlias)) {
67 e = FSSetCatalogInfo(ref, kFSCatInfoFinderInfo, &catalogInfo);
69 DEBUG(driver, 3,
"qtmidi: changed filetype to 'Midi'");
71 DEBUG(driver, 0,
"qtmidi: changing filetype to 'Midi' failed - error %d", e);
98 DEBUG(driver, 2,
"qtmidi: start loading '%s'...", path);
106 fd = open(path, O_RDONLY, 0);
107 if (fd == -1)
return false;
108 ret = read(fd, magic, 4);
110 if (ret < 4)
return false;
112 DEBUG(driver, 3,
"qtmidi: header is '%.4s'", magic);
113 if (magic[0] !=
'M' || magic[1] !=
'T' || magic[2] !=
'h' || magic[3] !=
'd') {
117 if (noErr != FSPathMakeRef((
const UInt8 *) path, &fsref, NULL))
return false;
120 if (noErr != FSGetCatalogInfo(&fsref, kFSCatInfoNone, NULL, NULL, &fsspec, NULL))
return false;
121 if (OpenMovieFile(&fsspec, &refnum, fsRdPerm) != noErr)
return false;
122 DEBUG(driver, 3,
"qtmidi: '%s' successfully opened", path);
124 if (noErr != NewMovieFromFile(moov, refnum, &resid, NULL,
125 newMovieActive | newMovieDontAskUnresolvedDataRefs, NULL)) {
126 CloseMovieFile(refnum);
129 DEBUG(driver, 3,
"qtmidi: movie container created");
131 CloseMovieFile(refnum);
154 DEBUG(driver, 2,
"qtmidi: initializing Quicktime");
157 (noErr == Gestalt(gestaltQuickTime, &dummy)) &&
158 (noErr == EnterMovies());
179 #define VOLUME ((short)((0x00FF & _quicktime_volume) << 1))
236 DEBUG(driver, 2,
"qtmidi: stopping driver...");
239 DEBUG(driver, 3,
"qtmidi: stopping not needed, already idle");
265 DEBUG(driver, 2,
"qtmidi: trying to play '%s'", filename);
269 DEBUG(driver, 3,
"qtmidi: previous tune stopped");
274 DEBUG(driver, 3,
"qtmidi: previous tune disposed");
284 DEBUG(driver, 3,
"qtmidi: playing '%s'", filename);
300 DEBUG(driver, 3,
"qtmidi: stop requested, but already idle");
307 DEBUG(driver, 3,
"qtmidi: player stopped");
327 DEBUG(driver, 2,
"qtmidi: set volume to %u (%hi)", vol,
VOLUME);