Cleaning up warnings on MacOS X
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401491
This commit is contained in:
parent
6ef737becd
commit
c0aec157c6
23 changed files with 316 additions and 356 deletions
|
@ -48,7 +48,7 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo;
|
||||||
/* This is the structure for custom window manager events */
|
/* This is the structure for custom window manager events */
|
||||||
#if SDL_VIDEO_DRIVER_X11
|
#if SDL_VIDEO_DRIVER_X11
|
||||||
#if defined(__APPLE__) && defined(__MACH__)
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
// conflicts with Quickdraw.h
|
/* conflicts with Quickdraw.h */
|
||||||
#define Cursor X11Cursor
|
#define Cursor X11Cursor
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo;
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
#if defined(__APPLE__) && defined(__MACH__)
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
// matches the re-define above
|
/* matches the re-define above */
|
||||||
#undef Cursor
|
#undef Cursor
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
20
src/SDL.c
20
src/SDL.c
|
@ -253,14 +253,14 @@ const SDL_version * SDL_Linked_Version(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__OS2__)
|
#if defined(__OS2__)
|
||||||
// Building for OS/2
|
/* Building for OS/2 */
|
||||||
#ifdef __WATCOMC__
|
#ifdef __WATCOMC__
|
||||||
|
|
||||||
#define INCL_DOSERRORS
|
#define INCL_DOSERRORS
|
||||||
#define INCL_DOSEXCEPTIONS
|
#define INCL_DOSEXCEPTIONS
|
||||||
#include <os2.h>
|
#include <os2.h>
|
||||||
|
|
||||||
// Exception handler to prevent the Audio thread hanging, making a zombie process!
|
/* Exception handler to prevent the Audio thread hanging, making a zombie process! */
|
||||||
ULONG _System SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec,
|
ULONG _System SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec,
|
||||||
PEXCEPTIONREGISTRATIONRECORD pERegRec,
|
PEXCEPTIONREGISTRATIONRECORD pERegRec,
|
||||||
PCONTEXTRECORD pCtxRec,
|
PCONTEXTRECORD pCtxRec,
|
||||||
|
@ -273,7 +273,7 @@ ULONG _System SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec,
|
||||||
if (pERepRec->fHandlerFlags & EH_NESTED_CALL)
|
if (pERepRec->fHandlerFlags & EH_NESTED_CALL)
|
||||||
return XCPT_CONTINUE_SEARCH;
|
return XCPT_CONTINUE_SEARCH;
|
||||||
|
|
||||||
// Do cleanup at every fatal exception!
|
/* Do cleanup at every fatal exception! */
|
||||||
if (((pERepRec->ExceptionNum & XCPT_SEVERITY_CODE) == XCPT_FATAL_EXCEPTION) &&
|
if (((pERepRec->ExceptionNum & XCPT_SEVERITY_CODE) == XCPT_FATAL_EXCEPTION) &&
|
||||||
(pERepRec->ExceptionNum != XCPT_BREAKPOINT) &&
|
(pERepRec->ExceptionNum != XCPT_BREAKPOINT) &&
|
||||||
(pERepRec->ExceptionNum != XCPT_SINGLE_STEP)
|
(pERepRec->ExceptionNum != XCPT_SINGLE_STEP)
|
||||||
|
@ -281,7 +281,7 @@ ULONG _System SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec,
|
||||||
{
|
{
|
||||||
if (SDL_initialized & SDL_INIT_AUDIO)
|
if (SDL_initialized & SDL_INIT_AUDIO)
|
||||||
{
|
{
|
||||||
// This removes the zombie audio thread in case of emergency.
|
/* This removes the zombie audio thread in case of emergency. */
|
||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
printf("[SDL_Main_ExceptionHandler] : Calling SDL_CloseAudio()!\n");
|
printf("[SDL_Main_ExceptionHandler] : Calling SDL_CloseAudio()!\n");
|
||||||
#endif
|
#endif
|
||||||
|
@ -294,28 +294,28 @@ ULONG _System SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec,
|
||||||
|
|
||||||
EXCEPTIONREGISTRATIONRECORD SDL_Main_xcpthand = {0, SDL_Main_ExceptionHandler};
|
EXCEPTIONREGISTRATIONRECORD SDL_Main_xcpthand = {0, SDL_Main_ExceptionHandler};
|
||||||
|
|
||||||
// The main DLL entry for DLL Initialization and Uninitialization:
|
/* The main DLL entry for DLL Initialization and Uninitialization: */
|
||||||
unsigned _System LibMain(unsigned hmod, unsigned termination)
|
unsigned _System LibMain(unsigned hmod, unsigned termination)
|
||||||
{
|
{
|
||||||
if (termination)
|
if (termination)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
// printf("[SDL DLL Unintialization] : Removing exception handler\n");
|
/* printf("[SDL DLL Unintialization] : Removing exception handler\n"); */
|
||||||
#endif
|
#endif
|
||||||
DosUnsetExceptionHandler(&SDL_Main_xcpthand);
|
DosUnsetExceptionHandler(&SDL_Main_xcpthand);
|
||||||
return 1;
|
return 1;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
// Make stdout and stderr unbuffered!
|
/* Make stdout and stderr unbuffered! */
|
||||||
setbuf(stdout, NULL);
|
setbuf(stdout, NULL);
|
||||||
setbuf(stderr, NULL);
|
setbuf(stderr, NULL);
|
||||||
#endif
|
#endif
|
||||||
// Fire up exception handler
|
/* Fire up exception handler */
|
||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
// printf("[SDL DLL Initialization] : Setting exception handler\n");
|
/* printf("[SDL DLL Initialization] : Setting exception handler\n"); */
|
||||||
#endif
|
#endif
|
||||||
// Set exception handler
|
/* Set exception handler */
|
||||||
DosSetExceptionHandler(&SDL_Main_xcpthand);
|
DosSetExceptionHandler(&SDL_Main_xcpthand);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include "SDL_sysaudio.h"
|
#include "SDL_sysaudio.h"
|
||||||
|
|
||||||
#ifdef __OS2__
|
#ifdef __OS2__
|
||||||
// We'll need the DosSetPriority() API!
|
/* We'll need the DosSetPriority() API! */
|
||||||
#define INCL_DOSPROCESS
|
#define INCL_DOSPROCESS
|
||||||
#include <os2.h>
|
#include <os2.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -178,8 +178,8 @@ int SDL_RunAudio(void *audiop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __OS2__
|
#ifdef __OS2__
|
||||||
// Increase the priority of this thread to make sure that
|
/* Increase the priority of this thread to make sure that
|
||||||
// the audio will be continuous all the time!
|
the audio will be continuous all the time! */
|
||||||
#ifdef USE_DOSSETPRIORITY
|
#ifdef USE_DOSSETPRIORITY
|
||||||
if (SDL_getenv("SDL_USE_TIMECRITICAL_AUDIO"))
|
if (SDL_getenv("SDL_USE_TIMECRITICAL_AUDIO"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
*/
|
*/
|
||||||
#include "SDL_config.h"
|
#include "SDL_config.h"
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||||
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
|
|
||||||
void SDL_MixAudio_MMX_S16(char* ,char* ,unsigned int ,int );
|
void SDL_MixAudio_MMX_S16(char* ,char* ,unsigned int ,int );
|
||||||
void SDL_MixAudio_MMX_S8(char* ,char* ,unsigned int ,int );
|
void SDL_MixAudio_MMX_S8(char* ,char* ,unsigned int ,int );
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,14 +23,14 @@
|
||||||
|
|
||||||
|
|
||||||
#if ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
#if ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||||
// headers for MMX assembler version of SDL_MixAudio
|
/* headers for MMX assembler version of SDL_MixAudio
|
||||||
// Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
|
Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
|
||||||
// Converted to Intel ASM notation by Cth
|
Converted to Intel ASM notation by Cth
|
||||||
// This code is licensed under the LGPL (see COPYING for details)
|
This code is licensed under the LGPL (see COPYING for details)
|
||||||
//
|
|
||||||
// Assumes buffer size in bytes is a multiple of 16
|
|
||||||
// Assumes SDL_MIX_MAXVOLUME = 128
|
|
||||||
|
|
||||||
|
Assumes buffer size in bytes is a multiple of 16
|
||||||
|
Assumes SDL_MIX_MAXVOLUME = 128
|
||||||
|
*/
|
||||||
void SDL_MixAudio_MMX_S16_VC(char* ,char* ,unsigned int ,int );
|
void SDL_MixAudio_MMX_S16_VC(char* ,char* ,unsigned int ,int );
|
||||||
void SDL_MixAudio_MMX_S8_VC(char* ,char* ,unsigned int ,int );
|
void SDL_MixAudio_MMX_S8_VC(char* ,char* ,unsigned int ,int );
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -433,7 +433,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
|
||||||
was_error = 1;
|
was_error = 1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
headerDiff += sizeof(Uint32); // for WAVE
|
headerDiff += sizeof(Uint32); /* for WAVE */
|
||||||
|
|
||||||
/* Read the audio data format chunk */
|
/* Read the audio data format chunk */
|
||||||
chunk.data = NULL;
|
chunk.data = NULL;
|
||||||
|
@ -446,7 +446,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
|
||||||
was_error = 1;
|
was_error = 1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
// 2 Uint32's for chunk header+len, plus the lenread
|
/* 2 Uint32's for chunk header+len, plus the lenread */
|
||||||
headerDiff += lenread + 2 * sizeof(Uint32);
|
headerDiff += lenread + 2 * sizeof(Uint32);
|
||||||
} while ( (chunk.magic == FACT) || (chunk.magic == LIST) );
|
} while ( (chunk.magic == FACT) || (chunk.magic == LIST) );
|
||||||
|
|
||||||
|
@ -527,7 +527,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
|
||||||
*audio_buf = chunk.data;
|
*audio_buf = chunk.data;
|
||||||
if(chunk.magic != DATA) headerDiff += lenread + 2 * sizeof(Uint32);
|
if(chunk.magic != DATA) headerDiff += lenread + 2 * sizeof(Uint32);
|
||||||
} while ( chunk.magic != DATA );
|
} while ( chunk.magic != DATA );
|
||||||
headerDiff += 2 * sizeof(Uint32); // for the data chunk and len
|
headerDiff += 2 * sizeof(Uint32); /* for the data chunk and len */
|
||||||
|
|
||||||
if ( MS_ADPCM_encoded ) {
|
if ( MS_ADPCM_encoded ) {
|
||||||
if ( MS_ADPCM_decode(audio_buf, audio_len) < 0 ) {
|
if ( MS_ADPCM_decode(audio_buf, audio_len) < 0 ) {
|
||||||
|
@ -554,7 +554,7 @@ done:
|
||||||
if ( freesrc ) {
|
if ( freesrc ) {
|
||||||
SDL_RWclose(src);
|
SDL_RWclose(src);
|
||||||
} else {
|
} else {
|
||||||
// seek to the end of the file (given by the RIFF chunk)
|
/* seek to the end of the file (given by the RIFF chunk) */
|
||||||
SDL_RWseek(src, wavelen - chunk.length - headerDiff, RW_SEEK_CUR);
|
SDL_RWseek(src, wavelen - chunk.length - headerDiff, RW_SEEK_CUR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,8 +128,8 @@ static OSStatus audioCallback (void *inRefCon,
|
||||||
len = bufferSize - bufferOffset;
|
len = bufferSize - bufferOffset;
|
||||||
if (len > remaining)
|
if (len > remaining)
|
||||||
len = remaining;
|
len = remaining;
|
||||||
SDL_memcpy(ptr, buffer + bufferOffset, len);
|
SDL_memcpy(ptr, (char *)buffer + bufferOffset, len);
|
||||||
ptr += len;
|
ptr = (char *)ptr + len;
|
||||||
remaining -= len;
|
remaining -= len;
|
||||||
bufferOffset += len;
|
bufferOffset += len;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,9 @@
|
||||||
*/
|
*/
|
||||||
#include "SDL_config.h"
|
#include "SDL_config.h"
|
||||||
|
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// AudioFilePlayer.cpp
|
AudioFilePlayer.cpp
|
||||||
//
|
*/
|
||||||
#include "AudioFilePlayer.h"
|
#include "AudioFilePlayer.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -61,7 +61,7 @@ static void PrintStreamDesc (AudioStreamBasicDescription *inDesc)
|
||||||
|
|
||||||
static int AudioFilePlayer_SetDestination (AudioFilePlayer *afp, AudioUnit *inDestUnit)
|
static int AudioFilePlayer_SetDestination (AudioFilePlayer *afp, AudioUnit *inDestUnit)
|
||||||
{
|
{
|
||||||
//if (afp->mConnected) throw static_cast<OSStatus>(-1); //can't set dest if already engaged
|
/*if (afp->mConnected) throw static_cast<OSStatus>(-1);*/ /* can't set dest if already engaged */
|
||||||
if (afp->mConnected)
|
if (afp->mConnected)
|
||||||
return 0 ;
|
return 0 ;
|
||||||
|
|
||||||
|
@ -70,17 +70,17 @@ static int AudioFilePlayer_SetDestination (AudioFilePlayer *afp, AudioUnit *inD
|
||||||
OSStatus result = noErr;
|
OSStatus result = noErr;
|
||||||
|
|
||||||
|
|
||||||
//we can "down" cast a component instance to a component
|
/* we can "down" cast a component instance to a component */
|
||||||
ComponentDescription desc;
|
ComponentDescription desc;
|
||||||
result = GetComponentInfo ((Component)*inDestUnit, &desc, 0, 0, 0);
|
result = GetComponentInfo ((Component)*inDestUnit, &desc, 0, 0, 0);
|
||||||
if (result) return 0; //THROW_RESULT("GetComponentInfo")
|
if (result) return 0; /*THROW_RESULT("GetComponentInfo")*/
|
||||||
|
|
||||||
// we're going to use this to know which convert routine to call
|
/* we're going to use this to know which convert routine to call
|
||||||
// a v1 audio unit will have a type of 'aunt'
|
a v1 audio unit will have a type of 'aunt'
|
||||||
// a v2 audio unit will have one of several different types.
|
a v2 audio unit will have one of several different types. */
|
||||||
if (desc.componentType != kAudioUnitComponentType) {
|
if (desc.componentType != kAudioUnitComponentType) {
|
||||||
result = badComponentInstance;
|
result = badComponentInstance;
|
||||||
//THROW_RESULT("BAD COMPONENT")
|
/*THROW_RESULT("BAD COMPONENT")*/
|
||||||
if (result) return 0;
|
if (result) return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ static int AudioFilePlayer_SetDestination (AudioFilePlayer *afp, AudioUnit *inD
|
||||||
0,
|
0,
|
||||||
&afp->mFileDescription,
|
&afp->mFileDescription,
|
||||||
sizeof (afp->mFileDescription));
|
sizeof (afp->mFileDescription));
|
||||||
//THROW_RESULT("AudioUnitSetProperty")
|
/*THROW_RESULT("AudioUnitSetProperty")*/
|
||||||
if (result) return 0;
|
if (result) return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ static int AudioFilePlayer_Connect(AudioFilePlayer *afp)
|
||||||
if (!afp->mAudioFileManager->DoConnect(afp->mAudioFileManager))
|
if (!afp->mAudioFileManager->DoConnect(afp->mAudioFileManager))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// set the render callback for the file data to be supplied to the sound converter AU
|
/* set the render callback for the file data to be supplied to the sound converter AU */
|
||||||
afp->mInputCallback.inputProc = afp->mAudioFileManager->FileInputProc;
|
afp->mInputCallback.inputProc = afp->mAudioFileManager->FileInputProc;
|
||||||
afp->mInputCallback.inputProcRefCon = afp->mAudioFileManager;
|
afp->mInputCallback.inputProcRefCon = afp->mAudioFileManager;
|
||||||
|
|
||||||
|
@ -180,15 +180,15 @@ static int AudioFilePlayer_Connect(AudioFilePlayer *afp)
|
||||||
0,
|
0,
|
||||||
&afp->mInputCallback,
|
&afp->mInputCallback,
|
||||||
sizeof(afp->mInputCallback));
|
sizeof(afp->mInputCallback));
|
||||||
if (result) return 0; //THROW_RESULT("AudioUnitSetProperty")
|
if (result) return 0; /*THROW_RESULT("AudioUnitSetProperty")*/
|
||||||
afp->mConnected = 1;
|
afp->mConnected = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// warning noted, now please go away ;-)
|
/* warning noted, now please go away ;-) */
|
||||||
// #warning This should redirect the calling of notification code to some other thread
|
/* #warning This should redirect the calling of notification code to some other thread */
|
||||||
static void AudioFilePlayer_DoNotification (AudioFilePlayer *afp, OSStatus inStatus)
|
static void AudioFilePlayer_DoNotification (AudioFilePlayer *afp, OSStatus inStatus)
|
||||||
{
|
{
|
||||||
if (afp->mNotifier) {
|
if (afp->mNotifier) {
|
||||||
|
@ -243,52 +243,53 @@ static int AudioFilePlayer_OpenFile (AudioFilePlayer *afp, const FSRef *inRef
|
||||||
ByteCount actual;
|
ByteCount actual;
|
||||||
SInt64 offset;
|
SInt64 offset;
|
||||||
|
|
||||||
// Open the data fork of the input file
|
/* Open the data fork of the input file */
|
||||||
result = FSGetDataForkName(&dfName);
|
result = FSGetDataForkName(&dfName);
|
||||||
if (result) return 0; //THROW_RESULT("AudioFilePlayer::OpenFile(): FSGetDataForkName")
|
if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSGetDataForkName")*/
|
||||||
|
|
||||||
result = FSOpenFork(inRef, dfName.length, dfName.unicode, fsRdPerm, &afp->mForkRefNum);
|
result = FSOpenFork(inRef, dfName.length, dfName.unicode, fsRdPerm, &afp->mForkRefNum);
|
||||||
if (result) return 0; //THROW_RESULT("AudioFilePlayer::OpenFile(): FSOpenFork")
|
if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSOpenFork")*/
|
||||||
|
|
||||||
// Read the file header, and check if it's indeed an AIFC file
|
/* Read the file header, and check if it's indeed an AIFC file */
|
||||||
result = FSReadFork(afp->mForkRefNum, fsAtMark, 0, sizeof(chunkHeader), &chunkHeader, &actual);
|
result = FSReadFork(afp->mForkRefNum, fsAtMark, 0, sizeof(chunkHeader), &chunkHeader, &actual);
|
||||||
if (result) return 0; //THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork")
|
if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork")*/
|
||||||
|
|
||||||
if (chunkHeader.ckID != 'FORM') {
|
if (chunkHeader.ckID != 'FORM') {
|
||||||
result = -1;
|
result = -1;
|
||||||
if (result) return 0; //THROW_RESULT("AudioFilePlayer::OpenFile(): chunk id is not 'FORM'");
|
if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): chunk id is not 'FORM'");*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chunkHeader.formType != 'AIFC') {
|
if (chunkHeader.formType != 'AIFC') {
|
||||||
result = -1;
|
result = -1;
|
||||||
if (result) return 0; //THROW_RESULT("AudioFilePlayer::OpenFile(): file format is not 'AIFC'");
|
if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): file format is not 'AIFC'");*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search for the SSND chunk. We ignore all compression etc. information
|
/* Search for the SSND chunk. We ignore all compression etc. information
|
||||||
// in other chunks. Of course that is kind of evil, but for now we are lazy
|
in other chunks. Of course that is kind of evil, but for now we are lazy
|
||||||
// and rely on the cdfs to always give us the same fixed format.
|
and rely on the cdfs to always give us the same fixed format.
|
||||||
// TODO: Parse the COMM chunk we currently skip to fill in mFileDescription.
|
TODO: Parse the COMM chunk we currently skip to fill in mFileDescription.
|
||||||
|
*/
|
||||||
offset = 0;
|
offset = 0;
|
||||||
do {
|
do {
|
||||||
result = FSReadFork(afp->mForkRefNum, fsFromMark, offset, sizeof(chunk), &chunk, &actual);
|
result = FSReadFork(afp->mForkRefNum, fsFromMark, offset, sizeof(chunk), &chunk, &actual);
|
||||||
if (result) return 0; //THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork")
|
if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork")*/
|
||||||
|
|
||||||
// Skip the chunk data
|
/* Skip the chunk data */
|
||||||
offset = chunk.ckSize;
|
offset = chunk.ckSize;
|
||||||
} while (chunk.ckID != 'SSND');
|
} while (chunk.ckID != 'SSND');
|
||||||
|
|
||||||
// Read the header of the SSND chunk. After this, we are positioned right
|
/* Read the header of the SSND chunk. After this, we are positioned right
|
||||||
// at the start of the audio data.
|
at the start of the audio data. */
|
||||||
result = FSReadFork(afp->mForkRefNum, fsAtMark, 0, sizeof(ssndData), &ssndData, &actual);
|
result = FSReadFork(afp->mForkRefNum, fsAtMark, 0, sizeof(ssndData), &ssndData, &actual);
|
||||||
if (result) return 0; //THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork")
|
if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork")*/
|
||||||
|
|
||||||
result = FSSetForkPosition(afp->mForkRefNum, fsFromMark, ssndData.offset);
|
result = FSSetForkPosition(afp->mForkRefNum, fsFromMark, ssndData.offset);
|
||||||
if (result) return 0; //THROW_RESULT("AudioFilePlayer::OpenFile(): FSSetForkPosition")
|
if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSSetForkPosition")*/
|
||||||
|
|
||||||
// Data size
|
/* Data size */
|
||||||
*outFileDataSize = chunk.ckSize - ssndData.offset - 8;
|
*outFileDataSize = chunk.ckSize - ssndData.offset - 8;
|
||||||
|
|
||||||
// File format
|
/* File format */
|
||||||
afp->mFileDescription.mSampleRate = 44100;
|
afp->mFileDescription.mSampleRate = 44100;
|
||||||
afp->mFileDescription.mFormatID = kAudioFormatLinearPCM;
|
afp->mFileDescription.mFormatID = kAudioFormatLinearPCM;
|
||||||
afp->mFileDescription.mFormatFlags = kLinearPCMFormatFlagIsPacked | kLinearPCMFormatFlagIsSignedInteger;
|
afp->mFileDescription.mFormatFlags = kLinearPCMFormatFlagIsPacked | kLinearPCMFormatFlagIsSignedInteger;
|
||||||
|
@ -331,7 +332,7 @@ AudioFilePlayer *new_AudioFilePlayer (const FSRef *inFileRef)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we want about 4 seconds worth of data for the buffer
|
/* we want about 4 seconds worth of data for the buffer */
|
||||||
int bytesPerSecond = (UInt32) (4 * afp->mFileDescription.mSampleRate * afp->mFileDescription.mBytesPerFrame);
|
int bytesPerSecond = (UInt32) (4 * afp->mFileDescription.mSampleRate * afp->mFileDescription.mBytesPerFrame);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|
|
@ -24,9 +24,9 @@
|
||||||
*/
|
*/
|
||||||
#include "SDL_config.h"
|
#include "SDL_config.h"
|
||||||
|
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// AudioFilePlayer.h
|
AudioFilePlayer.h
|
||||||
//
|
*/
|
||||||
#ifndef __AudioFilePlayer_H__
|
#ifndef __AudioFilePlayer_H__
|
||||||
#define __AudioFilePlayer_H__
|
#define __AudioFilePlayer_H__
|
||||||
|
|
||||||
|
@ -62,12 +62,12 @@ struct S_AudioFileManager;
|
||||||
#pragma mark __________ AudioFilePlayer
|
#pragma mark __________ AudioFilePlayer
|
||||||
typedef struct S_AudioFilePlayer
|
typedef struct S_AudioFilePlayer
|
||||||
{
|
{
|
||||||
//public:
|
/*public:*/
|
||||||
int (*SetDestination)(struct S_AudioFilePlayer *afp, AudioUnit *inDestUnit);
|
int (*SetDestination)(struct S_AudioFilePlayer *afp, AudioUnit *inDestUnit);
|
||||||
void (*SetNotifier)(struct S_AudioFilePlayer *afp, AudioFilePlayNotifier inNotifier, void *inRefCon);
|
void (*SetNotifier)(struct S_AudioFilePlayer *afp, AudioFilePlayNotifier inNotifier, void *inRefCon);
|
||||||
void (*SetStartFrame)(struct S_AudioFilePlayer *afp, int frame); // seek in the file
|
void (*SetStartFrame)(struct S_AudioFilePlayer *afp, int frame); /* seek in the file */
|
||||||
int (*GetCurrentFrame)(struct S_AudioFilePlayer *afp); // get the current frame position
|
int (*GetCurrentFrame)(struct S_AudioFilePlayer *afp); /* get the current frame position */
|
||||||
void (*SetStopFrame)(struct S_AudioFilePlayer *afp, int frame); // set limit in the file
|
void (*SetStopFrame)(struct S_AudioFilePlayer *afp, int frame); /* set limit in the file */
|
||||||
int (*Connect)(struct S_AudioFilePlayer *afp);
|
int (*Connect)(struct S_AudioFilePlayer *afp);
|
||||||
void (*Disconnect)(struct S_AudioFilePlayer *afp);
|
void (*Disconnect)(struct S_AudioFilePlayer *afp);
|
||||||
void (*DoNotification)(struct S_AudioFilePlayer *afp, OSStatus inError);
|
void (*DoNotification)(struct S_AudioFilePlayer *afp, OSStatus inError);
|
||||||
|
@ -75,7 +75,7 @@ typedef struct S_AudioFilePlayer
|
||||||
AudioUnit (*GetDestUnit)(struct S_AudioFilePlayer *afp);
|
AudioUnit (*GetDestUnit)(struct S_AudioFilePlayer *afp);
|
||||||
void (*Print)(struct S_AudioFilePlayer *afp);
|
void (*Print)(struct S_AudioFilePlayer *afp);
|
||||||
|
|
||||||
//private:
|
/*private:*/
|
||||||
AudioUnit mPlayUnit;
|
AudioUnit mPlayUnit;
|
||||||
SInt16 mForkRefNum;
|
SInt16 mForkRefNum;
|
||||||
|
|
||||||
|
@ -106,19 +106,19 @@ void delete_AudioFilePlayer(AudioFilePlayer *afp);
|
||||||
#pragma mark __________ AudioFileManager
|
#pragma mark __________ AudioFileManager
|
||||||
typedef struct S_AudioFileManager
|
typedef struct S_AudioFileManager
|
||||||
{
|
{
|
||||||
//public:
|
/*public:*/
|
||||||
// this method should NOT be called by an object of this class
|
/* this method should NOT be called by an object of this class
|
||||||
// as it is called by the parent's Disconnect() method
|
as it is called by the parent's Disconnect() method */
|
||||||
void (*Disconnect)(struct S_AudioFileManager *afm);
|
void (*Disconnect)(struct S_AudioFileManager *afm);
|
||||||
int (*DoConnect)(struct S_AudioFileManager *afm);
|
int (*DoConnect)(struct S_AudioFileManager *afm);
|
||||||
OSStatus (*Read)(struct S_AudioFileManager *afm, char *buffer, UInt32 *len);
|
OSStatus (*Read)(struct S_AudioFileManager *afm, char *buffer, UInt32 *len);
|
||||||
const char* (*GetFileBuffer)(struct S_AudioFileManager *afm);
|
const char* (*GetFileBuffer)(struct S_AudioFileManager *afm);
|
||||||
const AudioFilePlayer *(*GetParent)(struct S_AudioFileManager *afm);
|
const AudioFilePlayer *(*GetParent)(struct S_AudioFileManager *afm);
|
||||||
void (*SetPosition)(struct S_AudioFileManager *afm, SInt64 pos); // seek/rewind in the file
|
void (*SetPosition)(struct S_AudioFileManager *afm, SInt64 pos); /* seek/rewind in the file */
|
||||||
int (*GetByteCounter)(struct S_AudioFileManager *afm); // return actual bytes streamed to audio hardware
|
int (*GetByteCounter)(struct S_AudioFileManager *afm); /* return actual bytes streamed to audio hardware */
|
||||||
void (*SetEndOfFile)(struct S_AudioFileManager *afm, SInt64 pos); // set the "EOF" (will behave just like it reached eof)
|
void (*SetEndOfFile)(struct S_AudioFileManager *afm, SInt64 pos); /* set the "EOF" (will behave just like it reached eof) */
|
||||||
|
|
||||||
//protected:
|
/*protected:*/
|
||||||
AudioFilePlayer* mParent;
|
AudioFilePlayer* mParent;
|
||||||
SInt16 mForkRefNum;
|
SInt16 mForkRefNum;
|
||||||
SInt64 mAudioDataOffset;
|
SInt64 mAudioDataOffset;
|
||||||
|
@ -137,20 +137,20 @@ typedef struct S_AudioFileManager
|
||||||
void* mTmpBuffer;
|
void* mTmpBuffer;
|
||||||
UInt32 mBufferSize;
|
UInt32 mBufferSize;
|
||||||
UInt32 mBufferOffset;
|
UInt32 mBufferOffset;
|
||||||
//public:
|
/*public:*/
|
||||||
UInt32 mChunkSize;
|
UInt32 mChunkSize;
|
||||||
SInt64 mFileLength;
|
SInt64 mFileLength;
|
||||||
SInt64 mReadFilePosition;
|
SInt64 mReadFilePosition;
|
||||||
int mWriteToFirstBuffer;
|
int mWriteToFirstBuffer;
|
||||||
int mFinishedReadingData;
|
int mFinishedReadingData;
|
||||||
|
|
||||||
//protected:
|
/*protected:*/
|
||||||
OSStatus (*Render)(struct S_AudioFileManager *afm, AudioBuffer *ioData);
|
OSStatus (*Render)(struct S_AudioFileManager *afm, AudioBuffer *ioData);
|
||||||
OSStatus (*GetFileData)(struct S_AudioFileManager *afm, void** inOutData, UInt32 *inOutDataSize);
|
OSStatus (*GetFileData)(struct S_AudioFileManager *afm, void** inOutData, UInt32 *inOutDataSize);
|
||||||
void (*AfterRender)(struct S_AudioFileManager *afm);
|
void (*AfterRender)(struct S_AudioFileManager *afm);
|
||||||
|
|
||||||
//public:
|
/*public:*/
|
||||||
//static
|
/*static*/
|
||||||
OSStatus (*FileInputProc)(void *inRefCon,
|
OSStatus (*FileInputProc)(void *inRefCon,
|
||||||
AudioUnitRenderActionFlags inActionFlags,
|
AudioUnitRenderActionFlags inActionFlags,
|
||||||
const AudioTimeStamp *inTimeStamp,
|
const AudioTimeStamp *inTimeStamp,
|
||||||
|
|
|
@ -24,17 +24,17 @@
|
||||||
*/
|
*/
|
||||||
#include "SDL_config.h"
|
#include "SDL_config.h"
|
||||||
|
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// AudioFileManager.cpp
|
AudioFileManager.cpp
|
||||||
//
|
*/
|
||||||
#include "AudioFilePlayer.h"
|
#include "AudioFilePlayer.h"
|
||||||
#include <mach/mach.h> //used for setting policy of thread
|
#include <mach/mach.h> /* used for setting policy of thread */
|
||||||
#include "SDLOSXCAGuard.h"
|
#include "SDLOSXCAGuard.h"
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
//#include <list>
|
/*#include <list>*/
|
||||||
|
|
||||||
//typedef void *FileData;
|
/*typedef void *FileData;*/
|
||||||
typedef struct S_FileData
|
typedef struct S_FileData
|
||||||
{
|
{
|
||||||
AudioFileManager *obj;
|
AudioFileManager *obj;
|
||||||
|
@ -43,7 +43,7 @@ typedef struct S_FileData
|
||||||
|
|
||||||
|
|
||||||
typedef struct S_FileReaderThread {
|
typedef struct S_FileReaderThread {
|
||||||
//public:
|
/*public:*/
|
||||||
SDLOSXCAGuard* (*GetGuard)(struct S_FileReaderThread *frt);
|
SDLOSXCAGuard* (*GetGuard)(struct S_FileReaderThread *frt);
|
||||||
void (*AddReader)(struct S_FileReaderThread *frt);
|
void (*AddReader)(struct S_FileReaderThread *frt);
|
||||||
void (*RemoveReader)(struct S_FileReaderThread *frt, AudioFileManager* inItem);
|
void (*RemoveReader)(struct S_FileReaderThread *frt, AudioFileManager* inItem);
|
||||||
|
@ -51,8 +51,8 @@ typedef struct S_FileReaderThread {
|
||||||
|
|
||||||
int mThreadShouldDie;
|
int mThreadShouldDie;
|
||||||
|
|
||||||
//private:
|
/*private:*/
|
||||||
//typedef std::list<AudioFileManager*> FileData;
|
/*typedef std::list<AudioFileManager*> FileData;*/
|
||||||
|
|
||||||
SDLOSXCAGuard *mGuard;
|
SDLOSXCAGuard *mGuard;
|
||||||
UInt32 mThreadPriority;
|
UInt32 mThreadPriority;
|
||||||
|
@ -63,9 +63,9 @@ typedef struct S_FileReaderThread {
|
||||||
|
|
||||||
void (*ReadNextChunk)(struct S_FileReaderThread *frt);
|
void (*ReadNextChunk)(struct S_FileReaderThread *frt);
|
||||||
int (*StartFixedPriorityThread)(struct S_FileReaderThread *frt);
|
int (*StartFixedPriorityThread)(struct S_FileReaderThread *frt);
|
||||||
//static
|
/*static*/
|
||||||
UInt32 (*GetThreadBasePriority)(pthread_t inThread);
|
UInt32 (*GetThreadBasePriority)(pthread_t inThread);
|
||||||
//static
|
/*static*/
|
||||||
void* (*DiskReaderEntry)(void *inRefCon);
|
void* (*DiskReaderEntry)(void *inRefCon);
|
||||||
} FileReaderThread;
|
} FileReaderThread;
|
||||||
|
|
||||||
|
@ -75,15 +75,15 @@ static SDLOSXCAGuard* FileReaderThread_GetGuard(FileReaderThread *frt)
|
||||||
return frt->mGuard;
|
return frt->mGuard;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns 1 if succeeded
|
/* returns 1 if succeeded */
|
||||||
static int FileReaderThread_TryNextRead (FileReaderThread *frt, AudioFileManager* inItem)
|
static int FileReaderThread_TryNextRead (FileReaderThread *frt, AudioFileManager* inItem)
|
||||||
{
|
{
|
||||||
int didLock = 0;
|
int didLock = 0;
|
||||||
int succeeded = 0;
|
int succeeded = 0;
|
||||||
if (frt->mGuard->Try(frt->mGuard, &didLock))
|
if (frt->mGuard->Try(frt->mGuard, &didLock))
|
||||||
{
|
{
|
||||||
//frt->mFileData.push_back (inItem);
|
/*frt->mFileData.push_back (inItem);*/
|
||||||
// !!! FIXME: this could be faster with a "tail" member. --ryan.
|
/* !!! FIXME: this could be faster with a "tail" member. --ryan. */
|
||||||
FileData *i = frt->mFileData;
|
FileData *i = frt->mFileData;
|
||||||
FileData *prev = NULL;
|
FileData *prev = NULL;
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ static void FileReaderThread_RemoveReader (FileReaderThread *frt, AudioFileMa
|
||||||
{
|
{
|
||||||
int bNeedsRelease = frt->mGuard->Lock(frt->mGuard);
|
int bNeedsRelease = frt->mGuard->Lock(frt->mGuard);
|
||||||
|
|
||||||
//frt->mFileData.remove (inItem);
|
/*frt->mFileData.remove (inItem);*/
|
||||||
FileData *i = frt->mFileData;
|
FileData *i = frt->mFileData;
|
||||||
FileData *prev = NULL;
|
FileData *prev = NULL;
|
||||||
while (i != NULL)
|
while (i != NULL)
|
||||||
|
@ -144,8 +144,8 @@ static void FileReaderThread_RemoveReader (FileReaderThread *frt, AudioFileMa
|
||||||
|
|
||||||
if (--frt->mNumReaders == 0) {
|
if (--frt->mNumReaders == 0) {
|
||||||
frt->mThreadShouldDie = 1;
|
frt->mThreadShouldDie = 1;
|
||||||
frt->mGuard->Notify(frt->mGuard); // wake up thread so it will quit
|
frt->mGuard->Notify(frt->mGuard); /* wake up thread so it will quit */
|
||||||
frt->mGuard->Wait(frt->mGuard); // wait for thread to die
|
frt->mGuard->Wait(frt->mGuard); /* wait for thread to die */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bNeedsRelease) frt->mGuard->Unlock(frt->mGuard);
|
if (bNeedsRelease) frt->mGuard->Unlock(frt->mGuard);
|
||||||
|
@ -158,34 +158,34 @@ static int FileReaderThread_StartFixedPriorityThread (FileReaderThread *frt)
|
||||||
pthread_t pThread;
|
pthread_t pThread;
|
||||||
|
|
||||||
OSStatus result = pthread_attr_init(&theThreadAttrs);
|
OSStatus result = pthread_attr_init(&theThreadAttrs);
|
||||||
if (result) return 0; //THROW_RESULT("pthread_attr_init - Thread attributes could not be created.")
|
if (result) return 0; /*THROW_RESULT("pthread_attr_init - Thread attributes could not be created.")*/
|
||||||
|
|
||||||
result = pthread_attr_setdetachstate(&theThreadAttrs, PTHREAD_CREATE_DETACHED);
|
result = pthread_attr_setdetachstate(&theThreadAttrs, PTHREAD_CREATE_DETACHED);
|
||||||
if (result) return 0; //THROW_RESULT("pthread_attr_setdetachstate - Thread attributes could not be detached.")
|
if (result) return 0; /*THROW_RESULT("pthread_attr_setdetachstate - Thread attributes could not be detached.")*/
|
||||||
|
|
||||||
result = pthread_create (&pThread, &theThreadAttrs, frt->DiskReaderEntry, frt);
|
result = pthread_create (&pThread, &theThreadAttrs, frt->DiskReaderEntry, frt);
|
||||||
if (result) return 0; //THROW_RESULT("pthread_create - Create and start the thread.")
|
if (result) return 0; /*THROW_RESULT("pthread_create - Create and start the thread.")*/
|
||||||
|
|
||||||
pthread_attr_destroy(&theThreadAttrs);
|
pthread_attr_destroy(&theThreadAttrs);
|
||||||
|
|
||||||
// we've now created the thread and started it
|
/* we've now created the thread and started it
|
||||||
// we'll now set the priority of the thread to the nominated priority
|
we'll now set the priority of the thread to the nominated priority
|
||||||
// and we'll also make the thread fixed
|
and we'll also make the thread fixed */
|
||||||
thread_extended_policy_data_t theFixedPolicy;
|
thread_extended_policy_data_t theFixedPolicy;
|
||||||
thread_precedence_policy_data_t thePrecedencePolicy;
|
thread_precedence_policy_data_t thePrecedencePolicy;
|
||||||
SInt32 relativePriority;
|
SInt32 relativePriority;
|
||||||
|
|
||||||
// make thread fixed
|
/* make thread fixed */
|
||||||
theFixedPolicy.timeshare = 0; // set to 1 for a non-fixed thread
|
theFixedPolicy.timeshare = 0; /* set to 1 for a non-fixed thread */
|
||||||
result = thread_policy_set (pthread_mach_thread_np(pThread), THREAD_EXTENDED_POLICY, (thread_policy_t)&theFixedPolicy, THREAD_EXTENDED_POLICY_COUNT);
|
result = thread_policy_set (pthread_mach_thread_np(pThread), THREAD_EXTENDED_POLICY, (thread_policy_t)&theFixedPolicy, THREAD_EXTENDED_POLICY_COUNT);
|
||||||
if (result) return 0; //THROW_RESULT("thread_policy - Couldn't set thread as fixed priority.")
|
if (result) return 0; /*THROW_RESULT("thread_policy - Couldn't set thread as fixed priority.")*/
|
||||||
// set priority
|
/* set priority */
|
||||||
// precedency policy's "importance" value is relative to spawning thread's priority
|
/* precedency policy's "importance" value is relative to spawning thread's priority */
|
||||||
relativePriority = frt->mThreadPriority - frt->GetThreadBasePriority(pthread_self());
|
relativePriority = frt->mThreadPriority - frt->GetThreadBasePriority(pthread_self());
|
||||||
|
|
||||||
thePrecedencePolicy.importance = relativePriority;
|
thePrecedencePolicy.importance = relativePriority;
|
||||||
result = thread_policy_set (pthread_mach_thread_np(pThread), THREAD_PRECEDENCE_POLICY, (thread_policy_t)&thePrecedencePolicy, THREAD_PRECEDENCE_POLICY_COUNT);
|
result = thread_policy_set (pthread_mach_thread_np(pThread), THREAD_PRECEDENCE_POLICY, (thread_policy_t)&thePrecedencePolicy, THREAD_PRECEDENCE_POLICY_COUNT);
|
||||||
if (result) return 0; //THROW_RESULT("thread_policy - Couldn't set thread priority.")
|
if (result) return 0; /*THROW_RESULT("thread_policy - Couldn't set thread priority.")*/
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ static UInt32 FileReaderThread_GetThreadBasePriority (pthread_t inThread)
|
||||||
policy_info_data_t thePolicyInfo;
|
policy_info_data_t thePolicyInfo;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
|
||||||
// get basic info
|
/* get basic info */
|
||||||
count = THREAD_BASIC_INFO_COUNT;
|
count = THREAD_BASIC_INFO_COUNT;
|
||||||
thread_info (pthread_mach_thread_np (inThread), THREAD_BASIC_INFO, (integer_t*)&threadInfo, &count);
|
thread_info (pthread_mach_thread_np (inThread), THREAD_BASIC_INFO, (integer_t*)&threadInfo, &count);
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ static void FileReaderThread_ReadNextChunk (FileReaderThread *frt)
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
{ // this is a scoped based lock
|
{ /* this is a scoped based lock */
|
||||||
int bNeedsRelease = frt->mGuard->Lock(frt->mGuard);
|
int bNeedsRelease = frt->mGuard->Lock(frt->mGuard);
|
||||||
|
|
||||||
if (frt->mThreadShouldDie) {
|
if (frt->mThreadShouldDie) {
|
||||||
|
@ -259,13 +259,13 @@ static void FileReaderThread_ReadNextChunk (FileReaderThread *frt)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (frt->mFileData.empty())
|
/*if (frt->mFileData.empty())*/
|
||||||
if (frt->mFileData == NULL)
|
if (frt->mFileData == NULL)
|
||||||
{
|
{
|
||||||
frt->mGuard->Wait(frt->mGuard);
|
frt->mGuard->Wait(frt->mGuard);
|
||||||
}
|
}
|
||||||
|
|
||||||
// kill thread
|
/* kill thread */
|
||||||
if (frt->mThreadShouldDie) {
|
if (frt->mThreadShouldDie) {
|
||||||
|
|
||||||
frt->mGuard->Notify(frt->mGuard);
|
frt->mGuard->Notify(frt->mGuard);
|
||||||
|
@ -273,8 +273,8 @@ static void FileReaderThread_ReadNextChunk (FileReaderThread *frt)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//theItem = frt->mFileData.front();
|
/*theItem = frt->mFileData.front();*/
|
||||||
//frt->mFileData.pop_front();
|
/*frt->mFileData.pop_front();*/
|
||||||
theItem = NULL;
|
theItem = NULL;
|
||||||
if (frt->mFileData != NULL)
|
if (frt->mFileData != NULL)
|
||||||
{
|
{
|
||||||
|
@ -292,16 +292,16 @@ static void FileReaderThread_ReadNextChunk (FileReaderThread *frt)
|
||||||
else
|
else
|
||||||
dataChunkSize = theItem->mChunkSize;
|
dataChunkSize = theItem->mChunkSize;
|
||||||
|
|
||||||
// this is the exit condition for the thread
|
/* this is the exit condition for the thread */
|
||||||
if (dataChunkSize <= 0) {
|
if (dataChunkSize <= 0) {
|
||||||
theItem->mFinishedReadingData = 1;
|
theItem->mFinishedReadingData = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// construct pointer
|
/* construct pointer */
|
||||||
char* writePtr = (char *) (theItem->GetFileBuffer(theItem) +
|
char* writePtr = (char *) (theItem->GetFileBuffer(theItem) +
|
||||||
(theItem->mWriteToFirstBuffer ? 0 : theItem->mChunkSize));
|
(theItem->mWriteToFirstBuffer ? 0 : theItem->mChunkSize));
|
||||||
|
|
||||||
// read data
|
/* read data */
|
||||||
result = theItem->Read(theItem, writePtr, &dataChunkSize);
|
result = theItem->Read(theItem, writePtr, &dataChunkSize);
|
||||||
if (result != noErr && result != eofErr) {
|
if (result != noErr && result != eofErr) {
|
||||||
AudioFilePlayer *afp = (AudioFilePlayer *) theItem->GetParent(theItem);
|
AudioFilePlayer *afp = (AudioFilePlayer *) theItem->GetParent(theItem);
|
||||||
|
@ -313,16 +313,16 @@ static void FileReaderThread_ReadNextChunk (FileReaderThread *frt)
|
||||||
{
|
{
|
||||||
writePtr += dataChunkSize;
|
writePtr += dataChunkSize;
|
||||||
|
|
||||||
// can't exit yet.. we still have to pass the partial buffer back
|
/* can't exit yet.. we still have to pass the partial buffer back */
|
||||||
memset (writePtr, 0, (theItem->mChunkSize - dataChunkSize));
|
SDL_memset(writePtr, 0, (theItem->mChunkSize - dataChunkSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
theItem->mWriteToFirstBuffer = !theItem->mWriteToFirstBuffer; // switch buffers
|
theItem->mWriteToFirstBuffer = !theItem->mWriteToFirstBuffer; /* switch buffers */
|
||||||
|
|
||||||
if (result == eofErr)
|
if (result == eofErr)
|
||||||
theItem->mReadFilePosition = theItem->mFileLength;
|
theItem->mReadFilePosition = theItem->mFileLength;
|
||||||
else
|
else
|
||||||
theItem->mReadFilePosition += dataChunkSize; // increment count
|
theItem->mReadFilePosition += dataChunkSize; /* increment count */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,13 +372,14 @@ static int AudioFileManager_DoConnect (AudioFileManager *afm)
|
||||||
{
|
{
|
||||||
if (!afm->mIsEngaged)
|
if (!afm->mIsEngaged)
|
||||||
{
|
{
|
||||||
//afm->mReadFilePosition = 0;
|
OSStatus result;
|
||||||
|
|
||||||
|
/*afm->mReadFilePosition = 0;*/
|
||||||
afm->mFinishedReadingData = 0;
|
afm->mFinishedReadingData = 0;
|
||||||
|
|
||||||
afm->mNumTimesAskedSinceFinished = 0;
|
afm->mNumTimesAskedSinceFinished = 0;
|
||||||
afm->mLockUnsuccessful = 0;
|
afm->mLockUnsuccessful = 0;
|
||||||
|
|
||||||
OSStatus result;
|
|
||||||
UInt32 dataChunkSize;
|
UInt32 dataChunkSize;
|
||||||
|
|
||||||
if ((afm->mFileLength - afm->mReadFilePosition) < afm->mChunkSize)
|
if ((afm->mFileLength - afm->mReadFilePosition) < afm->mChunkSize)
|
||||||
|
@ -387,7 +388,7 @@ static int AudioFileManager_DoConnect (AudioFileManager *afm)
|
||||||
dataChunkSize = afm->mChunkSize;
|
dataChunkSize = afm->mChunkSize;
|
||||||
|
|
||||||
result = afm->Read(afm, afm->mFileBuffer, &dataChunkSize);
|
result = afm->Read(afm, afm->mFileBuffer, &dataChunkSize);
|
||||||
if (result) return 0; //THROW_RESULT("AudioFileManager::DoConnect(): Read")
|
if (result) return 0; /*THROW_RESULT("AudioFileManager::DoConnect(): Read")*/
|
||||||
|
|
||||||
afm->mReadFilePosition += dataChunkSize;
|
afm->mReadFilePosition += dataChunkSize;
|
||||||
|
|
||||||
|
@ -398,8 +399,9 @@ static int AudioFileManager_DoConnect (AudioFileManager *afm)
|
||||||
|
|
||||||
afm->mIsEngaged = 1;
|
afm->mIsEngaged = 1;
|
||||||
}
|
}
|
||||||
//else
|
/*
|
||||||
// throw static_cast<OSStatus>(-1); //thread has already been started
|
else
|
||||||
|
throw static_cast<OSStatus>(-1); */ /* thread has already been started */
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,16 +25,16 @@
|
||||||
#include "AudioFilePlayer.h"
|
#include "AudioFilePlayer.h"
|
||||||
#include "SDLOSXCAGuard.h"
|
#include "SDLOSXCAGuard.h"
|
||||||
|
|
||||||
// we're exporting these functions into C land for SDL_syscdrom.c
|
/* we're exporting these functions into C land for SDL_syscdrom.c */
|
||||||
//extern "C" {
|
/*extern "C" {*/
|
||||||
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
/*///////////////////////////////////////////////////////////////////////////
|
||||||
// Constants
|
Constants
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
#define kAudioCDFilesystemID (UInt16)(('J' << 8) | 'H') // 'JH'; this avoids compiler warning
|
#define kAudioCDFilesystemID (UInt16)(('J' << 8) | 'H') /* 'JH'; this avoids compiler warning */
|
||||||
|
|
||||||
// XML PList keys
|
/* XML PList keys */
|
||||||
#define kRawTOCDataString "Format 0x02 TOC Data"
|
#define kRawTOCDataString "Format 0x02 TOC Data"
|
||||||
#define kSessionsString "Sessions"
|
#define kSessionsString "Sessions"
|
||||||
#define kSessionTypeString "Session Type"
|
#define kSessionTypeString "Session Type"
|
||||||
|
@ -47,9 +47,9 @@
|
||||||
#define kSessionNumberKeyString "Session Number"
|
#define kSessionNumberKeyString "Session Number"
|
||||||
#define kStartBlockKeyString "Start Block"
|
#define kStartBlockKeyString "Start Block"
|
||||||
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
/*///////////////////////////////////////////////////////////////////////////
|
||||||
// Globals
|
Globals
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
#pragma mark -- Globals --
|
#pragma mark -- Globals --
|
||||||
|
|
||||||
|
@ -61,9 +61,9 @@ static SDL_mutex *apiMutex = NULL;
|
||||||
static SDL_sem *callbackSem;
|
static SDL_sem *callbackSem;
|
||||||
static SDL_CD* theCDROM;
|
static SDL_CD* theCDROM;
|
||||||
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
/*///////////////////////////////////////////////////////////////////////////
|
||||||
// Prototypes
|
Prototypes
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
#pragma mark -- Prototypes --
|
#pragma mark -- Prototypes --
|
||||||
|
|
||||||
|
@ -89,10 +89,6 @@ void Unlock ()
|
||||||
SDL_mutexV(apiMutex);
|
SDL_mutexV(apiMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
// DetectAudioCDVolumes
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
|
|
||||||
int DetectAudioCDVolumes(FSVolumeRefNum *volumes, int numVolumes)
|
int DetectAudioCDVolumes(FSVolumeRefNum *volumes, int numVolumes)
|
||||||
{
|
{
|
||||||
int volumeIndex;
|
int volumeIndex;
|
||||||
|
@ -116,7 +112,7 @@ int DetectAudioCDVolumes(FSVolumeRefNum *volumes, int numVolumes)
|
||||||
|
|
||||||
if (result == noErr)
|
if (result == noErr)
|
||||||
{
|
{
|
||||||
if (volumeInfo.filesystemID == kAudioCDFilesystemID) // It's an audio CD
|
if (volumeInfo.filesystemID == kAudioCDFilesystemID) /* It's an audio CD */
|
||||||
{
|
{
|
||||||
if (volumes != NULL && cdVolumeCount < numVolumes)
|
if (volumes != NULL && cdVolumeCount < numVolumes)
|
||||||
volumes[cdVolumeCount] = actualVolume;
|
volumes[cdVolumeCount] = actualVolume;
|
||||||
|
@ -126,18 +122,14 @@ int DetectAudioCDVolumes(FSVolumeRefNum *volumes, int numVolumes)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// I'm commenting this out because it seems to be harmless
|
/* I'm commenting this out because it seems to be harmless */
|
||||||
//SDL_SetError ("DetectAudioCDVolumes: FSGetVolumeInfo returned %d", result);
|
/*SDL_SetError ("DetectAudioCDVolumes: FSGetVolumeInfo returned %d", result);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cdVolumeCount;
|
return cdVolumeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
// ReadTOCData
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
|
|
||||||
int ReadTOCData (FSVolumeRefNum theVolume, SDL_CD *theCD)
|
int ReadTOCData (FSVolumeRefNum theVolume, SDL_CD *theCD)
|
||||||
{
|
{
|
||||||
HFSUniStr255 dataForkName;
|
HFSUniStr255 dataForkName;
|
||||||
|
@ -154,7 +146,7 @@ int ReadTOCData (FSVolumeRefNum theVolume, SDL_CD *theCD)
|
||||||
|
|
||||||
const char* error = "Unspecified Error";
|
const char* error = "Unspecified Error";
|
||||||
|
|
||||||
// get stuff from .TOC.plist
|
/* get stuff from .TOC.plist */
|
||||||
fsRefPB.ioCompletion = NULL;
|
fsRefPB.ioCompletion = NULL;
|
||||||
fsRefPB.ioNamePtr = "\p.TOC.plist";
|
fsRefPB.ioNamePtr = "\p.TOC.plist";
|
||||||
fsRefPB.ioVRefNum = theVolume;
|
fsRefPB.ioVRefNum = theVolume;
|
||||||
|
@ -167,7 +159,7 @@ int ReadTOCData (FSVolumeRefNum theVolume, SDL_CD *theCD)
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load and parse the TOC XML data
|
/* Load and parse the TOC XML data */
|
||||||
|
|
||||||
theErr = FSGetDataForkName (&dataForkName);
|
theErr = FSGetDataForkName (&dataForkName);
|
||||||
if (theErr != noErr) {
|
if (theErr != noErr) {
|
||||||
|
@ -187,7 +179,7 @@ int ReadTOCData (FSVolumeRefNum theVolume, SDL_CD *theCD)
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate some memory for the XML data
|
/* Allocate some memory for the XML data */
|
||||||
forkData = NewPtr (forkSize);
|
forkData = NewPtr (forkSize);
|
||||||
if(forkData == NULL) {
|
if(forkData == NULL) {
|
||||||
error = "NewPtr";
|
error = "NewPtr";
|
||||||
|
@ -215,9 +207,9 @@ int ReadTOCData (FSVolumeRefNum theVolume, SDL_CD *theCD)
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we got the Property List in memory. Parse it.
|
/* Now we got the Property List in memory. Parse it. */
|
||||||
|
|
||||||
// First, make sure the root item is a CFDictionary. If not, release and bail.
|
/* First, make sure the root item is a CFDictionary. If not, release and bail. */
|
||||||
if(CFGetTypeID(propertyListRef)== CFDictionaryGetTypeID())
|
if(CFGetTypeID(propertyListRef)== CFDictionaryGetTypeID())
|
||||||
{
|
{
|
||||||
CFDictionaryRef dictRef = (CFDictionaryRef)propertyListRef;
|
CFDictionaryRef dictRef = (CFDictionaryRef)propertyListRef;
|
||||||
|
@ -227,19 +219,19 @@ int ReadTOCData (FSVolumeRefNum theVolume, SDL_CD *theCD)
|
||||||
CFIndex numSessions;
|
CFIndex numSessions;
|
||||||
CFIndex index;
|
CFIndex index;
|
||||||
|
|
||||||
// This is how we get the Raw TOC Data
|
/* This is how we get the Raw TOC Data */
|
||||||
theRawTOCDataRef = (CFDataRef)CFDictionaryGetValue (dictRef, CFSTR(kRawTOCDataString));
|
theRawTOCDataRef = (CFDataRef)CFDictionaryGetValue (dictRef, CFSTR(kRawTOCDataString));
|
||||||
|
|
||||||
// Get the session array info.
|
/* Get the session array info. */
|
||||||
theSessionArrayRef = (CFArrayRef)CFDictionaryGetValue (dictRef, CFSTR(kSessionsString));
|
theSessionArrayRef = (CFArrayRef)CFDictionaryGetValue (dictRef, CFSTR(kSessionsString));
|
||||||
|
|
||||||
// Find out how many sessions there are.
|
/* Find out how many sessions there are. */
|
||||||
numSessions = CFArrayGetCount (theSessionArrayRef);
|
numSessions = CFArrayGetCount (theSessionArrayRef);
|
||||||
|
|
||||||
// Initialize the total number of tracks to 0
|
/* Initialize the total number of tracks to 0 */
|
||||||
theCD->numtracks = 0;
|
theCD->numtracks = 0;
|
||||||
|
|
||||||
// Iterate over all sessions, collecting the track data
|
/* Iterate over all sessions, collecting the track data */
|
||||||
for(index = 0; index < numSessions; index++)
|
for(index = 0; index < numSessions; index++)
|
||||||
{
|
{
|
||||||
CFDictionaryRef theSessionDict;
|
CFDictionaryRef theSessionDict;
|
||||||
|
@ -272,7 +264,7 @@ int ReadTOCData (FSVolumeRefNum theVolume, SDL_CD *theCD)
|
||||||
startBlock = (CFNumberRef) CFDictionaryGetValue (theTrackDict, CFSTR(kStartBlockKeyString));
|
startBlock = (CFNumberRef) CFDictionaryGetValue (theTrackDict, CFSTR(kStartBlockKeyString));
|
||||||
isDataTrack = (CFBooleanRef) CFDictionaryGetValue (theTrackDict, CFSTR(kDataKeyString));
|
isDataTrack = (CFBooleanRef) CFDictionaryGetValue (theTrackDict, CFSTR(kDataKeyString));
|
||||||
|
|
||||||
// Fill in the SDL_CD struct
|
/* Fill in the SDL_CD struct */
|
||||||
int idx = theCD->numtracks++;
|
int idx = theCD->numtracks++;
|
||||||
|
|
||||||
CFNumberGetValue (trackNumber, kCFNumberSInt32Type, &value);
|
CFNumberGetValue (trackNumber, kCFNumberSInt32Type, &value);
|
||||||
|
@ -283,19 +275,19 @@ int ReadTOCData (FSVolumeRefNum theVolume, SDL_CD *theCD)
|
||||||
|
|
||||||
theCD->track[idx].type = (isDataTrack == kCFBooleanTrue) ? SDL_DATA_TRACK : SDL_AUDIO_TRACK;
|
theCD->track[idx].type = (isDataTrack == kCFBooleanTrue) ? SDL_DATA_TRACK : SDL_AUDIO_TRACK;
|
||||||
|
|
||||||
// Since the track lengths are not stored in .TOC.plist we compute them.
|
/* Since the track lengths are not stored in .TOC.plist we compute them. */
|
||||||
if (trackIndex > 0) {
|
if (trackIndex > 0) {
|
||||||
theCD->track[idx-1].length = theCD->track[idx].offset - theCD->track[idx-1].offset;
|
theCD->track[idx-1].length = theCD->track[idx].offset - theCD->track[idx-1].offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the length of the last track
|
/* Compute the length of the last track */
|
||||||
CFNumberGetValue (leadoutBlock, kCFNumberSInt32Type, &value);
|
CFNumberGetValue (leadoutBlock, kCFNumberSInt32Type, &value);
|
||||||
|
|
||||||
theCD->track[theCD->numtracks-1].length =
|
theCD->track[theCD->numtracks-1].length =
|
||||||
value - theCD->track[theCD->numtracks-1].offset;
|
value - theCD->track[theCD->numtracks-1].offset;
|
||||||
|
|
||||||
// Set offset to leadout track
|
/* Set offset to leadout track */
|
||||||
theCD->track[theCD->numtracks].offset = value;
|
theCD->track[theCD->numtracks].offset = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,10 +312,6 @@ cleanup:
|
||||||
return theErr;
|
return theErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
// ListTrackFiles
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
|
|
||||||
int ListTrackFiles (FSVolumeRefNum theVolume, FSRef *trackFiles, int numTracks)
|
int ListTrackFiles (FSVolumeRefNum theVolume, FSRef *trackFiles, int numTracks)
|
||||||
{
|
{
|
||||||
OSStatus result = -1;
|
OSStatus result = -1;
|
||||||
|
@ -357,11 +345,11 @@ int ListTrackFiles (FSVolumeRefNum theVolume, FSRef *trackFiles, int numTracks)
|
||||||
CFStringRef name;
|
CFStringRef name;
|
||||||
name = CFStringCreateWithCharacters (NULL, nameStr.unicode, nameStr.length);
|
name = CFStringCreateWithCharacters (NULL, nameStr.unicode, nameStr.length);
|
||||||
|
|
||||||
// Look for .aiff extension
|
/* Look for .aiff extension */
|
||||||
if (CFStringHasSuffix (name, CFSTR(".aiff")) ||
|
if (CFStringHasSuffix (name, CFSTR(".aiff")) ||
|
||||||
CFStringHasSuffix (name, CFSTR(".cdda"))) {
|
CFStringHasSuffix (name, CFSTR(".cdda"))) {
|
||||||
|
|
||||||
// Extract the track id from the filename
|
/* Extract the track id from the filename */
|
||||||
int trackID = 0, i = 0;
|
int trackID = 0, i = 0;
|
||||||
while (i < nameStr.length && !isdigit(nameStr.unicode[i])) {
|
while (i < nameStr.length && !isdigit(nameStr.unicode[i])) {
|
||||||
++i;
|
++i;
|
||||||
|
@ -376,7 +364,7 @@ int ListTrackFiles (FSVolumeRefNum theVolume, FSRef *trackFiles, int numTracks)
|
||||||
CFStringGetCStringPtr (name, CFStringGetSystemEncoding()));
|
CFStringGetCStringPtr (name, CFStringGetSystemEncoding()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Track ID's start at 1, but we want to start at 0
|
/* Track ID's start at 1, but we want to start at 0 */
|
||||||
trackID--;
|
trackID--;
|
||||||
|
|
||||||
assert(0 <= trackID && trackID <= SDL_MAX_TRACKS);
|
assert(0 <= trackID && trackID <= SDL_MAX_TRACKS);
|
||||||
|
@ -393,10 +381,6 @@ int ListTrackFiles (FSVolumeRefNum theVolume, FSRef *trackFiles, int numTracks)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
// LoadFile
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
|
|
||||||
int LoadFile (const FSRef *ref, int startFrame, int stopFrame)
|
int LoadFile (const FSRef *ref, int startFrame, int stopFrame)
|
||||||
{
|
{
|
||||||
int error = -1;
|
int error = -1;
|
||||||
|
@ -404,7 +388,7 @@ int LoadFile (const FSRef *ref, int startFrame, int stopFrame)
|
||||||
if (CheckInit () < 0)
|
if (CheckInit () < 0)
|
||||||
goto bail;
|
goto bail;
|
||||||
|
|
||||||
// release any currently playing file
|
/* release any currently playing file */
|
||||||
if (ReleaseFile () < 0)
|
if (ReleaseFile () < 0)
|
||||||
goto bail;
|
goto bail;
|
||||||
|
|
||||||
|
@ -412,14 +396,14 @@ int LoadFile (const FSRef *ref, int startFrame, int stopFrame)
|
||||||
printf ("LoadFile: %d %d\n", startFrame, stopFrame);
|
printf ("LoadFile: %d %d\n", startFrame, stopFrame);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//try {
|
/*try {*/
|
||||||
|
|
||||||
// create a new player, and attach to the audio unit
|
/* create a new player, and attach to the audio unit */
|
||||||
|
|
||||||
thePlayer = new_AudioFilePlayer(ref);
|
thePlayer = new_AudioFilePlayer(ref);
|
||||||
if (thePlayer == NULL) {
|
if (thePlayer == NULL) {
|
||||||
SDL_SetError ("LoadFile: Could not create player");
|
SDL_SetError ("LoadFile: Could not create player");
|
||||||
return -3; //throw (-3);
|
return -3; /*throw (-3);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!thePlayer->SetDestination(thePlayer, &theUnit))
|
if (!thePlayer->SetDestination(thePlayer, &theUnit))
|
||||||
|
@ -431,8 +415,8 @@ int LoadFile (const FSRef *ref, int startFrame, int stopFrame)
|
||||||
if (stopFrame >= 0 && stopFrame > startFrame)
|
if (stopFrame >= 0 && stopFrame > startFrame)
|
||||||
thePlayer->SetStopFrame (thePlayer, stopFrame);
|
thePlayer->SetStopFrame (thePlayer, stopFrame);
|
||||||
|
|
||||||
// we set the notifier later
|
/* we set the notifier later */
|
||||||
//thePlayer->SetNotifier(thePlayer, FilePlayNotificationHandler, NULL);
|
/*thePlayer->SetNotifier(thePlayer, FilePlayNotificationHandler, NULL);*/
|
||||||
|
|
||||||
if (!thePlayer->Connect(thePlayer))
|
if (!thePlayer->Connect(thePlayer))
|
||||||
goto bail;
|
goto bail;
|
||||||
|
@ -441,11 +425,11 @@ int LoadFile (const FSRef *ref, int startFrame, int stopFrame)
|
||||||
thePlayer->Print(thePlayer);
|
thePlayer->Print(thePlayer);
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
#endif
|
#endif
|
||||||
//}
|
/*}
|
||||||
//catch (...)
|
catch (...)
|
||||||
//{
|
{
|
||||||
// goto bail;
|
goto bail;
|
||||||
//}
|
}*/
|
||||||
|
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
|
@ -453,16 +437,12 @@ int LoadFile (const FSRef *ref, int startFrame, int stopFrame)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
// ReleaseFile
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
|
|
||||||
int ReleaseFile ()
|
int ReleaseFile ()
|
||||||
{
|
{
|
||||||
int error = -1;
|
int error = -1;
|
||||||
|
|
||||||
// (Don't see any way that the original C++ code could throw here.) --ryan.
|
/* (Don't see any way that the original C++ code could throw here.) --ryan. */
|
||||||
//try {
|
/*try {*/
|
||||||
if (thePlayer != NULL) {
|
if (thePlayer != NULL) {
|
||||||
|
|
||||||
thePlayer->Disconnect(thePlayer);
|
thePlayer->Disconnect(thePlayer);
|
||||||
|
@ -471,22 +451,18 @@ int ReleaseFile ()
|
||||||
|
|
||||||
thePlayer = NULL;
|
thePlayer = NULL;
|
||||||
}
|
}
|
||||||
//}
|
/*}
|
||||||
//catch (...)
|
catch (...)
|
||||||
//{
|
{
|
||||||
// goto bail;
|
goto bail;
|
||||||
//}
|
}*/
|
||||||
|
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
// bail:
|
/* bail: */
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
// PlayFile
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
|
|
||||||
int PlayFile ()
|
int PlayFile ()
|
||||||
{
|
{
|
||||||
OSStatus result = -1;
|
OSStatus result = -1;
|
||||||
|
@ -494,17 +470,17 @@ int PlayFile ()
|
||||||
if (CheckInit () < 0)
|
if (CheckInit () < 0)
|
||||||
goto bail;
|
goto bail;
|
||||||
|
|
||||||
// try {
|
/*try {*/
|
||||||
|
|
||||||
// start processing of the audio unit
|
// start processing of the audio unit
|
||||||
result = AudioOutputUnitStart (theUnit);
|
result = AudioOutputUnitStart (theUnit);
|
||||||
if (result) goto bail; //THROW_RESULT("PlayFile: AudioOutputUnitStart")
|
if (result) goto bail; //THROW_RESULT("PlayFile: AudioOutputUnitStart")
|
||||||
|
|
||||||
// }
|
/*}
|
||||||
// catch (...)
|
catch (...)
|
||||||
// {
|
{
|
||||||
// goto bail;
|
goto bail;
|
||||||
// }
|
}*/
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
|
@ -512,10 +488,6 @@ bail:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
// PauseFile
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
|
|
||||||
int PauseFile ()
|
int PauseFile ()
|
||||||
{
|
{
|
||||||
OSStatus result = -1;
|
OSStatus result = -1;
|
||||||
|
@ -523,26 +495,22 @@ int PauseFile ()
|
||||||
if (CheckInit () < 0)
|
if (CheckInit () < 0)
|
||||||
goto bail;
|
goto bail;
|
||||||
|
|
||||||
//try {
|
/*try {*/
|
||||||
|
|
||||||
// stop processing the audio unit
|
/* stop processing the audio unit */
|
||||||
result = AudioOutputUnitStop (theUnit);
|
result = AudioOutputUnitStop (theUnit);
|
||||||
if (result) goto bail; //THROW_RESULT("PauseFile: AudioOutputUnitStop")
|
if (result) goto bail; /*THROW_RESULT("PauseFile: AudioOutputUnitStop")*/
|
||||||
//}
|
/*}
|
||||||
//catch (...)
|
catch (...)
|
||||||
//{
|
{
|
||||||
// goto bail;
|
goto bail;
|
||||||
//}
|
}*/
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
bail:
|
bail:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
// SetCompletionProc
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
|
|
||||||
void SetCompletionProc (CDPlayerCompletionProc proc, SDL_CD *cdrom)
|
void SetCompletionProc (CDPlayerCompletionProc proc, SDL_CD *cdrom)
|
||||||
{
|
{
|
||||||
assert(thePlayer != NULL);
|
assert(thePlayer != NULL);
|
||||||
|
@ -552,10 +520,6 @@ void SetCompletionProc (CDPlayerCompletionProc proc, SDL_CD *cdrom)
|
||||||
thePlayer->SetNotifier (thePlayer, FilePlayNotificationHandler, cdrom);
|
thePlayer->SetNotifier (thePlayer, FilePlayNotificationHandler, cdrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
// GetCurrentFrame
|
|
||||||
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
||||||
|
|
||||||
int GetCurrentFrame ()
|
int GetCurrentFrame ()
|
||||||
{
|
{
|
||||||
int frame;
|
int frame;
|
||||||
|
@ -578,13 +542,13 @@ static OSStatus CheckInit ()
|
||||||
|
|
||||||
OSStatus result = noErr;
|
OSStatus result = noErr;
|
||||||
|
|
||||||
// Create the callback semaphore
|
/* Create the callback semaphore */
|
||||||
callbackSem = SDL_CreateSemaphore(0);
|
callbackSem = SDL_CreateSemaphore(0);
|
||||||
|
|
||||||
// Start callback thread
|
/* Start callback thread */
|
||||||
SDL_CreateThread(RunCallBackThread, NULL);
|
SDL_CreateThread(RunCallBackThread, NULL);
|
||||||
|
|
||||||
{ //try {
|
{ /*try {*/
|
||||||
ComponentDescription desc;
|
ComponentDescription desc;
|
||||||
|
|
||||||
desc.componentType = kAudioUnitComponentType;
|
desc.componentType = kAudioUnitComponentType;
|
||||||
|
@ -609,10 +573,10 @@ static OSStatus CheckInit ()
|
||||||
|
|
||||||
playBackWasInit = true;
|
playBackWasInit = true;
|
||||||
}
|
}
|
||||||
//catch (...)
|
/*catch (...)
|
||||||
//{
|
{
|
||||||
// return -1;
|
return -1;
|
||||||
//}
|
}*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -621,7 +585,7 @@ static void FilePlayNotificationHandler(void * inRefCon, OSStatus inStatus)
|
||||||
{
|
{
|
||||||
if (inStatus == kAudioFilePlay_FileIsFinished) {
|
if (inStatus == kAudioFilePlay_FileIsFinished) {
|
||||||
|
|
||||||
// notify non-CA thread to perform the callback
|
/* notify non-CA thread to perform the callback */
|
||||||
SDL_SemPost(callbackSem);
|
SDL_SemPost(callbackSem);
|
||||||
|
|
||||||
} else if (inStatus == kAudioFilePlayErr_FilePlayUnderrun) {
|
} else if (inStatus == kAudioFilePlayErr_FilePlayUnderrun) {
|
||||||
|
@ -661,4 +625,4 @@ static int RunCallBackThread (void *param)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//}; // extern "C"
|
/*}; // extern "C" */
|
||||||
|
|
|
@ -44,7 +44,7 @@ void Lock ();
|
||||||
|
|
||||||
void Unlock();
|
void Unlock();
|
||||||
|
|
||||||
int LoadFile (const FSRef *ref, int startFrame, int endFrame); // pass -1 to do nothing
|
int LoadFile (const FSRef *ref, int startFrame, int endFrame); /* pass -1 to do nothing */
|
||||||
|
|
||||||
int ReleaseFile ();
|
int ReleaseFile ();
|
||||||
|
|
||||||
|
|
|
@ -66,9 +66,9 @@
|
||||||
|
|
||||||
=============================================================================*/
|
=============================================================================*/
|
||||||
|
|
||||||
//=============================================================================
|
/*=============================================================================
|
||||||
// Includes
|
Includes
|
||||||
//=============================================================================
|
=============================================================================*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
*/
|
*/
|
||||||
#include "SDL_stdinc.h"
|
#include "SDL_stdinc.h"
|
||||||
|
|
||||||
//#define NDEBUG 1
|
/*#define NDEBUG 1*/
|
||||||
/*
|
/*
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
*/
|
*/
|
||||||
|
@ -86,10 +86,10 @@
|
||||||
|
|
||||||
#include "SDLOSXCAGuard.h"
|
#include "SDLOSXCAGuard.h"
|
||||||
|
|
||||||
//#warning Need a try-based Locker too
|
/*#warning Need a try-based Locker too*/
|
||||||
//=============================================================================
|
/*=============================================================================
|
||||||
// SDLOSXCAGuard
|
SDLOSXCAGuard
|
||||||
//=============================================================================
|
=============================================================================*/
|
||||||
|
|
||||||
static int SDLOSXCAGuard_Lock(SDLOSXCAGuard *cag)
|
static int SDLOSXCAGuard_Lock(SDLOSXCAGuard *cag)
|
||||||
{
|
{
|
||||||
|
@ -98,6 +98,7 @@ static int SDLOSXCAGuard_Lock(SDLOSXCAGuard *cag)
|
||||||
if(pthread_self() != cag->mOwner)
|
if(pthread_self() != cag->mOwner)
|
||||||
{
|
{
|
||||||
OSStatus theError = pthread_mutex_lock(&cag->mMutex);
|
OSStatus theError = pthread_mutex_lock(&cag->mMutex);
|
||||||
|
(void)theError;
|
||||||
assert(theError == 0);
|
assert(theError == 0);
|
||||||
cag->mOwner = pthread_self();
|
cag->mOwner = pthread_self();
|
||||||
theAnswer = 1;
|
theAnswer = 1;
|
||||||
|
@ -108,10 +109,12 @@ static int SDLOSXCAGuard_Lock(SDLOSXCAGuard *cag)
|
||||||
|
|
||||||
static void SDLOSXCAGuard_Unlock(SDLOSXCAGuard *cag)
|
static void SDLOSXCAGuard_Unlock(SDLOSXCAGuard *cag)
|
||||||
{
|
{
|
||||||
|
OSStatus theError;
|
||||||
assert(pthread_self() == cag->mOwner);
|
assert(pthread_self() == cag->mOwner);
|
||||||
|
|
||||||
cag->mOwner = 0;
|
cag->mOwner = 0;
|
||||||
OSStatus theError = pthread_mutex_unlock(&cag->mMutex);
|
theError = pthread_mutex_unlock(&cag->mMutex);
|
||||||
|
(void)theError;
|
||||||
assert(theError == 0);
|
assert(theError == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,11 +140,13 @@ static int SDLOSXCAGuard_Try (SDLOSXCAGuard *cag, int *outWasLocked)
|
||||||
|
|
||||||
static void SDLOSXCAGuard_Wait(SDLOSXCAGuard *cag)
|
static void SDLOSXCAGuard_Wait(SDLOSXCAGuard *cag)
|
||||||
{
|
{
|
||||||
|
OSStatus theError;
|
||||||
assert(pthread_self() == cag->mOwner);
|
assert(pthread_self() == cag->mOwner);
|
||||||
|
|
||||||
cag->mOwner = 0;
|
cag->mOwner = 0;
|
||||||
|
|
||||||
OSStatus theError = pthread_cond_wait(&cag->mCondVar, &cag->mMutex);
|
theError = pthread_cond_wait(&cag->mCondVar, &cag->mMutex);
|
||||||
|
(void)theError;
|
||||||
assert(theError == 0);
|
assert(theError == 0);
|
||||||
cag->mOwner = pthread_self();
|
cag->mOwner = pthread_self();
|
||||||
}
|
}
|
||||||
|
@ -149,12 +154,14 @@ static void SDLOSXCAGuard_Wait(SDLOSXCAGuard *cag)
|
||||||
static void SDLOSXCAGuard_Notify(SDLOSXCAGuard *cag)
|
static void SDLOSXCAGuard_Notify(SDLOSXCAGuard *cag)
|
||||||
{
|
{
|
||||||
OSStatus theError = pthread_cond_signal(&cag->mCondVar);
|
OSStatus theError = pthread_cond_signal(&cag->mCondVar);
|
||||||
|
(void)theError;
|
||||||
assert(theError == 0);
|
assert(theError == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SDLOSXCAGuard *new_SDLOSXCAGuard(void)
|
SDLOSXCAGuard *new_SDLOSXCAGuard(void)
|
||||||
{
|
{
|
||||||
|
OSStatus theError;
|
||||||
SDLOSXCAGuard *cag = (SDLOSXCAGuard *) SDL_malloc(sizeof (SDLOSXCAGuard));
|
SDLOSXCAGuard *cag = (SDLOSXCAGuard *) SDL_malloc(sizeof (SDLOSXCAGuard));
|
||||||
if (cag == NULL)
|
if (cag == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -168,10 +175,12 @@ SDLOSXCAGuard *new_SDLOSXCAGuard(void)
|
||||||
SET_SDLOSXCAGUARD_METHOD(Notify);
|
SET_SDLOSXCAGUARD_METHOD(Notify);
|
||||||
#undef SET_SDLOSXCAGUARD_METHOD
|
#undef SET_SDLOSXCAGUARD_METHOD
|
||||||
|
|
||||||
OSStatus theError = pthread_mutex_init(&cag->mMutex, NULL);
|
theError = pthread_mutex_init(&cag->mMutex, NULL);
|
||||||
|
(void)theError;
|
||||||
assert(theError == 0);
|
assert(theError == 0);
|
||||||
|
|
||||||
theError = pthread_cond_init(&cag->mCondVar, NULL);
|
theError = pthread_cond_init(&cag->mCondVar, NULL);
|
||||||
|
(void)theError;
|
||||||
assert(theError == 0);
|
assert(theError == 0);
|
||||||
|
|
||||||
cag->mOwner = 0;
|
cag->mOwner = 0;
|
||||||
|
|
|
@ -69,41 +69,41 @@
|
||||||
#if !defined(__CAGuard_h__)
|
#if !defined(__CAGuard_h__)
|
||||||
#define __CAGuard_h__
|
#define __CAGuard_h__
|
||||||
|
|
||||||
//=============================================================================
|
/*=============================================================================
|
||||||
// Includes
|
Includes
|
||||||
//=============================================================================
|
=============================================================================*/
|
||||||
|
|
||||||
#include <CoreAudio/CoreAudioTypes.h>
|
#include <CoreAudio/CoreAudioTypes.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
|
||||||
//=============================================================================
|
/*=============================================================================
|
||||||
// CAGuard
|
CAGuard
|
||||||
//
|
|
||||||
// This is your typical mutex with signalling implemented via pthreads.
|
This is your typical mutex with signalling implemented via pthreads.
|
||||||
// Lock() will return true if and only if the guard is locked on that call.
|
Lock() will return true if and only if the guard is locked on that call.
|
||||||
// A thread that already has the guard will receive 'false' if it locks it
|
A thread that already has the guard will receive 'false' if it locks it
|
||||||
// again. Use of the stack-based CAGuard::Locker class is highly recommended
|
again. Use of the stack-based CAGuard::Locker class is highly recommended
|
||||||
// to properly manage the recursive nesting. The Wait calls with timeouts
|
to properly manage the recursive nesting. The Wait calls with timeouts
|
||||||
// will return true if and only if the timeout period expired. They will
|
will return true if and only if the timeout period expired. They will
|
||||||
// return false if they receive notification any other way.
|
return false if they receive notification any other way.
|
||||||
//=============================================================================
|
=============================================================================*/
|
||||||
|
|
||||||
typedef struct S_SDLOSXCAGuard
|
typedef struct S_SDLOSXCAGuard
|
||||||
{
|
{
|
||||||
|
|
||||||
// Construction/Destruction
|
/* Construction/Destruction */
|
||||||
//public:
|
/*public:*/
|
||||||
// Actions
|
/* Actions */
|
||||||
//public:
|
/*public:*/
|
||||||
int (*Lock)(struct S_SDLOSXCAGuard *cag);
|
int (*Lock)(struct S_SDLOSXCAGuard *cag);
|
||||||
void (*Unlock)(struct S_SDLOSXCAGuard *cag);
|
void (*Unlock)(struct S_SDLOSXCAGuard *cag);
|
||||||
int (*Try)(struct S_SDLOSXCAGuard *cag, int *outWasLocked); // returns true if lock is free, false if not
|
int (*Try)(struct S_SDLOSXCAGuard *cag, int *outWasLocked); /* returns true if lock is free, false if not */
|
||||||
void (*Wait)(struct S_SDLOSXCAGuard *cag);
|
void (*Wait)(struct S_SDLOSXCAGuard *cag);
|
||||||
void (*Notify)(struct S_SDLOSXCAGuard *cag);
|
void (*Notify)(struct S_SDLOSXCAGuard *cag);
|
||||||
|
|
||||||
// Implementation
|
/* Implementation */
|
||||||
//protected:
|
/*protected:*/
|
||||||
pthread_mutex_t mMutex;
|
pthread_mutex_t mMutex;
|
||||||
pthread_cond_t mCondVar;
|
pthread_cond_t mCondVar;
|
||||||
pthread_t mOwner;
|
pthread_t mOwner;
|
||||||
|
|
|
@ -472,7 +472,7 @@ static int SDL_SYS_CDEject(SDL_CD *cdrom)
|
||||||
|
|
||||||
status = CD_STOPPED;
|
status = CD_STOPPED;
|
||||||
|
|
||||||
// Eject the volume
|
/* Eject the volume */
|
||||||
pb.ioParam.ioNamePtr = NULL;
|
pb.ioParam.ioNamePtr = NULL;
|
||||||
pb.ioParam.ioVRefNum = volumes[cdrom->id];
|
pb.ioParam.ioVRefNum = volumes[cdrom->id];
|
||||||
err = PBUnmountVol((ParamBlockRec *) &pb);
|
err = PBUnmountVol((ParamBlockRec *) &pb);
|
||||||
|
|
|
@ -26,13 +26,11 @@
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "SDL_cpuinfo.h"
|
#include "SDL_cpuinfo.h"
|
||||||
|
|
||||||
#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
|
|
||||||
#include <signal.h>
|
|
||||||
#include <setjmp.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __MACOSX__
|
#ifdef __MACOSX__
|
||||||
#include <sys/sysctl.h> /* For AltiVec check */
|
#include <sys/sysctl.h> /* For AltiVec check */
|
||||||
|
#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
|
||||||
|
#include <signal.h>
|
||||||
|
#include <setjmp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CPU_HAS_RDTSC 0x00000001
|
#define CPU_HAS_RDTSC 0x00000001
|
||||||
|
@ -44,7 +42,7 @@
|
||||||
#define CPU_HAS_SSE2 0x00000080
|
#define CPU_HAS_SSE2 0x00000080
|
||||||
#define CPU_HAS_ALTIVEC 0x00000100
|
#define CPU_HAS_ALTIVEC 0x00000100
|
||||||
|
|
||||||
#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
|
#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__
|
||||||
/* This is the brute force way of detecting instruction sets...
|
/* This is the brute force way of detecting instruction sets...
|
||||||
the idea is borrowed from the libmpeg2 library - thanks!
|
the idea is borrowed from the libmpeg2 library - thanks!
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -48,42 +48,42 @@
|
||||||
|
|
||||||
struct recElement
|
struct recElement
|
||||||
{
|
{
|
||||||
IOHIDElementCookie cookie; // unique value which identifies element, will NOT change
|
IOHIDElementCookie cookie; /* unique value which identifies element, will NOT change */
|
||||||
long min; // reported min value possible
|
long min; /* reported min value possible */
|
||||||
long max; // reported max value possible
|
long max; /* reported max value possible */
|
||||||
/*
|
#if 0
|
||||||
TODO: maybe should handle the following stuff somehow?
|
/* TODO: maybe should handle the following stuff somehow? */
|
||||||
|
|
||||||
long scaledMin; // reported scaled min value possible
|
long scaledMin; /* reported scaled min value possible */
|
||||||
long scaledMax; // reported scaled max value possible
|
long scaledMax; /* reported scaled max value possible */
|
||||||
long size; // size in bits of data return from element
|
long size; /* size in bits of data return from element */
|
||||||
Boolean relative; // are reports relative to last report (deltas)
|
Boolean relative; /* are reports relative to last report (deltas) */
|
||||||
Boolean wrapping; // does element wrap around (one value higher than max is min)
|
Boolean wrapping; /* does element wrap around (one value higher than max is min) */
|
||||||
Boolean nonLinear; // are the values reported non-linear relative to element movement
|
Boolean nonLinear; /* are the values reported non-linear relative to element movement */
|
||||||
Boolean preferredState; // does element have a preferred state (such as a button)
|
Boolean preferredState; /* does element have a preferred state (such as a button) */
|
||||||
Boolean nullState; // does element have null state
|
Boolean nullState; /* does element have null state */
|
||||||
*/
|
#endif /* 0 */
|
||||||
|
|
||||||
/* runtime variables used for auto-calibration */
|
/* runtime variables used for auto-calibration */
|
||||||
long minReport; // min returned value
|
long minReport; /* min returned value */
|
||||||
long maxReport; // max returned value
|
long maxReport; /* max returned value */
|
||||||
|
|
||||||
struct recElement * pNext; // next element in list
|
struct recElement * pNext; /* next element in list */
|
||||||
};
|
};
|
||||||
typedef struct recElement recElement;
|
typedef struct recElement recElement;
|
||||||
|
|
||||||
struct joystick_hwdata
|
struct joystick_hwdata
|
||||||
{
|
{
|
||||||
IOHIDDeviceInterface ** interface; // interface to device, NULL = no interface
|
IOHIDDeviceInterface ** interface; /* interface to device, NULL = no interface */
|
||||||
|
|
||||||
char product[256]; // name of product
|
char product[256]; /* name of product */
|
||||||
long usage; // usage page from IOUSBHID Parser.h which defines general usage
|
long usage; /* usage page from IOUSBHID Parser.h which defines general usage */
|
||||||
long usagePage; // usage within above page from IOUSBHID Parser.h which defines specific usage
|
long usagePage; /* usage within above page from IOUSBHID Parser.h which defines specific usage */
|
||||||
|
|
||||||
long axes; // number of axis (calculated, not reported by device)
|
long axes; /* number of axis (calculated, not reported by device) */
|
||||||
long buttons; // number of buttons (calculated, not reported by device)
|
long buttons; /* number of buttons (calculated, not reported by device) */
|
||||||
long hats; // number of hat switches (calculated, not reported by device)
|
long hats; /* number of hat switches (calculated, not reported by device) */
|
||||||
long elements; // number of total elements (shouldbe total of above) (calculated, not reported by device)
|
long elements; /* number of total elements (shouldbe total of above) (calculated, not reported by device) */
|
||||||
|
|
||||||
recElement* firstAxis;
|
recElement* firstAxis;
|
||||||
recElement* firstButton;
|
recElement* firstButton;
|
||||||
|
@ -92,7 +92,7 @@ struct joystick_hwdata
|
||||||
int removed;
|
int removed;
|
||||||
int uncentered;
|
int uncentered;
|
||||||
|
|
||||||
struct joystick_hwdata* pNext; // next device
|
struct joystick_hwdata* pNext; /* next device */
|
||||||
};
|
};
|
||||||
typedef struct joystick_hwdata recDevice;
|
typedef struct joystick_hwdata recDevice;
|
||||||
|
|
||||||
|
@ -131,32 +131,17 @@ static SInt32 HIDGetElementValue (recDevice *pDevice, recElement *pElement)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// auto user scale
|
/* auto user scale */
|
||||||
return hidEvent.value;
|
return hidEvent.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* similiar to HIDGetElementValue, but auto-calibrates the value before returning it */
|
|
||||||
|
|
||||||
static SInt32 HIDCalibratedValue (recDevice *pDevice, recElement *pElement)
|
|
||||||
{
|
|
||||||
float deviceScale = pElement->max - pElement->min;
|
|
||||||
float readScale = pElement->maxReport - pElement->minReport;
|
|
||||||
SInt32 value = HIDGetElementValue(pDevice, pElement);
|
|
||||||
if (readScale == 0)
|
|
||||||
return value; // no scaling at all
|
|
||||||
else
|
|
||||||
return ((value - pElement->minReport) * deviceScale / readScale) + pElement->min;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* similiar to HIDCalibratedValue but calibrates to an arbitrary scale instead of the elements default scale */
|
|
||||||
|
|
||||||
static SInt32 HIDScaledCalibratedValue (recDevice *pDevice, recElement *pElement, long min, long max)
|
static SInt32 HIDScaledCalibratedValue (recDevice *pDevice, recElement *pElement, long min, long max)
|
||||||
{
|
{
|
||||||
float deviceScale = max - min;
|
float deviceScale = max - min;
|
||||||
float readScale = pElement->maxReport - pElement->minReport;
|
float readScale = pElement->maxReport - pElement->minReport;
|
||||||
SInt32 value = HIDGetElementValue(pDevice, pElement);
|
SInt32 value = HIDGetElementValue(pDevice, pElement);
|
||||||
if (readScale == 0)
|
if (readScale == 0)
|
||||||
return value; // no scaling at all
|
return value; /* no scaling at all */
|
||||||
else
|
else
|
||||||
return ((value - pElement->minReport) * deviceScale / readScale) + min;
|
return ((value - pElement->minReport) * deviceScale / readScale) + min;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +176,7 @@ static IOReturn HIDCreateOpenDeviceInterface (io_object_t hidDevice, recDevice *
|
||||||
kIOCFPlugInInterfaceID, &ppPlugInInterface, &score);
|
kIOCFPlugInInterfaceID, &ppPlugInInterface, &score);
|
||||||
if (kIOReturnSuccess == result)
|
if (kIOReturnSuccess == result)
|
||||||
{
|
{
|
||||||
// Call a method of the intermediate plug-in to create the device interface
|
/* Call a method of the intermediate plug-in to create the device interface */
|
||||||
plugInResult = (*ppPlugInInterface)->QueryInterface (ppPlugInInterface,
|
plugInResult = (*ppPlugInInterface)->QueryInterface (ppPlugInInterface,
|
||||||
CFUUIDGetUUIDBytes (kIOHIDDeviceInterfaceID), (void *) &(pDevice->interface));
|
CFUUIDGetUUIDBytes (kIOHIDDeviceInterfaceID), (void *) &(pDevice->interface));
|
||||||
if (S_OK != plugInResult)
|
if (S_OK != plugInResult)
|
||||||
|
@ -225,15 +210,15 @@ static IOReturn HIDCloseReleaseInterface (recDevice *pDevice)
|
||||||
|
|
||||||
if ((NULL != pDevice) && (NULL != pDevice->interface))
|
if ((NULL != pDevice) && (NULL != pDevice->interface))
|
||||||
{
|
{
|
||||||
// close the interface
|
/* close the interface */
|
||||||
result = (*(pDevice->interface))->close (pDevice->interface);
|
result = (*(pDevice->interface))->close (pDevice->interface);
|
||||||
if (kIOReturnNotOpen == result)
|
if (kIOReturnNotOpen == result)
|
||||||
{
|
{
|
||||||
// do nothing as device was not opened, thus can't be closed
|
/* do nothing as device was not opened, thus can't be closed */
|
||||||
}
|
}
|
||||||
else if (kIOReturnSuccess != result)
|
else if (kIOReturnSuccess != result)
|
||||||
HIDReportErrorNum ("Failed to close IOHIDDeviceInterface.", result);
|
HIDReportErrorNum ("Failed to close IOHIDDeviceInterface.", result);
|
||||||
//release the interface
|
/* release the interface */
|
||||||
result = (*(pDevice->interface))->Release (pDevice->interface);
|
result = (*(pDevice->interface))->Release (pDevice->interface);
|
||||||
if (kIOReturnSuccess != result)
|
if (kIOReturnSuccess != result)
|
||||||
HIDReportErrorNum ("Failed to release IOHIDDeviceInterface.", result);
|
HIDReportErrorNum ("Failed to release IOHIDDeviceInterface.", result);
|
||||||
|
@ -559,7 +544,7 @@ static recDevice *HIDDisposeDevice (recDevice **ppDevice)
|
||||||
recDevice *pDeviceNext = NULL;
|
recDevice *pDeviceNext = NULL;
|
||||||
if (*ppDevice)
|
if (*ppDevice)
|
||||||
{
|
{
|
||||||
// save next device prior to disposing of this device
|
/* save next device prior to disposing of this device */
|
||||||
pDeviceNext = (*ppDevice)->pNext;
|
pDeviceNext = (*ppDevice)->pNext;
|
||||||
|
|
||||||
/* free element lists */
|
/* free element lists */
|
||||||
|
@ -658,8 +643,9 @@ int SDL_SYS_JoystickInit(void)
|
||||||
|
|
||||||
/* dump device object, it is no longer needed */
|
/* dump device object, it is no longer needed */
|
||||||
result = IOObjectRelease (ioHIDDeviceObject);
|
result = IOObjectRelease (ioHIDDeviceObject);
|
||||||
// if (KERN_SUCCESS != result)
|
/* if (KERN_SUCCESS != result)
|
||||||
// HIDReportErrorNum ("IOObjectRelease error with ioHIDDeviceObject.", result);
|
HIDReportErrorNum ("IOObjectRelease error with ioHIDDeviceObject.", result);
|
||||||
|
*/
|
||||||
|
|
||||||
/* Filter device list to non-keyboard/mouse stuff */
|
/* Filter device list to non-keyboard/mouse stuff */
|
||||||
if ( (device->usagePage != kHIDPage_GenericDesktop) ||
|
if ( (device->usagePage != kHIDPage_GenericDesktop) ||
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#ifdef __MACOSX__
|
#ifdef __MACOSX__
|
||||||
#define USE_NAMED_SEMAPHORES 1
|
#define USE_NAMED_SEMAPHORES 1
|
||||||
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct SDL_semaphore {
|
struct SDL_semaphore {
|
||||||
|
|
|
@ -502,7 +502,7 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt,
|
||||||
if (!dstfmt) {
|
if (!dstfmt) {
|
||||||
dstfmt = &default_pixel_format;
|
dstfmt = &default_pixel_format;
|
||||||
}
|
}
|
||||||
vector unsigned char plus = VECUINT8_LITERAL
|
const vector unsigned char plus = VECUINT8_LITERAL
|
||||||
( 0x00, 0x00, 0x00, 0x00,
|
( 0x00, 0x00, 0x00, 0x00,
|
||||||
0x04, 0x04, 0x04, 0x04,
|
0x04, 0x04, 0x04, 0x04,
|
||||||
0x08, 0x08, 0x08, 0x08,
|
0x08, 0x08, 0x08, 0x08,
|
||||||
|
@ -863,8 +863,8 @@ static void Blit32to32PixelAlphaAltivec(SDL_BlitInfo *info)
|
||||||
}
|
}
|
||||||
ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
|
ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
|
||||||
if (width > 0) {
|
if (width > 0) {
|
||||||
// vsrcPermute
|
/* vsrcPermute */
|
||||||
// vdstPermute
|
/* vdstPermute */
|
||||||
int extrawidth = (width % 4);
|
int extrawidth = (width % 4);
|
||||||
vector unsigned char valigner = VEC_ALIGNER(srcp);
|
vector unsigned char valigner = VEC_ALIGNER(srcp);
|
||||||
vector unsigned char vs = (vector unsigned char)vec_ld(0, srcp);
|
vector unsigned char vs = (vector unsigned char)vec_ld(0, srcp);
|
||||||
|
|
|
@ -119,7 +119,7 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt,
|
||||||
if (!dstfmt) {
|
if (!dstfmt) {
|
||||||
dstfmt = &default_pixel_format;
|
dstfmt = &default_pixel_format;
|
||||||
}
|
}
|
||||||
vector unsigned char plus = VECUINT8_LITERAL(
|
const vector unsigned char plus = VECUINT8_LITERAL(
|
||||||
0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00,
|
||||||
0x04, 0x04, 0x04, 0x04,
|
0x04, 0x04, 0x04, 0x04,
|
||||||
0x08, 0x08, 0x08, 0x08,
|
0x08, 0x08, 0x08, 0x08,
|
||||||
|
@ -559,10 +559,11 @@ static void Blit32to32KeyAltivec(SDL_BlitInfo *info)
|
||||||
vpermute = calc_swizzle32(srcfmt, dstfmt);
|
vpermute = calc_swizzle32(srcfmt, dstfmt);
|
||||||
if (info->d_width < 16) {
|
if (info->d_width < 16) {
|
||||||
if(copy_alpha) {
|
if(copy_alpha) {
|
||||||
return BlitNtoNKeyCopyAlpha(info);
|
BlitNtoNKeyCopyAlpha(info);
|
||||||
} else {
|
} else {
|
||||||
return BlitNtoNKey(info);
|
BlitNtoNKey(info);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
vzero = vec_splat_u8(0);
|
vzero = vec_splat_u8(0);
|
||||||
if (alpha) {
|
if (alpha) {
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
|
|
||||||
#include "SDL_QuartzVideo.h"
|
#include "SDL_QuartzVideo.h"
|
||||||
|
|
||||||
#include <IOKit/IOMessage.h> // For wake from sleep detection
|
#include <IOKit/IOMessage.h> /* For wake from sleep detection */
|
||||||
#include <IOKit/pwr_mgt/IOPMLib.h> // For wake from sleep detection
|
#include <IOKit/pwr_mgt/IOPMLib.h> /* For wake from sleep detection */
|
||||||
#include "SDL_QuartzKeys.h"
|
#include "SDL_QuartzKeys.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -681,26 +681,28 @@ void QZ_RegisterForSleepNotifications (_THIS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Try to map Quartz mouse buttons to SDL's lingo...
|
/* Try to map Quartz mouse buttons to SDL's lingo... */
|
||||||
static int QZ_OtherMouseButtonToSDL(int button)
|
static int QZ_OtherMouseButtonToSDL(int button)
|
||||||
{
|
{
|
||||||
switch (button)
|
switch (button)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return(SDL_BUTTON_LEFT); // 1
|
return(SDL_BUTTON_LEFT); /* 1 */
|
||||||
case 1:
|
case 1:
|
||||||
return(SDL_BUTTON_RIGHT); // 3
|
return(SDL_BUTTON_RIGHT); /* 3 */
|
||||||
case 2:
|
case 2:
|
||||||
return(SDL_BUTTON_MIDDLE); // 2
|
return(SDL_BUTTON_MIDDLE); /* 2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
// >= 3: skip 4 & 5, since those are the SDL mousewheel buttons.
|
/* >= 3: skip 4 & 5, since those are the SDL mousewheel buttons. */
|
||||||
return(button + 3);
|
return(button + 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QZ_PumpEvents (_THIS)
|
void QZ_PumpEvents (_THIS)
|
||||||
{
|
{
|
||||||
|
static Uint32 screensaverTicks = 0;
|
||||||
|
Uint32 nowTicks;
|
||||||
int firstMouseEvent;
|
int firstMouseEvent;
|
||||||
CGMouseDelta dx, dy;
|
CGMouseDelta dx, dy;
|
||||||
|
|
||||||
|
@ -713,8 +715,7 @@ void QZ_PumpEvents (_THIS)
|
||||||
return; /* don't do anything if there's no screen surface. */
|
return; /* don't do anything if there's no screen surface. */
|
||||||
|
|
||||||
/* Update activity every five seconds to prevent screensaver. --ryan. */
|
/* Update activity every five seconds to prevent screensaver. --ryan. */
|
||||||
static Uint32 screensaverTicks = 0;
|
nowTicks = SDL_GetTicks();
|
||||||
Uint32 nowTicks = SDL_GetTicks();
|
|
||||||
if ((nowTicks - screensaverTicks) > 5000)
|
if ((nowTicks - screensaverTicks) > 5000)
|
||||||
{
|
{
|
||||||
UpdateSystemActivity(UsrActivity);
|
UpdateSystemActivity(UsrActivity);
|
||||||
|
|
|
@ -682,7 +682,7 @@ static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//[ qz_window setReleasedWhenClosed:YES ];
|
/*[ qz_window setReleasedWhenClosed:YES ];*/
|
||||||
QZ_SetCaption(this, this->wm_title, this->wm_icon);
|
QZ_SetCaption(this, this->wm_title, this->wm_icon);
|
||||||
[ qz_window setAcceptsMouseMovedEvents:YES ];
|
[ qz_window setAcceptsMouseMovedEvents:YES ];
|
||||||
[ qz_window setViewsNeedDisplay:NO ];
|
[ qz_window setViewsNeedDisplay:NO ];
|
||||||
|
@ -759,7 +759,7 @@ static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
|
||||||
|
|
||||||
int hOffset = [ window_view frame ].origin.x;
|
int hOffset = [ window_view frame ].origin.x;
|
||||||
|
|
||||||
current->pixels += (vOffset * current->pitch) + hOffset * (qdbpp/8);
|
current->pixels = (Uint8 *)current->pixels + (vOffset * current->pitch) + hOffset * (qdbpp/8);
|
||||||
}
|
}
|
||||||
this->UpdateRects = QZ_UpdateRects;
|
this->UpdateRects = QZ_UpdateRects;
|
||||||
this->LockHWSurface = QZ_LockWindow;
|
this->LockHWSurface = QZ_LockWindow;
|
||||||
|
@ -921,7 +921,7 @@ static int QZ_ThreadFlip (_THIS) {
|
||||||
* a fullscreen resolution smaller than the hardware could supply
|
* a fullscreen resolution smaller than the hardware could supply
|
||||||
* so SDL is centering it in a bigger resolution)...
|
* so SDL is centering it in a bigger resolution)...
|
||||||
*/
|
*/
|
||||||
dst = CGDisplayBaseAddress (display_id) + SDL_VideoSurface->offset;
|
dst = (Uint8 *)CGDisplayBaseAddress (display_id) + SDL_VideoSurface->offset;
|
||||||
src = current_buffer + SDL_VideoSurface->offset;
|
src = current_buffer + SDL_VideoSurface->offset;
|
||||||
len = SDL_VideoSurface->w * SDL_VideoSurface->format->BytesPerPixel;
|
len = SDL_VideoSurface->w * SDL_VideoSurface->format->BytesPerPixel;
|
||||||
h = SDL_VideoSurface->h;
|
h = SDL_VideoSurface->h;
|
||||||
|
@ -1025,7 +1025,7 @@ static void QZ_DirectUpdate (_THIS, int num_rects, SDL_Rect *rects) {
|
||||||
who supplied sample code for Carbon.
|
who supplied sample code for Carbon.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#define TEST_OBSCURED 1
|
/*#define TEST_OBSCURED 1*/
|
||||||
|
|
||||||
#if TEST_OBSCURED
|
#if TEST_OBSCURED
|
||||||
#include "CGS.h"
|
#include "CGS.h"
|
||||||
|
@ -1075,7 +1075,6 @@ static int QZ_IsWindowObscured (NSWindow *window) {
|
||||||
|
|
||||||
CGSRect contentRect;
|
CGSRect contentRect;
|
||||||
int windowNumber;
|
int windowNumber;
|
||||||
//int isMainWindow;
|
|
||||||
int firstDockIcon;
|
int firstDockIcon;
|
||||||
int dockIconCacheMiss;
|
int dockIconCacheMiss;
|
||||||
int windowContentOffset;
|
int windowContentOffset;
|
||||||
|
@ -1106,7 +1105,6 @@ static int QZ_IsWindowObscured (NSWindow *window) {
|
||||||
windowContentOffset = 0;
|
windowContentOffset = 0;
|
||||||
|
|
||||||
windowNumber = [ window windowNumber ];
|
windowNumber = [ window windowNumber ];
|
||||||
//isMainWindow = [ window isMainWindow ];
|
|
||||||
|
|
||||||
/* The window list is sorted according to order on the screen */
|
/* The window list is sorted according to order on the screen */
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
|
@ -144,7 +144,7 @@ static void QZ_SetPortAlphaOpaque () {
|
||||||
|
|
||||||
int hOffset = newViewFrame.origin.x;
|
int hOffset = newViewFrame.origin.x;
|
||||||
|
|
||||||
SDL_VideoSurface->pixels += (vOffset * SDL_VideoSurface->pitch) + hOffset * (device_bpp/8);
|
SDL_VideoSurface->pixels = (Uint8 *)SDL_VideoSurface->pixels + (vOffset * SDL_VideoSurface->pitch) + hOffset * (device_bpp/8);
|
||||||
}
|
}
|
||||||
|
|
||||||
UnlockPortBits ( thePort );
|
UnlockPortBits ( thePort );
|
||||||
|
@ -177,7 +177,7 @@ static void QZ_SetPortAlphaOpaque () {
|
||||||
/* restore cached image, since it may not be current, post expose event too */
|
/* restore cached image, since it may not be current, post expose event too */
|
||||||
[ self restoreCachedImage ];
|
[ self restoreCachedImage ];
|
||||||
|
|
||||||
//SDL_PrivateExpose ();
|
/*SDL_PrivateExpose ();*/
|
||||||
|
|
||||||
SDL_PrivateAppActive (1, SDL_APPACTIVE);
|
SDL_PrivateAppActive (1, SDL_APPACTIVE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue