19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL - Simple DirectMedia Layer 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Copyright (C) 1997-2012 Sam Lantinga 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is free software; you can redistribute it and/or 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall modify it under the terms of the GNU Library General Public 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License as published by the Free Software Foundation; either 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall version 2 of the License, or (at your option) any later version. 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is distributed in the hope that it will be useful, 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall but WITHOUT ANY WARRANTY; without even the implied warranty of 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Library General Public License for more details. 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall You should have received a copy of the GNU Library General Public 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License along with this library; if not, write to the Free 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sam Lantinga 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slouken@libsdl.org 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h" 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "CDPlayer.h" 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "AudioFilePlayer.h" 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDLOSXCAGuard.h" 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* we're exporting these functions into C land for SDL_syscdrom.c */ 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*extern "C" {*/ 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*/////////////////////////////////////////////////////////////////////////// 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Constants 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //////////////////////////////////////////////////////////////////////////*/ 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kAudioCDFilesystemID (UInt16)(('J' << 8) | 'H') /* 'JH'; this avoids compiler warning */ 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* XML PList keys */ 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kRawTOCDataString "Format 0x02 TOC Data" 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kSessionsString "Sessions" 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kSessionTypeString "Session Type" 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kTrackArrayString "Track Array" 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kFirstTrackInSessionString "First Track" 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kLastTrackInSessionString "Last Track" 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kLeadoutBlockString "Leadout Block" 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kDataKeyString "Data" 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kPointKeyString "Point" 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kSessionNumberKeyString "Session Number" 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define kStartBlockKeyString "Start Block" 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*/////////////////////////////////////////////////////////////////////////// 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Globals 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //////////////////////////////////////////////////////////////////////////*/ 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#pragma mark -- Globals -- 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int playBackWasInit = 0; 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic AudioUnit theUnit; 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic AudioFilePlayer* thePlayer = NULL; 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic CDPlayerCompletionProc completionProc = NULL; 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_mutex *apiMutex = NULL; 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_sem *callbackSem; 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic SDL_CD* theCDROM; 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*/////////////////////////////////////////////////////////////////////////// 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Prototypes 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall //////////////////////////////////////////////////////////////////////////*/ 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#pragma mark -- Prototypes -- 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic OSStatus CheckInit (); 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void FilePlayNotificationHandler (void* inRefCon, OSStatus inStatus); 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int RunCallBackThread (void* inRefCon); 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#pragma mark -- Public Functions -- 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid Lock () 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (!apiMutex) { 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall apiMutex = SDL_CreateMutex(); 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_mutexP(apiMutex); 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid Unlock () 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_mutexV(apiMutex); 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint DetectAudioCDVolumes(FSVolumeRefNum *volumes, int numVolumes) 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int volumeIndex; 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int cdVolumeCount = 0; 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OSStatus result = noErr; 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (volumeIndex = 1; result == noErr || result != nsvErr; volumeIndex++) 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FSVolumeRefNum actualVolume; 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FSVolumeInfo volumeInfo; 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall memset (&volumeInfo, 0, sizeof(volumeInfo)); 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall result = FSGetVolumeInfo (kFSInvalidVolumeRefNum, 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall volumeIndex, 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall &actualVolume, 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall kFSVolInfoFSInfo, 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall &volumeInfo, 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall NULL, 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall NULL); 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (result == noErr) 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (volumeInfo.filesystemID == kAudioCDFilesystemID) /* It's an audio CD */ 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (volumes != NULL && cdVolumeCount < numVolumes) 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall volumes[cdVolumeCount] = actualVolume; 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall cdVolumeCount++; 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* I'm commenting this out because it seems to be harmless */ 1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /*SDL_SetError ("DetectAudioCDVolumes: FSGetVolumeInfo returned %d", result);*/ 1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return cdVolumeCount; 1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ReadTOCData (FSVolumeRefNum theVolume, SDL_CD *theCD) 1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall HFSUniStr255 dataForkName; 1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OSStatus theErr; 1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FSIORefNum forkRefNum; 1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SInt64 forkSize; 1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Ptr forkData = 0; 1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ByteCount actualRead; 1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFDataRef dataRef = 0; 1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFPropertyListRef propertyListRef = 0; 1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FSRefParam fsRefPB; 1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FSRef tocPlistFSRef; 1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FSRef rootRef; 1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const char* error = "Unspecified Error"; 1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall const UniChar uniName[] = { '.','T','O','C','.','p','l','i','s','t' }; 1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theErr = FSGetVolumeInfo(theVolume, 0, 0, kFSVolInfoNone, 0, 0, &rootRef); 1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(theErr != noErr) { 1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall error = "FSGetVolumeInfo"; 1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset(&fsRefPB, '\0', sizeof (fsRefPB)); 1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* get stuff from .TOC.plist */ 1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fsRefPB.ref = &rootRef; 1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fsRefPB.newRef = &tocPlistFSRef; 1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fsRefPB.nameLength = sizeof (uniName) / sizeof (uniName[0]); 1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fsRefPB.name = uniName; 1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fsRefPB.textEncodingHint = kTextEncodingUnknown; 1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theErr = PBMakeFSRefUnicodeSync (&fsRefPB); 1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(theErr != noErr) { 1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall error = "PBMakeFSRefUnicodeSync"; 1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Load and parse the TOC XML data */ 1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theErr = FSGetDataForkName (&dataForkName); 1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (theErr != noErr) { 1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall error = "FSGetDataForkName"; 1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theErr = FSOpenFork (&tocPlistFSRef, dataForkName.length, dataForkName.unicode, fsRdPerm, &forkRefNum); 1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (theErr != noErr) { 1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall error = "FSOpenFork"; 1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theErr = FSGetForkSize (forkRefNum, &forkSize); 1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (theErr != noErr) { 1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall error = "FSGetForkSize"; 1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Allocate some memory for the XML data */ 1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall forkData = NewPtr (forkSize); 1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(forkData == NULL) { 1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall error = "NewPtr"; 1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theErr = FSReadFork (forkRefNum, fsFromStart, 0 /* offset location */, forkSize, forkData, &actualRead); 1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(theErr != noErr) { 1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall error = "FSReadFork"; 2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dataRef = CFDataCreate (kCFAllocatorDefault, (UInt8 *)forkData, forkSize); 2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(dataRef == 0) { 2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall error = "CFDataCreate"; 2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall propertyListRef = CFPropertyListCreateFromXMLData (kCFAllocatorDefault, 2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dataRef, 2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall kCFPropertyListImmutable, 2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall NULL); 2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (propertyListRef == NULL) { 2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall error = "CFPropertyListCreateFromXMLData"; 2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Now we got the Property List in memory. Parse it. */ 2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* First, make sure the root item is a CFDictionary. If not, release and bail. */ 2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if(CFGetTypeID(propertyListRef)== CFDictionaryGetTypeID()) 2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFDictionaryRef dictRef = (CFDictionaryRef)propertyListRef; 2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFDataRef theRawTOCDataRef; 2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFArrayRef theSessionArrayRef; 2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFIndex numSessions; 2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFIndex index; 2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* This is how we get the Raw TOC Data */ 2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theRawTOCDataRef = (CFDataRef)CFDictionaryGetValue (dictRef, CFSTR(kRawTOCDataString)); 2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Get the session array info. */ 2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theSessionArrayRef = (CFArrayRef)CFDictionaryGetValue (dictRef, CFSTR(kSessionsString)); 2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Find out how many sessions there are. */ 2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall numSessions = CFArrayGetCount (theSessionArrayRef); 2389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Initialize the total number of tracks to 0 */ 2409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theCD->numtracks = 0; 2419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Iterate over all sessions, collecting the track data */ 2439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(index = 0; index < numSessions; index++) 2449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFDictionaryRef theSessionDict; 2469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFNumberRef leadoutBlock; 2479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFArrayRef trackArray; 2489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFIndex numTracks; 2499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFIndex trackIndex; 2509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall UInt32 value = 0; 2519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theSessionDict = (CFDictionaryRef) CFArrayGetValueAtIndex (theSessionArrayRef, index); 2539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall leadoutBlock = (CFNumberRef) CFDictionaryGetValue (theSessionDict, CFSTR(kLeadoutBlockString)); 2549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall trackArray = (CFArrayRef)CFDictionaryGetValue (theSessionDict, CFSTR(kTrackArrayString)); 2569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall numTracks = CFArrayGetCount (trackArray); 2589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for(trackIndex = 0; trackIndex < numTracks; trackIndex++) { 2609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFDictionaryRef theTrackDict; 2629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFNumberRef trackNumber; 2639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFNumberRef sessionNumber; 2649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFNumberRef startBlock; 2659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFBooleanRef isDataTrack; 2669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall UInt32 value; 2679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theTrackDict = (CFDictionaryRef) CFArrayGetValueAtIndex (trackArray, trackIndex); 2699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall trackNumber = (CFNumberRef) CFDictionaryGetValue (theTrackDict, CFSTR(kPointKeyString)); 2719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall sessionNumber = (CFNumberRef) CFDictionaryGetValue (theTrackDict, CFSTR(kSessionNumberKeyString)); 2729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall startBlock = (CFNumberRef) CFDictionaryGetValue (theTrackDict, CFSTR(kStartBlockKeyString)); 2739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall isDataTrack = (CFBooleanRef) CFDictionaryGetValue (theTrackDict, CFSTR(kDataKeyString)); 2749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Fill in the SDL_CD struct */ 2769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int idx = theCD->numtracks++; 2779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFNumberGetValue (trackNumber, kCFNumberSInt32Type, &value); 2799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theCD->track[idx].id = value; 2809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFNumberGetValue (startBlock, kCFNumberSInt32Type, &value); 2829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theCD->track[idx].offset = value; 2839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theCD->track[idx].type = (isDataTrack == kCFBooleanTrue) ? SDL_DATA_TRACK : SDL_AUDIO_TRACK; 2859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Since the track lengths are not stored in .TOC.plist we compute them. */ 2879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (trackIndex > 0) { 2889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theCD->track[idx-1].length = theCD->track[idx].offset - theCD->track[idx-1].offset; 2899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Compute the length of the last track */ 2939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFNumberGetValue (leadoutBlock, kCFNumberSInt32Type, &value); 2949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theCD->track[theCD->numtracks-1].length = 2969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall value - theCD->track[theCD->numtracks-1].offset; 2979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Set offset to leadout track */ 2999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theCD->track[theCD->numtracks].offset = value; 3009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theErr = 0; 3059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto cleanup; 3069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallbail: 3079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("ReadTOCData: %s returned %d", error, theErr); 3089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theErr = -1; 3099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallcleanup: 3109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (propertyListRef != NULL) 3129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFRelease(propertyListRef); 3139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (dataRef != NULL) 3149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFRelease(dataRef); 3159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (forkData != NULL) 3169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall DisposePtr(forkData); 3179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FSCloseFork (forkRefNum); 3199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return theErr; 3219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ListTrackFiles (FSVolumeRefNum theVolume, FSRef *trackFiles, int numTracks) 3249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OSStatus result = -1; 3269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FSIterator iterator; 3279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ItemCount actualObjects; 3289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FSRef rootDirectory; 3299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FSRef ref; 3309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall HFSUniStr255 nameStr; 3319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall result = FSGetVolumeInfo (theVolume, 3339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 0, 3349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall NULL, 3359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall kFSVolInfoFSInfo, 3369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall NULL, 3379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall NULL, 3389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall &rootDirectory); 3399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (result != noErr) { 3419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("ListTrackFiles: FSGetVolumeInfo returned %d", result); 3429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return result; 3439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall result = FSOpenIterator (&rootDirectory, kFSIterateFlat, &iterator); 3469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (result == noErr) { 3479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall do 3489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall result = FSGetCatalogInfoBulk (iterator, 1, &actualObjects, 3509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall NULL, kFSCatInfoNone, NULL, &ref, NULL, &nameStr); 3519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (result == noErr) { 3529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFStringRef name; 3549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall name = CFStringCreateWithCharacters (NULL, nameStr.unicode, nameStr.length); 3559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Look for .aiff extension */ 3579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (CFStringHasSuffix (name, CFSTR(".aiff")) || 3589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFStringHasSuffix (name, CFSTR(".cdda"))) { 3599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Extract the track id from the filename */ 3619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int trackID = 0, i = 0; 3629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while (i < nameStr.length && !isdigit(nameStr.unicode[i])) { 3639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ++i; 3649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall while (i < nameStr.length && isdigit(nameStr.unicode[i])) { 3669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall trackID = 10 * trackID +(nameStr.unicode[i] - '0'); 3679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ++i; 3689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if DEBUG_CDROM 3719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf("Found AIFF for track %d: '%s'\n", trackID, 3729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFStringGetCStringPtr (name, CFStringGetSystemEncoding())); 3739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 3749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Track ID's start at 1, but we want to start at 0 */ 3769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall trackID--; 3779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall assert(0 <= trackID && trackID <= SDL_MAX_TRACKS); 3799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (trackID < numTracks) 3819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall memcpy (&trackFiles[trackID], &ref, sizeof(FSRef)); 3829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall CFRelease (name); 3849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } while(noErr == result); 3869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall FSCloseIterator (iterator); 3879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 3909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint LoadFile (const FSRef *ref, int startFrame, int stopFrame) 3939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int error = -1; 3959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (CheckInit () < 0) 3979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 3989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* release any currently playing file */ 4009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (ReleaseFile () < 0) 4019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 4029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if DEBUG_CDROM 4049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf ("LoadFile: %d %d\n", startFrame, stopFrame); 4059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 4069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /*try {*/ 4089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* create a new player, and attach to the audio unit */ 4109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall thePlayer = new_AudioFilePlayer(ref); 4129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (thePlayer == NULL) { 4139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("LoadFile: Could not create player"); 4149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -3; /*throw (-3);*/ 4159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (!thePlayer->SetDestination(thePlayer, &theUnit)) 4189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 4199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (startFrame >= 0) 4219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall thePlayer->SetStartFrame (thePlayer, startFrame); 4229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (stopFrame >= 0 && stopFrame > startFrame) 4249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall thePlayer->SetStopFrame (thePlayer, stopFrame); 4259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* we set the notifier later */ 4279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /*thePlayer->SetNotifier(thePlayer, FilePlayNotificationHandler, NULL);*/ 4289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (!thePlayer->Connect(thePlayer)) 4309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 4319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if DEBUG_CDROM 4339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall thePlayer->Print(thePlayer); 4349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall fflush (stdout); 4359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 4369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /*} 4379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall catch (...) 4389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 4409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall }*/ 4419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall error = 0; 4439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bail: 4459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return error; 4469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 4479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ReleaseFile () 4499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 4509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int error = -1; 4519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* (Don't see any way that the original C++ code could throw here.) --ryan. */ 4539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /*try {*/ 4549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (thePlayer != NULL) { 4559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall thePlayer->Disconnect(thePlayer); 4579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall delete_AudioFilePlayer(thePlayer); 4599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall thePlayer = NULL; 4619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /*} 4639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall catch (...) 4649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 4669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall }*/ 4679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall error = 0; 4699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* bail: */ 4719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return error; 4729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 4739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint PlayFile () 4759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 4769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OSStatus result = -1; 4779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (CheckInit () < 0) 4799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 4809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /*try {*/ 4829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // start processing of the audio unit 4849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall result = AudioOutputUnitStart (theUnit); 4859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (result) goto bail; //THROW_RESULT("PlayFile: AudioOutputUnitStart") 4869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /*} 4889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall catch (...) 4899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 4919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall }*/ 4929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall result = 0; 4949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallbail: 4969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return result; 4979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 4989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint PauseFile () 5009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 5019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OSStatus result = -1; 5029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (CheckInit () < 0) 5049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 5059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /*try {*/ 5079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* stop processing the audio unit */ 5099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall result = AudioOutputUnitStop (theUnit); 5109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (result) goto bail; /*THROW_RESULT("PauseFile: AudioOutputUnitStop")*/ 5119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /*} 5129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall catch (...) 5139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall goto bail; 5159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall }*/ 5169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall result = 0; 5189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallbail: 5199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return result; 5209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 5219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid SetCompletionProc (CDPlayerCompletionProc proc, SDL_CD *cdrom) 5239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 5249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall assert(thePlayer != NULL); 5259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall theCDROM = cdrom; 5279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall completionProc = proc; 5289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall thePlayer->SetNotifier (thePlayer, FilePlayNotificationHandler, cdrom); 5299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 5309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint GetCurrentFrame () 5329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 5339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int frame; 5349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (thePlayer == NULL) 5369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall frame = 0; 5379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 5389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall frame = thePlayer->GetCurrentFrame (thePlayer); 5399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return frame; 5419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 5429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#pragma mark -- Private Functions -- 5459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic OSStatus CheckInit () 5479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 5489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (playBackWasInit) 5499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 5509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OSStatus result = noErr; 5529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Create the callback semaphore */ 5549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall callbackSem = SDL_CreateSemaphore(0); 5559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Start callback thread */ 5579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_CreateThread(RunCallBackThread, NULL); 5589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { /*try {*/ 5609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ComponentDescription desc; 5619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall desc.componentType = kAudioUnitType_Output; 5639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall desc.componentSubType = kAudioUnitSubType_DefaultOutput; 5649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall desc.componentManufacturer = kAudioUnitManufacturer_Apple; 5659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall desc.componentFlags = 0; 5669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall desc.componentFlagsMask = 0; 5679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Component comp = FindNextComponent (NULL, &desc); 5699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (comp == NULL) { 5709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("CheckInit: FindNextComponent returned NULL"); 5719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (result) return -1; //throw(internalComponentErr); 5729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall result = OpenAComponent (comp, &theUnit); 5759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (result) return -1; //THROW_RESULT("CheckInit: OpenAComponent") 5769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall // you need to initialize the output unit before you set it as a destination 5789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall result = AudioUnitInitialize (theUnit); 5799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (result) return -1; //THROW_RESULT("CheckInit: AudioUnitInitialize") 5809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall playBackWasInit = true; 5839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /*catch (...) 5859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 5879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall }*/ 5889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 5909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 5919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic void FilePlayNotificationHandler(void * inRefCon, OSStatus inStatus) 5939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 5949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (inStatus == kAudioFilePlay_FileIsFinished) { 5959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* notify non-CA thread to perform the callback */ 5979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SemPost(callbackSem); 5989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else if (inStatus == kAudioFilePlayErr_FilePlayUnderrun) { 6009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("CDPlayer Notification: buffer underrun"); 6029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else if (inStatus == kAudioFilePlay_PlayerIsUninitialized) { 6039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("CDPlayer Notification: player is uninitialized"); 6059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 6069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError ("CDPlayer Notification: unknown error %ld", inStatus); 6089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 6109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic int RunCallBackThread (void *param) 6129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 6139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (;;) { 6149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SemWait(callbackSem); 6169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (completionProc && theCDROM) { 6189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if DEBUG_CDROM 6199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf ("callback!\n"); 6209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 6219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall (*completionProc)(theCDROM); 6229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } else { 6239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if DEBUG_CDROM 6249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf ("callback?\n"); 6259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 6269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if DEBUG_CDROM 6309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall printf ("thread dying now...\n"); 6319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif 6329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 6349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 6359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*}; // extern "C" */ 637