Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cleaning up warnings on MacOS X
  • Loading branch information
slouken committed Mar 9, 2006
1 parent bcf18da commit c946569
Show file tree
Hide file tree
Showing 23 changed files with 317 additions and 357 deletions.
4 changes: 2 additions & 2 deletions include/SDL_syswm.h
Expand Up @@ -48,15 +48,15 @@ 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

#include <X11/Xlib.h>
#include <X11/Xatom.h>

#if defined(__APPLE__) && defined(__MACH__)
// matches the re-define above
/* matches the re-define above */
#undef Cursor
#endif

Expand Down
20 changes: 10 additions & 10 deletions src/SDL.c
Expand Up @@ -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,
Expand All @@ -273,15 +273,15 @@ 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)
)
{
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
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/audio/SDL_audio.c
Expand Up @@ -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
Expand Down Expand Up @@ -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"))
{
Expand Down
3 changes: 1 addition & 2 deletions src/audio/SDL_mixer_MMX.h
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions src/audio/SDL_mixer_MMX_VC.h
Expand Up @@ -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
8 changes: 4 additions & 4 deletions src/audio/SDL_wave.c
Expand Up @@ -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;
Expand All @@ -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) );

Expand Down Expand Up @@ -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 ) {
Expand All @@ -554,7 +554,7 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/audio/macosx/SDL_coreaudio.c
Expand Up @@ -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;
}
Expand Down
71 changes: 36 additions & 35 deletions src/cdrom/macosx/AudioFilePlayer.c
Expand Up @@ -24,9 +24,9 @@
*/
#include "SDL_config.h"

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// AudioFilePlayer.cpp
//
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AudioFilePlayer.cpp
*/
#include "AudioFilePlayer.h"

/*
Expand Down Expand Up @@ -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 ;

Expand All @@ -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;
}

Expand All @@ -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;
}
Expand Down Expand Up @@ -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;

Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c946569

Please sign in to comment.