Commit f4df35b9 authored by Sam Lantinga's avatar Sam Lantinga

Max has been reworking this code so it works on MacOS X 10.1

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40769
parent 86ec9803
......@@ -2430,11 +2430,9 @@ case "$target" in
# Set up files for the cdrom library
if test x$enable_cdrom = xyes; then
# The CD-ROM code won't work on old versions of MacOS X yet...
#CDROM_SUBDIRS="$CDROM_SUBDIRS macosx"
#CDROM_DRIVERS="$CDROM_DRIVERS macosx/libcdrom_macosx.la"
#SYSTEM_LIBS="$SYSTEM_LIBS -framework AudioToolbox -framework AudioUnit -lstdc++"
CDROM_SUBDIRS="$CDROM_SUBDIRS dummy"
CDROM_DRIVERS="$CDROM_DRIVERS dummy/libcdrom_dummy.la"
CDROM_SUBDIRS="$CDROM_SUBDIRS macosx"
CDROM_DRIVERS="$CDROM_DRIVERS macosx/libcdrom_macosx.la"
SYSTEM_LIBS="$SYSTEM_LIBS -framework AudioToolbox -framework AudioUnit -lstdc++"
fi
# Set up files for the thread library
if test x$enable_threads = xyes; then
......
This diff is collapsed.
......@@ -31,7 +31,7 @@
#include <CoreServices/CoreServices.h>
#include <AudioToolbox/AudioToolbox.h>
#include <AudioToolbox/AudioConverter.h>
#include <AudioUnit/AudioUnit.h>
#include "SDL_error.h"
......@@ -97,12 +97,9 @@ public:
#if DEBUG
void Print() const
{
CAShow (mAudioFileID);
printf ("Destination Bus:%ld\n", GetBusNumber());
printf ("Is 'aunt' unit:%s\n", (mIsAUNTUnit ? "true" : "false"));
printf ("Is Connected:%s\n", (IsConnected() ? "true" : "false"));
if (mConverter) CAShow (mConverter);
printf ("- - - - - - - - - - - - - - \n");
printf ("- - - - - - - - - - - - - - \n");
}
#endif
......@@ -111,14 +108,13 @@ public:
private:
AudioUnit mPlayUnit;
UInt32 mBusNumber;
AudioFileID mAudioFileID;
SInt16 mForkRefNum;
AudioUnitInputCallback mInputCallback;
AudioStreamBasicDescription mFileDescription;
bool mConnected;
bool mIsAUNTUnit;
AudioFileManager* mAudioFileManager;
AudioConverterRef mConverter;
......@@ -137,14 +133,12 @@ private:
class AudioFileManager
{
public:
AudioFileManager (AudioFilePlayer& inParent, AudioFileID inFile)
: mParent (inParent),
mAudioFileID (inFile),
mFileBuffer (0),
mByteCounter (0)
{}
AudioFileManager (AudioFilePlayer &inParent,
SInt16 inForkRefNum,
SInt64 inFileLength,
UInt32 inChunkSize);
virtual ~AudioFileManager();
~AudioFileManager();
void Connect (AudioConverterRef inConverter)
......@@ -155,36 +149,51 @@ public:
// this method should NOT be called by an object of this class
// as it is called by the parent's Disconnect() method
virtual void Disconnect () {}
void Disconnect ();
const AudioFileID& GetFileID() const { return mAudioFileID; }
OSStatus Read(char *buffer, UInt32 *len);
const char* GetFileBuffer () { return mFileBuffer; }
const AudioFilePlayer& GetParent () const { return mParent; }
virtual void SetPosition (SInt64 pos) = 0; // seek/rewind in the file
void SetPosition (SInt64 pos); // seek/rewind in the file
virtual int GetByteCounter () { return mByteCounter; } // return actual bytes streamed to audio hardware
int GetByteCounter () { return mByteCounter; } // return actual bytes streamed to audio hardware
virtual void SetEndOfFile (SInt64 pos) = 0; // set the "EOF" (will behave just like it reached eof)
void SetEndOfFile (SInt64 pos); // set the "EOF" (will behave just like it reached eof)
protected:
AudioFilePlayer& mParent;
AudioConverterRef mParentConverter;
const AudioFileID mAudioFileID;
AudioFilePlayer& mParent;
AudioConverterRef mParentConverter;
SInt16 mForkRefNum;
SInt64 mAudioDataOffset;
char* mFileBuffer;
char* mFileBuffer;
OSStatus Render (AudioBuffer &ioData);
int mByteCounter;
bool mReadFromFirstBuffer;
bool mLockUnsuccessful;
bool mIsEngaged;
int mNumTimesAskedSinceFinished;
int mByteCounter;
public:
const UInt32 mChunkSize;
SInt64 mFileLength;
SInt64 mReadFilePosition;
bool mWriteToFirstBuffer;
bool mFinishedReadingData;
protected:
OSStatus Render (AudioBuffer &ioData);
virtual OSStatus GetFileData (void** inOutData, UInt32 *inOutDataSize) = 0;
OSStatus GetFileData (void** inOutData, UInt32 *inOutDataSize);
virtual void DoConnect () = 0;
void DoConnect ();
virtual void AfterRender () = 0;
void AfterRender ();
public:
static OSStatus FileInputProc (void *inRefCon,
......@@ -199,42 +208,4 @@ public:
};
#pragma mark __________ AudioFileReaderThread
class AudioFileReaderThread
: public AudioFileManager
{
public:
const UInt32 mChunkSize;
SInt64 mFileLength;
SInt64 mReadFilePosition;
bool mWriteToFirstBuffer;
bool mFinishedReadingData;
AudioFileReaderThread (AudioFilePlayer &inParent,
AudioFileID &inFile,
SInt64 inFileLength,
UInt32 inChunkSize);
virtual void Disconnect ();
virtual void SetPosition (SInt64 pos); // seek/rewind in the file
virtual void SetEndOfFile (SInt64 pos); // set the "EOF" (will behave just like it reached eof)
protected:
virtual void DoConnect ();
virtual OSStatus GetFileData (void** inOutData, UInt32 *inOutDataSize);
virtual void AfterRender ();
private:
bool mReadFromFirstBuffer;
bool mLockUnsuccessful;
bool mIsEngaged;
int mNumTimesAskedSinceFinished;
};
#endif
This diff is collapsed.
......@@ -70,7 +70,7 @@
#include <stdio.h>
#define NDEBUG 1
//#define NDEBUG 1
#include <assert.h>
......
......@@ -114,9 +114,7 @@ int DetectAudioCDVolumes(FSVolumeRefNum *volumes, int numVolumes)
for (volumeIndex = 1; result == noErr || result != nsvErr; volumeIndex++)
{
FSVolumeRefNum actualVolume;
HFSUniStr255 volumeName;
FSVolumeInfo volumeInfo;
FSRef rootDirectory;
memset (&volumeInfo, 0, sizeof(volumeInfo));
......@@ -125,13 +123,13 @@ int DetectAudioCDVolumes(FSVolumeRefNum *volumes, int numVolumes)
&actualVolume,
kFSVolInfoFSInfo,
&volumeInfo,
&volumeName,
&rootDirectory);
NULL,
NULL);
if (result == noErr)
{
if (volumeInfo.filesystemID == kAudioCDFilesystemID) // It's an audio CD
{
{
if (volumes != NULL && cdVolumeCount < numVolumes)
volumes[cdVolumeCount] = actualVolume;
......
......@@ -25,9 +25,8 @@
#include <string.h>
#include <CoreFoundation/CoreFoundation.h>
#include <Carbon/Carbon.h>
#include <CoreFoundation/CoreFoundation.h>
#include <AudioUnit/AudioUnit.h>
#include "SDL.h"
......
......@@ -265,19 +265,25 @@ void SDL_SYS_CDQuit(void)
/* Get the Unix disk name of the volume */
static const char *SDL_SYS_CDName (int drive)
{
CFStringRef diskID;
OSStatus err = noErr;
HParamBlockRec pb;
GetVolParmsInfoBuffer volParmsInfo;
if (fakeCD)
return "Fake CD-ROM Device";
err = FSCopyDiskIDForVolume (volumes[drive], &diskID);
pb.ioParam.ioNamePtr = NULL;
pb.ioParam.ioVRefNum = volumes[drive];
pb.ioParam.ioBuffer = (Ptr)&volParmsInfo;
pb.ioParam.ioReqCount = (SInt32)sizeof(volParmsInfo);
err = PBHGetVolParmsSync(&pb);
if (err != noErr) {
SDL_SetError ("FSCopyDiskIDForVolume returned %d", err);
SDL_SetError ("PBHGetVolParmsSync returned %d", err);
return NULL;
}
return CFStringGetCStringPtr (diskID, 0);
return volParmsInfo.vMDeviceID;
}
/* Open the "device" */
......@@ -318,14 +324,15 @@ static int SDL_SYS_CDGetTOC (SDL_CD *cdrom)
/* Get CD-ROM status */
static CDstatus SDL_SYS_CDStatus (SDL_CD *cdrom, int *position)
{
int trackFrame;
Lock ();
trackFrame = GetCurrentFrame ();
Unlock ();
if (position) {
int trackFrame;
Lock ();
trackFrame = GetCurrentFrame ();
Unlock ();
if (position)
*position = cdrom->track[currentTrack].offset + trackFrame;
*position = cdrom->track[currentTrack].offset + trackFrame;
}
return status;
}
......@@ -383,8 +390,10 @@ static int SDL_SYS_CDPause(SDL_CD *cdrom)
Lock ();
if (PauseFile () < 0)
if (PauseFile () < 0) {
Unlock ();
return -2;
}
status = CD_PAUSED;
......@@ -403,8 +412,10 @@ static int SDL_SYS_CDResume(SDL_CD *cdrom)
Lock ();
if (PlayFile () < 0)
if (PauseFile () < 0) {
Unlock ();
return -2;
}
status = CD_PLAYING;
......@@ -423,11 +434,15 @@ static int SDL_SYS_CDStop(SDL_CD *cdrom)
Lock ();
if (PauseFile () < 0)
if (PauseFile () < 0) {
Unlock ();
return -2;
}
if (ReleaseFile () < 0)
if (ReleaseFile () < 0) {
Unlock ();
return -3;
}
status = CD_STOPPED;
......@@ -440,6 +455,7 @@ static int SDL_SYS_CDStop(SDL_CD *cdrom)
static int SDL_SYS_CDEject(SDL_CD *cdrom)
{
OSStatus err;
HParamBlockRec pb;
if (fakeCD) {
SDL_SetError (kErrorFakeDevice);
......@@ -448,20 +464,28 @@ static int SDL_SYS_CDEject(SDL_CD *cdrom)
Lock ();
if (PauseFile () < 0)
if (PauseFile () < 0) {
Unlock ();
return -2;
}
if (ReleaseFile () < 0)
if (ReleaseFile () < 0) {
Unlock ();
return -3;
}
status = CD_STOPPED;
err = FSEjectVolumeSync (volumes[cdrom->id], 0, NULL);
if (err != noErr) {
SDL_SetError ("FSEjectVolumeSync returned %d", err);
return -4;
}
// Eject the volume
pb.ioParam.ioNamePtr = NULL;
pb.ioParam.ioVRefNum = volumes[cdrom->id];
err = PBUnmountVol((ParamBlockRec *) &pb);
if (err != noErr) {
Unlock ();
SDL_SetError ("PBUnmountVol returned %d", err);
return -4;
}
status = CD_TRAYEMPTY;
......
......@@ -20,6 +20,9 @@
slouken@libsdl.org
*/
/* This is the Mac OS X / CoreAudio specific header for the SDL CD-ROM API
Contributed by Darrell Walisser and Max Horn
*/
/***********************************************************************************
Implementation Notes
......
......@@ -1365,7 +1365,7 @@ static void QZ_DrawResizeIcon (_THIS, RgnHandle dirtyRegion) {
SDL_RWops *rw;
SDL_Surface *tmp;
rw = SDL_RWFromMem (QZ_ResizeIcon, sizeof(QZ_ResizeIcon));
rw = SDL_RWFromConstMem (QZ_ResizeIcon, sizeof(QZ_ResizeIcon));
tmp = SDL_LoadBMP_RW (rw, SDL_TRUE);
resize_icon = SDL_ConvertSurface (tmp, SDL_VideoSurface->format, SDL_SRCCOLORKEY);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment