Commit c0aec157 authored by Sam Lantinga's avatar Sam Lantinga

Cleaning up warnings on MacOS X

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401491
parent 6ef737be
......@@ -48,7 +48,7 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo;
/* This is the structure for custom window manager events */
#if SDL_VIDEO_DRIVER_X11
#if defined(__APPLE__) && defined(__MACH__)
// conflicts with Quickdraw.h
/* conflicts with Quickdraw.h */
#define Cursor X11Cursor
#endif
......@@ -56,7 +56,7 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo;
#include <X11/Xatom.h>
#if defined(__APPLE__) && defined(__MACH__)
// matches the re-define above
/* matches the re-define above */
#undef Cursor
#endif
......
......@@ -253,14 +253,14 @@ const SDL_version * SDL_Linked_Version(void)
}
#if defined(__OS2__)
// Building for OS/2
/* Building for OS/2 */
#ifdef __WATCOMC__
#define INCL_DOSERRORS
#define INCL_DOSEXCEPTIONS
#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,
PEXCEPTIONREGISTRATIONRECORD pERegRec,
PCONTEXTRECORD pCtxRec,
......@@ -273,7 +273,7 @@ ULONG _System SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec,
if (pERepRec->fHandlerFlags & EH_NESTED_CALL)
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) &&
(pERepRec->ExceptionNum != XCPT_BREAKPOINT) &&
(pERepRec->ExceptionNum != XCPT_SINGLE_STEP)
......@@ -281,7 +281,7 @@ ULONG _System SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec,
{
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
printf("[SDL_Main_ExceptionHandler] : Calling SDL_CloseAudio()!\n");
#endif
......@@ -294,28 +294,28 @@ ULONG _System SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec,
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)
{
if (termination)
{
#ifdef DEBUG_BUILD
// printf("[SDL DLL Unintialization] : Removing exception handler\n");
/* printf("[SDL DLL Unintialization] : Removing exception handler\n"); */
#endif
DosUnsetExceptionHandler(&SDL_Main_xcpthand);
return 1;
} else
{
#ifdef DEBUG_BUILD
// Make stdout and stderr unbuffered!
/* Make stdout and stderr unbuffered! */
setbuf(stdout, NULL);
setbuf(stderr, NULL);
#endif
// Fire up exception handler
/* Fire up exception handler */
#ifdef DEBUG_BUILD
// printf("[SDL DLL Initialization] : Setting exception handler\n");
/* printf("[SDL DLL Initialization] : Setting exception handler\n"); */
#endif
// Set exception handler
/* Set exception handler */
DosSetExceptionHandler(&SDL_Main_xcpthand);
return 1;
......
......@@ -29,7 +29,7 @@
#include "SDL_sysaudio.h"
#ifdef __OS2__
// We'll need the DosSetPriority() API!
/* We'll need the DosSetPriority() API! */
#define INCL_DOSPROCESS
#include <os2.h>
#endif
......@@ -178,8 +178,8 @@ int SDL_RunAudio(void *audiop)
#endif
#ifdef __OS2__
// Increase the priority of this thread to make sure that
// the audio will be continuous all the time!
/* Increase the priority of this thread to make sure that
the audio will be continuous all the time! */
#ifdef USE_DOSSETPRIORITY
if (SDL_getenv("SDL_USE_TIMECRITICAL_AUDIO"))
{
......
......@@ -8,8 +8,7 @@
*/
#include "SDL_config.h"
#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
void SDL_MixAudio_MMX_S16(char* ,char* ,unsigned int ,int );
void SDL_MixAudio_MMX_S8(char* ,char* ,unsigned int ,int );
#endif
......
......@@ -23,14 +23,14 @@
#if ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
// headers for MMX assembler version of SDL_MixAudio
// Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
// Converted to Intel ASM notation by Cth
// 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
/* headers for MMX assembler version of SDL_MixAudio
Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
Converted to Intel ASM notation by Cth
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
*/
void SDL_MixAudio_MMX_S16_VC(char* ,char* ,unsigned int ,int );
void SDL_MixAudio_MMX_S8_VC(char* ,char* ,unsigned int ,int );
#endif
......@@ -433,7 +433,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
was_error = 1;
goto done;
}
headerDiff += sizeof(Uint32); // for WAVE
headerDiff += sizeof(Uint32); /* for WAVE */
/* Read the audio data format chunk */
chunk.data = NULL;
......@@ -446,7 +446,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
was_error = 1;
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);
} 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;
if(chunk.magic != DATA) headerDiff += lenread + 2 * sizeof(Uint32);
} 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_decode(audio_buf, audio_len) < 0 ) {
......@@ -554,7 +554,7 @@ done:
if ( freesrc ) {
SDL_RWclose(src);
} 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);
}
}
......
......@@ -128,8 +128,8 @@ static OSStatus audioCallback (void *inRefCon,
len = bufferSize - bufferOffset;
if (len > remaining)
len = remaining;
SDL_memcpy(ptr, buffer + bufferOffset, len);
ptr += len;
SDL_memcpy(ptr, (char *)buffer + bufferOffset, len);
ptr = (char *)ptr + len;
remaining -= len;
bufferOffset += len;
}
......
......@@ -24,9 +24,9 @@
*/
#include "SDL_config.h"
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// AudioFilePlayer.cpp
//
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AudioFilePlayer.cpp
*/
#include "AudioFilePlayer.h"
/*
......@@ -61,7 +61,7 @@ static void PrintStreamDesc (AudioStreamBasicDescription *inDesc)
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)
return 0 ;
......@@ -70,17 +70,17 @@ static int AudioFilePlayer_SetDestination (AudioFilePlayer *afp, AudioUnit *inD
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;
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
// a v1 audio unit will have a type of 'aunt'
// a v2 audio unit will have one of several different types.
/* we're going to use this to know which convert routine to call
a v1 audio unit will have a type of 'aunt'
a v2 audio unit will have one of several different types. */
if (desc.componentType != kAudioUnitComponentType) {
result = badComponentInstance;
//THROW_RESULT("BAD COMPONENT")
/*THROW_RESULT("BAD COMPONENT")*/
if (result) return 0;
}
......@@ -91,7 +91,7 @@ static int AudioFilePlayer_SetDestination (AudioFilePlayer *afp, AudioUnit *inD
0,
&afp->mFileDescription,
sizeof (afp->mFileDescription));
//THROW_RESULT("AudioUnitSetProperty")
/*THROW_RESULT("AudioUnitSetProperty")*/
if (result) return 0;
return 1;
}
......@@ -170,7 +170,7 @@ static int AudioFilePlayer_Connect(AudioFilePlayer *afp)
if (!afp->mAudioFileManager->DoConnect(afp->mAudioFileManager))
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.inputProcRefCon = afp->mAudioFileManager;
......@@ -180,15 +180,15 @@ static int AudioFilePlayer_Connect(AudioFilePlayer *afp)
0,
&afp->mInputCallback,
sizeof(afp->mInputCallback));
if (result) return 0; //THROW_RESULT("AudioUnitSetProperty")
if (result) return 0; /*THROW_RESULT("AudioUnitSetProperty")*/
afp->mConnected = 1;
}
return 1;
}
// warning noted, now please go away ;-)
// #warning This should redirect the calling of notification code to some other thread
/* warning noted, now please go away ;-) */
/* #warning This should redirect the calling of notification code to some other thread */
static void AudioFilePlayer_DoNotification (AudioFilePlayer *afp, OSStatus inStatus)
{
if (afp->mNotifier) {
......@@ -243,52 +243,53 @@ static int AudioFilePlayer_OpenFile (AudioFilePlayer *afp, const FSRef *inRef
ByteCount actual;
SInt64 offset;
// Open the data fork of the input file
/* Open the data fork of the input file */
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);
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);
if (result) return 0; //THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork")
if (result) return 0; /*THROW_RESULT("AudioFilePlayer::OpenFile(): FSReadFork")*/
if (chunkHeader.ckID != 'FORM') {
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') {
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
// 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.
// TODO: Parse the COMM chunk we currently skip to fill in mFileDescription.
/* 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
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.
*/
offset = 0;
do {
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;
} while (chunk.ckID != 'SSND');
// Read the header of the SSND chunk. After this, we are positioned right
// at the start of the audio data.
/* Read the header of the SSND chunk. After this, we are positioned right
at the start of the audio data. */
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);
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;
// File format
/* File format */
afp->mFileDescription.mSampleRate = 44100;
afp->mFileDescription.mFormatID = kAudioFormatLinearPCM;
afp->mFileDescription.mFormatFlags = kLinearPCMFormatFlagIsPacked | kLinearPCMFormatFlagIsSignedInteger;
......@@ -331,7 +332,7 @@ AudioFilePlayer *new_AudioFilePlayer (const FSRef *inFileRef)
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);
#if DEBUG
......
......@@ -24,9 +24,9 @@
*/
#include "SDL_config.h"
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// AudioFilePlayer.h
//
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AudioFilePlayer.h
*/
#ifndef __AudioFilePlayer_H__
#define __AudioFilePlayer_H__
......@@ -62,12 +62,12 @@ struct S_AudioFileManager;
#pragma mark __________ AudioFilePlayer
typedef struct S_AudioFilePlayer
{
//public:
/*public:*/
int (*SetDestination)(struct S_AudioFilePlayer *afp, AudioUnit *inDestUnit);
void (*SetNotifier)(struct S_AudioFilePlayer *afp, AudioFilePlayNotifier inNotifier, void *inRefCon);
void (*SetStartFrame)(struct S_AudioFilePlayer *afp, int frame); // seek in the file
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 (*SetStartFrame)(struct S_AudioFilePlayer *afp, int frame); /* seek in the file */
int (*GetCurrentFrame)(struct S_AudioFilePlayer *afp); /* get the current frame position */
void (*SetStopFrame)(struct S_AudioFilePlayer *afp, int frame); /* set limit in the file */
int (*Connect)(struct S_AudioFilePlayer *afp);
void (*Disconnect)(struct S_AudioFilePlayer *afp);
void (*DoNotification)(struct S_AudioFilePlayer *afp, OSStatus inError);
......@@ -75,7 +75,7 @@ typedef struct S_AudioFilePlayer
AudioUnit (*GetDestUnit)(struct S_AudioFilePlayer *afp);
void (*Print)(struct S_AudioFilePlayer *afp);
//private:
/*private:*/
AudioUnit mPlayUnit;
SInt16 mForkRefNum;
......@@ -106,19 +106,19 @@ void delete_AudioFilePlayer(AudioFilePlayer *afp);
#pragma mark __________ AudioFileManager
typedef struct S_AudioFileManager
{
//public:
// this method should NOT be called by an object of this class
// as it is called by the parent's Disconnect() method
/*public:*/
/* this method should NOT be called by an object of this class
as it is called by the parent's Disconnect() method */
void (*Disconnect)(struct S_AudioFileManager *afm);
int (*DoConnect)(struct S_AudioFileManager *afm);
OSStatus (*Read)(struct S_AudioFileManager *afm, char *buffer, UInt32 *len);
const char* (*GetFileBuffer)(struct S_AudioFileManager *afm);
const AudioFilePlayer *(*GetParent)(struct S_AudioFileManager *afm);
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
void (*SetEndOfFile)(struct S_AudioFileManager *afm, SInt64 pos); // set the "EOF" (will behave just like it reached eof)
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 */
void (*SetEndOfFile)(struct S_AudioFileManager *afm, SInt64 pos); /* set the "EOF" (will behave just like it reached eof) */
//protected:
/*protected:*/
AudioFilePlayer* mParent;
SInt16 mForkRefNum;
SInt64 mAudioDataOffset;
......@@ -137,20 +137,20 @@ typedef struct S_AudioFileManager
void* mTmpBuffer;
UInt32 mBufferSize;
UInt32 mBufferOffset;
//public:
/*public:*/
UInt32 mChunkSize;
SInt64 mFileLength;
SInt64 mReadFilePosition;
int mWriteToFirstBuffer;
int mFinishedReadingData;
//protected:
/*protected:*/
OSStatus (*Render)(struct S_AudioFileManager *afm, AudioBuffer *ioData);
OSStatus (*GetFileData)(struct S_AudioFileManager *afm, void** inOutData, UInt32 *inOutDataSize);
void (*AfterRender)(struct S_AudioFileManager *afm);
//public:
//static
/*public:*/
/*static*/
OSStatus (*FileInputProc)(void *inRefCon,
AudioUnitRenderActionFlags inActionFlags,
const AudioTimeStamp *inTimeStamp,
......
This diff is collapsed.
This diff is collapsed.
......@@ -44,7 +44,7 @@ void Lock ();
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 ();
......
......@@ -66,9 +66,9 @@
=============================================================================*/
//=============================================================================
// Includes
//=============================================================================
/*=============================================================================
Includes
=============================================================================*/
/*
#include <stdio.h>
......@@ -77,7 +77,7 @@
*/
#include "SDL_stdinc.h"
//#define NDEBUG 1
/*#define NDEBUG 1*/
/*
#include <assert.h>
*/
......@@ -86,10 +86,10 @@
#include "SDLOSXCAGuard.h"
//#warning Need a try-based Locker too
//=============================================================================
// SDLOSXCAGuard
//=============================================================================
/*#warning Need a try-based Locker too*/
/*=============================================================================
SDLOSXCAGuard
=============================================================================*/
static int SDLOSXCAGuard_Lock(SDLOSXCAGuard *cag)
{
......@@ -98,6 +98,7 @@ static int SDLOSXCAGuard_Lock(SDLOSXCAGuard *cag)
if(pthread_self() != cag->mOwner)
{
OSStatus theError = pthread_mutex_lock(&cag->mMutex);
(void)theError;
assert(theError == 0);
cag->mOwner = pthread_self();
theAnswer = 1;
......@@ -108,10 +109,12 @@ static int SDLOSXCAGuard_Lock(SDLOSXCAGuard *cag)
static void SDLOSXCAGuard_Unlock(SDLOSXCAGuard *cag)
{
OSStatus theError;
assert(pthread_self() == cag->mOwner);
cag->mOwner = 0;
OSStatus theError = pthread_mutex_unlock(&cag->mMutex);
theError = pthread_mutex_unlock(&cag->mMutex);
(void)theError;
assert(theError == 0);
}
......@@ -137,11 +140,13 @@ static int SDLOSXCAGuard_Try (SDLOSXCAGuard *cag, int *outWasLocked)
static void SDLOSXCAGuard_Wait(SDLOSXCAGuard *cag)
{
OSStatus theError;
assert(pthread_self() == cag->mOwner);
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);
cag->mOwner = pthread_self();
}
......@@ -149,12 +154,14 @@ static void SDLOSXCAGuard_Wait(SDLOSXCAGuard *cag)
static void SDLOSXCAGuard_Notify(SDLOSXCAGuard *cag)
{
OSStatus theError = pthread_cond_signal(&cag->mCondVar);
(void)theError;
assert(theError == 0);
}
SDLOSXCAGuard *new_SDLOSXCAGuard(void)
{
OSStatus theError;
SDLOSXCAGuard *cag = (SDLOSXCAGuard *) SDL_malloc(sizeof (SDLOSXCAGuard));
if (cag == NULL)
return NULL;
......@@ -168,10 +175,12 @@ SDLOSXCAGuard *new_SDLOSXCAGuard(void)
SET_SDLOSXCAGUARD_METHOD(Notify);
#undef SET_SDLOSXCAGUARD_METHOD
OSStatus theError = pthread_mutex_init(&cag->mMutex, NULL);
theError = pthread_mutex_init(&cag->mMutex, NULL);
(void)theError;
assert(theError == 0);
theError = pthread_cond_init(&cag->mCondVar, NULL);
(void)theError;
assert(theError == 0);
cag->mOwner = 0;
......
......@@ -69,41 +69,41 @@
#if !defined(__CAGuard_h__)
#define __CAGuard_h__
//=============================================================================
// Includes
//=============================================================================
/*=============================================================================
Includes
=============================================================================*/
#include <CoreAudio/CoreAudioTypes.h>
#include <pthread.h>
//=============================================================================
// CAGuard
//
// 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.
// 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
// to properly manage the recursive nesting. The Wait calls with timeouts
// will return true if and only if the timeout period expired. They will
// return false if they receive notification any other way.
//=============================================================================
/*=============================================================================
CAGuard
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.
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
to properly manage the recursive nesting. The Wait calls with timeouts
will return true if and only if the timeout period expired. They will
return false if they receive notification any other way.
=============================================================================*/
typedef struct S_SDLOSXCAGuard
{
// Construction/Destruction
//public:
// Actions
//public:
/* Construction/Destruction */
/*public:*/
/* Actions */
/*public:*/
int (*Lock)(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 (*Notify)(struct S_SDLOSXCAGuard *cag);
// Implementation
//protected:
/* Implementation */
/*protected:*/
pthread_mutex_t mMutex;
pthread_cond_t mCondVar;
pthread_t mOwner;
......
......@@ -472,7 +472,7 @@ static int SDL_SYS_CDEject(SDL_CD *cdrom)
status = CD_STOPPED;
// Eject the volume
/* Eject the volume */
pb.ioParam.ioNamePtr = NULL;
pb.ioParam.ioVRefNum = volumes[cdrom->id];
err = PBUnmountVol((ParamBlockRec *) &pb);
......
......@@ -26,13 +26,11 @@
#include "SDL.h"
#include "SDL_cpuinfo.h"
#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
#include <signal.h>
#include <setjmp.h>
#endif
#ifdef __MACOSX__
#include <sys/sysctl.h> /* For AltiVec check */
#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
#include <signal.h>
#include <setjmp.h>
#endif
#define CPU_HAS_RDTSC 0x00000001
......@@ -44,7 +42,7 @@
#define CPU_HAS_SSE2 0x00000080
#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...
the idea is borrowed from the libmpeg2 library - thanks!
*/
......
......@@ -48,42 +48,42 @@
struct recElement
{
IOHIDElementCookie cookie; // unique value which identifies element, will NOT change
long min; // reported min value possible
long max; // reported max value possible
/*
TODO: maybe should handle the following stuff somehow?
long scaledMin; // reported scaled min value possible
long scaledMax; // reported scaled max value possible
long size; // size in bits of data return from element
Boolean relative; // are reports relative to last report (deltas)
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 preferredState; // does element have a preferred state (such as a button)
Boolean nullState; // does element have null state
*/
IOHIDElementCookie cookie; /* unique value which identifies element, will NOT change */
long min; /* reported min value possible */
long max; /* reported max value possible */
#if 0
/* TODO: maybe should handle the following stuff somehow? */
long scaledMin; /* reported scaled min value possible */
long scaledMax; /* reported scaled max value possible */
long size; /* size in bits of data return from element */
Boolean relative; /* are reports relative to last report (deltas) */
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 preferredState; /* does element have a preferred state (such as a button) */
Boolean nullState; /* does element have null state */
#endif /* 0 */
/* runtime variables used for auto-calibration */
long minReport; // min returned value
long maxReport; // max returned value
long minReport; /* min 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;
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
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
char product[256]; /* name of product */
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 axes; // number of axis (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 elements; // number of total elements (shouldbe total of above) (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 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) */
recElement* firstAxis;
recElement* firstButton;
......@@ -92,7 +92,7 @@ struct joystick_hwdata
int removed;
int uncentered;
struct joystick_hwdata* pNext; // next device
struct joystick_hwdata* pNext; /* next device */
};
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;
}
/* 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)
{
float deviceScale = max - min;
float readScale = pElement->maxReport - pElement->minReport;
SInt32 value = HIDGetElementValue(pDevice, pElement);
if (readScale == 0)
return value; // no scaling at all
return value; /* no scaling at all */
else
return ((value - pElement->minReport) * deviceScale / readScale) + min;
}
......@@ -191,7 +176,7 @@ static IOReturn HIDCreateOpenDeviceInterface (io_object_t hidDevice, recDevice *
kIOCFPlugInInterfaceID, &ppPlugInInterface, &score);
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,
CFUUIDGetUUIDBytes (kIOHIDDeviceInterfaceID), (void *) &(pDevice->interface));
if (S_OK != plugInResult)
......@@ -225,15 +210,15 @@ static IOReturn HIDCloseReleaseInterface (recDevice *pDevice)
if ((NULL != pDevice) && (NULL != pDevice->interface))
{
// close the interface
/* close the interface */
result = (*(pDevice->interface))->close (pDevice->interface);
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)
HIDReportErrorNum ("Failed to close IOHIDDeviceInterface.", result);
//release the interface
/* release the interface */
result = (*(pDevice->interface))->Release (pDevice->interface);
if (kIOReturnSuccess != result)
HIDReportErrorNum ("Failed to release IOHIDDeviceInterface.", result);
......@@ -559,7 +544,7 @@ static recDevice *HIDDisposeDevice (recDevice **ppDevice)
recDevice *pDeviceNext = NULL;
if (*ppDevice)
{
// save next device prior to disposing of this device
/* save next device prior to disposing of this device */
pDeviceNext = (*ppDevice)->pNext;
/* free element lists */
......@@ -658,8 +643,9 @@ int SDL_SYS_JoystickInit(void)
/* dump device object, it is no longer needed */
result = IOObjectRelease (ioHIDDeviceObject);
// if (KERN_SUCCESS != result)
// HIDReportErrorNum ("IOObjectRelease error with ioHIDDeviceObject.", result);
/* if (KERN_SUCCESS != result)
HIDReportErrorNum ("IOObjectRelease error with ioHIDDeviceObject.", result);
*/
/* Filter device list to non-keyboard/mouse stuff */
if ( (device->usagePage != kHIDPage_GenericDesktop) ||
......
......@@ -31,6 +31,7 @@
#ifdef __MACOSX__
#define USE_NAMED_SEMAPHORES 1
#include <unistd.h>
#endif
struct SDL_semaphore {
......
......@@ -502,7 +502,7 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt,
if (!dstfmt) {
dstfmt = &default_pixel_format;
}
vector unsigned char plus = VECUINT8_LITERAL
const vector unsigned char plus = VECUINT8_LITERAL
( 0x00, 0x00, 0x00, 0x00,
0x04, 0x04, 0x04, 0x04,
0x08, 0x08, 0x08, 0x08,
......@@ -863,8 +863,8 @@ static void Blit32to32PixelAlphaAltivec(SDL_BlitInfo *info)
}
ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width);
if (width > 0) {
// vsrcPermute
// vdstPermute
/* vsrcPermute */
/* vdstPermute */
int extrawidth = (width % 4);
vector unsigned char valigner = VEC_ALIGNER(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) {
dstfmt = &default_pixel_format;
}
vector unsigned char plus = VECUINT8_LITERAL(
const vector unsigned char plus = VECUINT8_LITERAL(
0x00, 0x00, 0x00, 0x00,
0x04, 0x04, 0x04, 0x04,
0x08, 0x08, 0x08, 0x08,
......@@ -559,10 +559,11 @@ static void Blit32to32KeyAltivec(SDL_BlitInfo *info)
vpermute = calc_swizzle32(srcfmt, dstfmt);
if (info->d_width < 16) {
if(copy_alpha) {
return BlitNtoNKeyCopyAlpha(info);
BlitNtoNKeyCopyAlpha(info);
} else {
return BlitNtoNKey(info);
BlitNtoNKey(info);
}
return;
}
vzero = vec_splat_u8(0);
if (alpha) {
......
......@@ -23,8 +23,8 @@
#include "SDL_QuartzVideo.h"
#include <IOKit/IOMessage.h> // For wake from sleep detection
#include <IOKit/pwr_mgt/IOPMLib.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 "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)
{
switch (button)
{
case 0:
return(SDL_BUTTON_LEFT); // 1
return(SDL_BUTTON_LEFT); /* 1 */
case 1:
return(SDL_BUTTON_RIGHT); // 3
return(SDL_BUTTON_RIGHT); /* 3 */
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);
}
void QZ_PumpEvents (_THIS)
{
static Uint32 screensaverTicks = 0;
Uint32 nowTicks;
int firstMouseEvent;
CGMouseDelta dx, dy;
......@@ -713,8 +715,7 @@ void QZ_PumpEvents (_THIS)
return; /* don't do anything if there's no screen surface. */
/* Update activity every five seconds to prevent screensaver. --ryan. */
static Uint32 screensaverTicks = 0;
Uint32 nowTicks = SDL_GetTicks();
nowTicks = SDL_GetTicks();
if ((nowTicks - screensaverTicks) > 5000)
{
UpdateSystemActivity(UsrActivity);
......
......@@ -682,7 +682,7 @@ static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
return NULL;
}
//[ qz_window setReleasedWhenClosed:YES ];
/*[ qz_window setReleasedWhenClosed:YES ];*/
QZ_SetCaption(this, this->wm_title, this->wm_icon);
[ qz_window setAcceptsMouseMovedEvents:YES ];
[ 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;
current->pixels += (vOffset * current->pitch) + hOffset * (qdbpp/8);
current->pixels = (Uint8 *)current->pixels + (vOffset * current->pitch) + hOffset * (qdbpp/8);
}
this->UpdateRects = QZ_UpdateRects;
this->LockHWSurface = QZ_LockWindow;
......@@ -921,7 +921,7 @@ static int QZ_ThreadFlip (_THIS) {
* a fullscreen resolution smaller than the hardware could supply
* 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;
len = SDL_VideoSurface->w * SDL_VideoSurface->format->BytesPerPixel;
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.
*/
//#define TEST_OBSCURED 1
/*#define TEST_OBSCURED 1*/
#if TEST_OBSCURED
#include "CGS.h"
......@@ -1075,7 +1075,6 @@ static int QZ_IsWindowObscured (NSWindow *window) {
CGSRect contentRect;
int windowNumber;
//int isMainWindow;
int firstDockIcon;
int dockIconCacheMiss;
int windowContentOffset;
......@@ -1106,7 +1105,6 @@ static int QZ_IsWindowObscured (NSWindow *window) {
windowContentOffset = 0;
windowNumber = [ window windowNumber ];
//isMainWindow = [ window isMainWindow ];
/* The window list is sorted according to order on the screen */
count = 0;
......
......@@ -144,7 +144,7 @@ static void QZ_SetPortAlphaOpaque () {
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 );
......@@ -177,7 +177,7 @@ static void QZ_SetPortAlphaOpaque () {
/* restore cached image, since it may not be current, post expose event too */
[ self restoreCachedImage ];
//SDL_PrivateExpose ();
/*SDL_PrivateExpose ();*/
SDL_PrivateAppActive (1, SDL_APPACTIVE);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment