diff --git a/Android/jni/jnicrash.c b/Android/jni/jnicrash.c index 64a0ed0e..c5c4f294 100644 --- a/Android/jni/jnicrash.c +++ b/Android/jni/jnicrash.c @@ -132,7 +132,7 @@ void Java_org_deadc0de_apple2ix_Apple2CrashHandler_nativeProcessCrash(JNIEnv *en do { outputFILE = TEMP_FAILURE_RETRY_FOPEN(fopen(outputPath, "w")); if (!outputFILE) { - ERRLOG("could not open %s", outputPath); + LOG("could not open %s", outputPath); break; } diff --git a/Android/jni/jnihooks.c b/Android/jni/jnihooks.c index 06384174..8cbdaa88 100644 --- a/Android/jni/jnihooks.c +++ b/Android/jni/jnihooks.c @@ -393,7 +393,7 @@ jstring Java_org_deadc0de_apple2ix_Apple2DisksMenu_nativeChooseDisk(JNIEnv *env, } else { fd = dup(fd); if (fd == -1) { - ERRLOG("OOPS could not dup file descriptor!"); + LOG("OOPS could not dup file descriptor!"); } } @@ -468,7 +468,7 @@ static int _openFdFromJson(OUTPARM int *fdOut, JSON_ref jsonData, const char * c } else { fd = dup(fd); if (fd == -1) { - ERRLOG("OOPS could not dup file descriptor!"); + LOG("OOPS could not dup file descriptor!"); } } } while (0); diff --git a/Apple2Mac/Classes/iOS/AppDelegate.m b/Apple2Mac/Classes/iOS/AppDelegate.m index a5e99936..cf6d5ae5 100644 --- a/Apple2Mac/Classes/iOS/AppDelegate.m +++ b/Apple2Mac/Classes/iOS/AppDelegate.m @@ -86,13 +86,13 @@ [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&error]; if (error) { - ERRLOG("Error setting AVAudioSessionCategoryAmbient : %s", [[error description] UTF8String]); + LOG("Error setting AVAudioSessionCategoryAmbient : %s", [[error description] UTF8String]); error = nil; } [[AVAudioSession sharedInstance] setActive:YES error:&error]; if (error) { - ERRLOG("Error activating AVAudioSession : %s", [[error description] UTF8String]); + LOG("Error activating AVAudioSession : %s", [[error description] UTF8String]); error = nil; } } @@ -103,7 +103,7 @@ [[AVAudioSession sharedInstance] setActive:NO error:&error]; if (error) { - ERRLOG("Error deactivating AVAudioSession : %s", [[error description] UTF8String]); + LOG("Error deactivating AVAudioSession : %s", [[error description] UTF8String]); } } @@ -142,14 +142,14 @@ if (error) { - ERRLOG("Could not create directory. Error: %s", [[error description] UTF8String]); + LOG("Could not create directory. Error: %s", [[error description] UTF8String]); return; } NSArray *fileList = [fileManager contentsOfDirectoryAtPath:resourcesPath error:&error]; if (error) { - ERRLOG("Could not list contents of bundle. Error: %s", [[error description] UTF8String]); + LOG("Could not list contents of bundle. Error: %s", [[error description] UTF8String]); return; } @@ -174,7 +174,7 @@ [fileManager copyItemAtPath:resourcesFile toPath:documentsFile error:&error]; if (error) { - ERRLOG("Could not copy file. Error: %s", [[error description] UTF8String]); + LOG("Could not copy file. Error: %s", [[error description] UTF8String]); } } } diff --git a/src/audio/alhelpers.c b/src/audio/alhelpers.c index c11bff09..b8f40aa4 100644 --- a/src/audio/alhelpers.c +++ b/src/audio/alhelpers.c @@ -43,7 +43,7 @@ ALCcontext* InitAL(void) device = alcOpenDevice(NULL); if(!device) { - ERRLOG("Could not open a device!"); + LOG("Could not open a device!"); return NULL; } @@ -55,7 +55,7 @@ ALCcontext* InitAL(void) alcDestroyContext(ctx); } alcCloseDevice(device); - ERRLOG("Could not set a context!"); + LOG("Could not set a context!"); return NULL; } diff --git a/src/audio/mockingboard.c b/src/audio/mockingboard.c index 0cdf78e0..c617ad8b 100644 --- a/src/audio/mockingboard.c +++ b/src/audio/mockingboard.c @@ -1293,7 +1293,7 @@ static void* SSI263Thread(void *lpParameter) err = pthread_cond_timedwait(&ssi263_cond, &ssi263_mutex, &wait); if (err && (err != ETIMEDOUT)) { - ERRLOG("OOPS pthread_cond_timedwait"); + LOG("OOPS pthread_cond_timedwait"); } pthread_mutex_unlock(&ssi263_mutex); @@ -1562,12 +1562,12 @@ static bool MB_DSInit() int err = 0; if ((err = pthread_mutex_init(&ssi263_mutex, NULL))) { - ERRLOG("OOPS pthread_mutex_init"); + LOG("OOPS pthread_mutex_init"); } if ((err = pthread_cond_init(&ssi263_cond, NULL))) { - ERRLOG("OOPS pthread_cond_init"); + LOG("OOPS pthread_cond_init"); } #else g_hSSI263Event[0] = CreateEvent(NULL, // lpEventAttributes @@ -1708,7 +1708,7 @@ static bool MB_DSInit() int err = 0; if ((err = pthread_create(&g_hThread, NULL, SSI263Thread, NULL))) { - ERRLOG("SSI263Thread"); + LOG("SSI263Thread"); } // assuming time critical ... @@ -1719,11 +1719,11 @@ static bool MB_DSInit() int prio = 0; if ((prio = sched_get_priority_max(policy)) < 0) { - ERRLOG("OOPS sched_get_priority_max"); + LOG("OOPS sched_get_priority_max"); } else { if ((err = pthread_setschedprio(thread, prio))) { - ERRLOG("OOPS pthread_setschedprio"); + LOG("OOPS pthread_setschedprio"); } } # endif @@ -1757,7 +1757,7 @@ static void MB_DSUninit() int err = 0; if ( (err = pthread_join(g_hThread, NULL)) ) { - ERRLOG("OOPS pthread_join"); + LOG("OOPS pthread_join"); } #else unsigned long dwExitCode; diff --git a/src/audio/playqueue.c b/src/audio/playqueue.c index c6a7de43..da3f9e82 100644 --- a/src/audio/playqueue.c +++ b/src/audio/playqueue.c @@ -45,7 +45,7 @@ static long playq_enqueue(PlayQueue_s *_this, INOUT PlayNode_s *node) { // detach a node from the available pool PQListNode_s *listNode = list->availNodes; if (!listNode) { - ERRLOG("Cannot enqueue: no slots available"); + LOG("Cannot enqueue: no slots available"); err = -1; break; } @@ -228,14 +228,14 @@ PlayQueue_s *playq_createPlayQueue(const long *nodeIdPtr, unsigned long numBuffe do { playq = CALLOC(1, sizeof(PlayQueue_s)); if (!playq) { - ERRLOG("no memory"); + LOG("no memory"); break; } PQList_s *list = CALLOC(1, sizeof(PQList_s)); playq->_internal = list; if (!list) { - ERRLOG("no memory"); + LOG("no memory"); break; } @@ -245,7 +245,7 @@ PlayQueue_s *playq_createPlayQueue(const long *nodeIdPtr, unsigned long numBuffe LOG("CREATING PlayNode_s node ID: %ld", nodeIdPtr[i]); listNode->node.nodeId = nodeIdPtr[i]; if (!listNode) { - ERRLOG("no memory"); + LOG("no memory"); allocSuccess = false; break; } diff --git a/src/audio/soundcore-openal.c b/src/audio/soundcore-openal.c index d8b8fc9b..2f58dc7c 100644 --- a/src/audio/soundcore-openal.c +++ b/src/audio/soundcore-openal.c @@ -84,7 +84,7 @@ static long _ALProcessPlayBuffers(ALVoice *voice, ALuint *bytes_queued) { ALint processed = 0; alGetSourcei(voice->source, AL_BUFFERS_PROCESSED, &processed); if ((err = alGetError()) != AL_NO_ERROR) { - ERRLOG("OOPS, error in checking processed buffers : 0x%08lx", err); + LOG("OOPS, error in checking processed buffers : 0x%08lx", err); break; } @@ -93,7 +93,7 @@ static long _ALProcessPlayBuffers(ALVoice *voice, ALuint *bytes_queued) { ALuint bufid = 0; alSourceUnqueueBuffers(voice->source, 1, &bufid); if ((err = alGetError()) != AL_NO_ERROR) { - ERRLOG("OOPS, OpenAL error dequeuing buffer : 0x%08lx", err); + LOG("OOPS, OpenAL error dequeuing buffer : 0x%08lx", err); break; } @@ -103,7 +103,7 @@ static long _ALProcessPlayBuffers(ALVoice *voice, ALuint *bytes_queued) { }; err = voice->playq->Get(voice->playq, &playNode); if (err) { - ERRLOG("OOPS, OpenAL bufid %u not found in playlist...", bufid); + LOG("OOPS, OpenAL bufid %u not found in playlist...", bufid); } else { _playq_removeNode(voice, &playNode); } @@ -112,7 +112,7 @@ static long _ALProcessPlayBuffers(ALVoice *voice, ALuint *bytes_queued) { ALint play_offset = 0; alGetSourcei(voice->source, AL_BYTE_OFFSET, &play_offset); if ((err = alGetError()) != AL_NO_ERROR) { - ERRLOG("OOPS, alGetSourcei AL_BYTE_OFFSET : 0x%08lx", err); + LOG("OOPS, alGetSourcei AL_BYTE_OFFSET : 0x%08lx", err); break; } assert((play_offset >= 0)/* && (play_offset < voice->buffersize)*/); @@ -219,7 +219,7 @@ static long _ALSubmitBufferToOpenAL(ALVoice *voice) { alBufferData(playNode.nodeId, voice->format, playNode.bytes, playNode.numBytes, voice->rate); if ((err = alGetError()) != AL_NO_ERROR) { _playq_removeNode(voice, &playNode); - ERRLOG("OOPS, Error alBufferData : 0x%08lx", err); + LOG("OOPS, Error alBufferData : 0x%08lx", err); break; } @@ -227,14 +227,14 @@ static long _ALSubmitBufferToOpenAL(ALVoice *voice) { alSourceQueueBuffers(voice->source, 1, &nodeId); if ((err = alGetError()) != AL_NO_ERROR) { _playq_removeNode(voice, &playNode); - ERRLOG("OOPS, Error buffering data : 0x%08lx", err); + LOG("OOPS, Error buffering data : 0x%08lx", err); break; } ALint state = 0; alGetSourcei(voice->source, AL_SOURCE_STATE, &state); if ((err = alGetError()) != AL_NO_ERROR) { - ERRLOG("OOPS, Error checking source state : 0x%08lx", err); + LOG("OOPS, Error checking source state : 0x%08lx", err); break; } if ((state != AL_PLAYING) && (state != AL_PAUSED)) { @@ -313,7 +313,7 @@ static long ALGetStatus(AudioBuffer_s *_this, OUTPARM unsigned long *status) { ALint state = 0; alGetSourcei(voice->source, AL_SOURCE_STATE, &state); if ((err = alGetError()) != AL_NO_ERROR) { - ERRLOG("OOPS, Error checking source state : 0x%08lx", err); + LOG("OOPS, Error checking source state : 0x%08lx", err); break; } @@ -333,7 +333,7 @@ static long ALGetStatus(AudioBuffer_s *_this, OUTPARM unsigned long *status) { static void _openal_destroyVoice(ALVoice *voice) { alDeleteSources(1, &voice->source); if (alGetError() != AL_NO_ERROR) { - ERRLOG("OOPS, Failed to delete source"); + LOG("OOPS, Failed to delete source"); } if (voice->data) { @@ -343,7 +343,7 @@ static void _openal_destroyVoice(ALVoice *voice) { for (unsigned int i=0; ibuffers); if (alGetError() != AL_NO_ERROR) { - ERRLOG("OOPS, Failed to delete object IDs"); + LOG("OOPS, Failed to delete object IDs"); } } @@ -359,43 +359,43 @@ static ALVoice *_openal_createVoice(unsigned long numChannels) { do { voice = CALLOC(1, sizeof(*voice)); if (voice == NULL) { - ERRLOG("OOPS, Out of memory!"); + LOG("OOPS, Out of memory!"); break; } alGenBuffers(OPENAL_NUM_BUFFERS, voice->buffers); if (alGetError() != AL_NO_ERROR) { - ERRLOG("OOPS, Could not create buffers"); + LOG("OOPS, Could not create buffers"); break; } alGenSources(1, &voice->source); if (alGetError() != AL_NO_ERROR) { - ERRLOG("OOPS, Could not create source"); + LOG("OOPS, Could not create source"); break; } // Set parameters so mono sources play out the front-center speaker and won't distance attenuate. alSource3i(voice->source, AL_POSITION, 0, 0, -1); if (alGetError() != AL_NO_ERROR) { - ERRLOG("OOPS, Could not set AL_POSITION source parameter"); + LOG("OOPS, Could not set AL_POSITION source parameter"); break; } alSourcei(voice->source, AL_SOURCE_RELATIVE, AL_TRUE); if (alGetError() != AL_NO_ERROR) { - ERRLOG("OOPS, Could not set AL_SOURCE_RELATIVE source parameter"); + LOG("OOPS, Could not set AL_SOURCE_RELATIVE source parameter"); break; } alSourcei(voice->source, AL_ROLLOFF_FACTOR, 0); if (alGetError() != AL_NO_ERROR) { - ERRLOG("OOPS, Could not set AL_ROLLOFF_FACTOR source parameter"); + LOG("OOPS, Could not set AL_ROLLOFF_FACTOR source parameter"); break; } #if 0 alSourcei(voice->source, AL_STREAMING, AL_TRUE); if (alGetError() != AL_NO_ERROR) { - ERRLOG("OOPS, Could not set AL_STREAMING source parameter"); + LOG("OOPS, Could not set AL_STREAMING source parameter"); break; } #endif @@ -406,7 +406,7 @@ static ALVoice *_openal_createVoice(unsigned long numChannels) { } voice->playq = playq_createPlayQueue(longBuffers, OPENAL_NUM_BUFFERS); if (!voice->playq) { - ERRLOG("OOPS, Not enough memory for PlayQueue"); + LOG("OOPS, Not enough memory for PlayQueue"); break; } @@ -426,7 +426,7 @@ static ALVoice *_openal_createVoice(unsigned long numChannels) { voice->data = CALLOC(1, voice->buffersize); if (voice->data == NULL) { - ERRLOG("OOPS, Error allocating %d bytes", voice->buffersize); + LOG("OOPS, Error allocating %d bytes", voice->buffersize); break; } @@ -483,14 +483,14 @@ static long openal_createSoundBuffer(const AudioContext_s *audio_context, INOUT assert(ctx != NULL); if ((voice = _openal_createVoice(NUM_CHANNELS)) == NULL) { - ERRLOG("OOPS, Cannot create new voice"); + LOG("OOPS, Cannot create new voice"); break; } ALVoices immutableNode = { /*const*/.source = voice->source }; ALVoices *vnode = CALLOC(1, sizeof(ALVoices)); if (!vnode) { - ERRLOG("OOPS, Not enough memory"); + LOG("OOPS, Not enough memory"); break; } memcpy(vnode, &immutableNode, sizeof(ALVoices)); @@ -498,7 +498,7 @@ static long openal_createSoundBuffer(const AudioContext_s *audio_context, INOUT HASH_ADD_INT(voices, source, vnode); if ((*soundbuf_struct = CALLOC(1, sizeof(AudioBuffer_s))) == NULL) { - ERRLOG("OOPS, Not enough memory"); + LOG("OOPS, Not enough memory"); break; } @@ -556,7 +556,7 @@ static long openal_systemSetup(INOUT AudioContext_s **audio_context) { if ((ctx = InitAL()) == NULL) { // NOTE : currently assuming just one OpenAL global context - ERRLOG("OOPS, OpenAL initialize failed"); + LOG("OOPS, OpenAL initialize failed"); break; } @@ -567,7 +567,7 @@ static long openal_systemSetup(INOUT AudioContext_s **audio_context) { } if ((*audio_context = CALLOC(1, sizeof(AudioContext_s))) == NULL) { - ERRLOG("OOPS, Not enough memory"); + LOG("OOPS, Not enough memory"); break; } @@ -600,7 +600,7 @@ static long openal_systemPause(AudioContext_s *audio_context) { alSourcePause(vnode->source); err = alGetError(); if (err != AL_NO_ERROR) { - ERRLOG("OOPS, Failed to pause source : 0x%08lx", err); + LOG("OOPS, Failed to pause source : 0x%08lx", err); } } @@ -616,7 +616,7 @@ static long openal_systemResume(AudioContext_s *audio_context) { alSourcePlay(vnode->source); err = alGetError(); if (err != AL_NO_ERROR) { - ERRLOG("OOPS, Failed to pause source : 0x%08lx", err); + LOG("OOPS, Failed to pause source : 0x%08lx", err); } } diff --git a/src/audio/soundcore-opensles.c b/src/audio/soundcore-opensles.c index 434f4d7d..714a14c4 100644 --- a/src/audio/soundcore-opensles.c +++ b/src/audio/soundcore-opensles.c @@ -197,7 +197,7 @@ static long _SLMaybeSubmitAndStart(SLVoice *voice) { EngineContext_s *ctx = (EngineContext_s *)voice->ctx; SLresult result = (*(ctx->bqPlayerPlay))->GetPlayState(ctx->bqPlayerPlay, &state); if (result != SL_RESULT_SUCCESS) { - ERRLOG("OOPS, could not get source state : %lu", (unsigned long)result); + LOG("OOPS, could not get source state : %lu", (unsigned long)result); } else { if ((state != SL_PLAYSTATE_PLAYING) && (state != SL_PLAYSTATE_PAUSED)) { LOG("FORCING restart audio buffer queue playback ..."); @@ -338,7 +338,7 @@ static long SLGetStatus(AudioBuffer_s *_this, OUTPARM unsigned long *status) { SLuint32 state = 0; result = (*(ctx->bqPlayerPlay))->GetPlayState(ctx->bqPlayerPlay, &state); if (result != SL_RESULT_SUCCESS) { - ERRLOG("OOPS, could not get source state : %lu", (unsigned long)result); + LOG("OOPS, could not get source state : %lu", (unsigned long)result); break; } @@ -428,14 +428,14 @@ static long opensl_createSoundBuffer(const AudioContext_s *audio_context, INOUT LOG("Creating new SLVoice ..."); voice = CALLOC(1, sizeof(*voice)); if (voice == NULL) { - ERRLOG("OOPS, Out of memory!"); + LOG("OOPS, Out of memory!"); break; } voice->bufferSize = bufferSize; // Allocate enough space for the temp buffer (including a maximum allowed overflow) voice->ringBuffer = CALLOC(1, voice->bufferSize + ctx->submitSize/*max overflow*/); if (voice->ringBuffer == NULL) { - ERRLOG("OOPS, Error allocating %lu bytes", (unsigned long)voice->bufferSize+ctx->submitSize); + LOG("OOPS, Error allocating %lu bytes", (unsigned long)voice->bufferSize+ctx->submitSize); break; } } @@ -445,7 +445,7 @@ static long opensl_createSoundBuffer(const AudioContext_s *audio_context, INOUT voice->ctx = ctx; if ((*soundbuf_struct = CALLOC(1, sizeof(AudioBuffer_s))) == NULL) { - ERRLOG("OOPS, Not enough memory"); + LOG("OOPS, Not enough memory"); break; } @@ -565,28 +565,28 @@ static long opensles_systemSetup(INOUT AudioContext_s **audio_context) { ctx->submitSize = android_stereoBufferSubmitSizeSamples * opensles_audio_backend.systemSettings.bytesPerSample * NUM_CHANNELS; ctx->mixBuf = CALLOC(1, ctx->submitSize); if (ctx->mixBuf == NULL) { - ERRLOG("OOPS, Error allocating %lu bytes", (unsigned long)ctx->submitSize); + LOG("OOPS, Error allocating %lu bytes", (unsigned long)ctx->submitSize); break; } // create basic engine result = slCreateEngine(&(ctx->engineObject), 0, NULL, /*engineMixIIDCount:*/0, /*engineMixIIDs:*/NULL, /*engineMixReqs:*/NULL); if (result != SL_RESULT_SUCCESS) { - ERRLOG("Could not create OpenSLES Engine : %lu", (unsigned long)result); + LOG("Could not create OpenSLES Engine : %lu", (unsigned long)result); break; } // realize the engine result = (*(ctx->engineObject))->Realize(ctx->engineObject, /*asynchronous_realization:*/SL_BOOLEAN_FALSE); if (result != SL_RESULT_SUCCESS) { - ERRLOG("Could not realize the OpenSLES Engine : %lu", (unsigned long)result); + LOG("Could not realize the OpenSLES Engine : %lu", (unsigned long)result); break; } // get the actual engine interface result = (*(ctx->engineObject))->GetInterface(ctx->engineObject, SL_IID_ENGINE, &(ctx->engineEngine)); if (result != SL_RESULT_SUCCESS) { - ERRLOG("Could not get the OpenSLES Engine : %lu", (unsigned long)result); + LOG("Could not get the OpenSLES Engine : %lu", (unsigned long)result); break; } @@ -596,21 +596,21 @@ static long opensles_systemSetup(INOUT AudioContext_s **audio_context) { result = (*(ctx->engineEngine))->CreateOutputMix(ctx->engineEngine, &(ctx->outputMixObject), 0, NULL, NULL); if (result != SL_RESULT_SUCCESS) { - ERRLOG("Could not create output mix : %lu", (unsigned long)result); + LOG("Could not create output mix : %lu", (unsigned long)result); break; } // realize the output mix result = (*(ctx->outputMixObject))->Realize(ctx->outputMixObject, SL_BOOLEAN_FALSE); if (result != SL_RESULT_SUCCESS) { - ERRLOG("Could not realize the output mix : %lu", (unsigned long)result); + LOG("Could not realize the output mix : %lu", (unsigned long)result); break; } // create soundcore API wrapper if ((*audio_context = CALLOC(1, sizeof(AudioContext_s))) == NULL) { result = -1; - ERRLOG("OOPS, Not enough memory"); + LOG("OOPS, Not enough memory"); break; } @@ -665,35 +665,35 @@ static long opensles_systemSetup(INOUT AudioContext_s **audio_context) { result = (*(ctx->engineEngine))->CreateAudioPlayer(ctx->engineEngine, &(ctx->bqPlayerObject), &audioSrc, &audioSnk, _NUM_INTERFACES, ids, req); if (result != SL_RESULT_SUCCESS) { - ERRLOG("OOPS, could not create the BufferQueue player object : %lu", (unsigned long)result); + LOG("OOPS, could not create the BufferQueue player object : %lu", (unsigned long)result); break; } // realize the player result = (*(ctx->bqPlayerObject))->Realize(ctx->bqPlayerObject, /*asynchronous_realization:*/SL_BOOLEAN_FALSE); if (result != SL_RESULT_SUCCESS) { - ERRLOG("OOPS, could not realize the BufferQueue player object : %lu", (unsigned long)result); + LOG("OOPS, could not realize the BufferQueue player object : %lu", (unsigned long)result); break; } // get the play interface result = (*(ctx->bqPlayerObject))->GetInterface(ctx->bqPlayerObject, SL_IID_PLAY, &(ctx->bqPlayerPlay)); if (result != SL_RESULT_SUCCESS) { - ERRLOG("OOPS, could not get the play interface : %lu", (unsigned long)result); + LOG("OOPS, could not get the play interface : %lu", (unsigned long)result); break; } // get the buffer queue interface result = (*(ctx->bqPlayerObject))->GetInterface(ctx->bqPlayerObject, SL_IID_BUFFERQUEUE, &(ctx->bqPlayerBufferQueue)); if (result != SL_RESULT_SUCCESS) { - ERRLOG("OOPS, could not get the BufferQueue play interface : %lu", (unsigned long)result); + LOG("OOPS, could not get the BufferQueue play interface : %lu", (unsigned long)result); break; } // register callback on the buffer queue result = (*(ctx->bqPlayerBufferQueue))->RegisterCallback(ctx->bqPlayerBufferQueue, bqPlayerCallback, ctx); if (result != SL_RESULT_SUCCESS) { - ERRLOG("OOPS, could not register BufferQueue callback : %lu", (unsigned long)result); + LOG("OOPS, could not register BufferQueue callback : %lu", (unsigned long)result); break; } @@ -737,12 +737,12 @@ static long opensles_systemResume(AudioContext_s *audio_context) { do { if (result != SL_RESULT_SUCCESS) { - ERRLOG("OOPS, could not get source state when attempting to resume : %lu", (unsigned long)result); + LOG("OOPS, could not get source state when attempting to resume : %lu", (unsigned long)result); break; } if (state != SL_PLAYSTATE_PLAYING) { - ERRLOG("WARNING: possible audio lifecycle mismatch ... continuing anyway"); + LOG("WARNING: possible audio lifecycle mismatch ... continuing anyway"); } if (state == SL_PLAYSTATE_PAUSED) { diff --git a/src/audio/soundcore.c b/src/audio/soundcore.c index fed3549a..37ee51d2 100644 --- a/src/audio/soundcore.c +++ b/src/audio/soundcore.c @@ -52,7 +52,7 @@ long audio_createSoundBuffer(INOUT AudioBuffer_s **audioBuffer) { long err = 0; do { if (!audioContext) { - ERRLOG("Cannot create sound buffer, no context"); + LOG("Cannot create sound buffer, no context"); err = -1; break; } diff --git a/src/audio/speaker.c b/src/audio/speaker.c index dd60306f..4dc3e9a6 100644 --- a/src/audio/speaker.c +++ b/src/audio/speaker.c @@ -338,7 +338,7 @@ static unsigned int _submit_samples_buffer(const unsigned long num_channel_sampl unsigned long counter = 0; do { if (speakerBuffer->Lock(speakerBuffer, curr_buffer_size, &system_samples_buffer, &system_buffer_size)) { - ERRLOG("Problem locking speaker buffer"); + LOG("Problem locking speaker buffer"); break; } @@ -352,7 +352,7 @@ static unsigned int _submit_samples_buffer(const unsigned long num_channel_sampl err = speakerBuffer->Unlock(speakerBuffer, system_buffer_size); if (err) { - ERRLOG("Problem unlocking speaker buffer"); + LOG("Problem unlocking speaker buffer"); break; } diff --git a/src/common.h b/src/common.h index 14a0aa3b..8338bcd8 100644 --- a/src/common.h +++ b/src/common.h @@ -230,13 +230,6 @@ static const char *log_end = "\n"; #endif #define LOG(...) \ - if (do_logging) { \ - errno = 0; \ - GLenum _glerr = 0; \ - _LOG(__VA_ARGS__); \ - } // - -#define ERRLOG(...) \ if (do_logging) { \ GLenum _glerr = safeGLGetError(); \ _LOG(__VA_ARGS__); \ @@ -274,9 +267,6 @@ static const char *log_end = "\n"; #else // NDEBUG -#define ERRLOG(...) \ - do { } while (0) - #define ERRQUIT(...) \ do { } while (0) diff --git a/src/disk.c b/src/disk.c index 384ef222..65268f26 100644 --- a/src/disk.c +++ b/src/disk.c @@ -453,7 +453,7 @@ static void save_track_data(int drive) { int ret = -1; TEMP_FAILURE_RETRY(ret = msync(disk6.disk[drive].raw_image_data+niboff, NIB_TRACK_SIZE, MS_SYNC)); if (ret) { - ERRLOG("Error syncing file %s", disk6.disk[drive].file_name); + LOG("Error syncing file %s", disk6.disk[drive].file_name); } */ } else { @@ -464,7 +464,7 @@ static void save_track_data(int drive) { int ret = -1; TEMP_FAILURE_RETRY(ret = msync(disk6.disk[drive].raw_image_data+dskoff, DSK_TRACK_SIZE, MS_SYNC)); if (ret) { - ERRLOG("Error syncing file %s", disk6.disk[drive].file_name); + LOG("Error syncing file %s", disk6.disk[drive].file_name); } */ } @@ -807,7 +807,7 @@ const char *disk6_eject(int drive) { // re-compress in place ... err = zlib_deflate_buffer(/*src:*/disk6.disk[drive].raw_image_data, disk6.disk[drive].whole_len, /*dst:*/compressed_data, &compressed_size); if (err) { - ERRLOG("OOPS, error deflating %s : %s", disk6.disk[drive].file_name, err); + LOG("OOPS, error deflating %s : %s", disk6.disk[drive].file_name, err); } if (compressed_size > 0) { @@ -818,32 +818,32 @@ const char *disk6_eject(int drive) { TEMP_FAILURE_RETRY(ret = msync(disk6.disk[drive].raw_image_data, disk6.disk[drive].whole_len, MS_SYNC)); if (ret) { - ERRLOG("Error syncing file %s", disk6.disk[drive].file_name); + LOG("Error syncing file %s", disk6.disk[drive].file_name); } } } TEMP_FAILURE_RETRY(ret = munmap(disk6.disk[drive].raw_image_data, disk6.disk[drive].whole_len)); if (ret) { - ERRLOG("Error munmap()ping file %s", disk6.disk[drive].file_name); + LOG("Error munmap()ping file %s", disk6.disk[drive].file_name); } } if (compressed_size > 0) { TEMP_FAILURE_RETRY(ret = ftruncate(disk6.disk[drive].fd, compressed_size)); if (ret == -1) { - ERRLOG("OOPS, cannot truncate file descriptor!"); + LOG("OOPS, cannot truncate file descriptor!"); } } TEMP_FAILURE_RETRY(ret = fsync(disk6.disk[drive].fd)); if (ret) { - ERRLOG("Error fsync()ing file %s", disk6.disk[drive].file_name); + LOG("Error fsync()ing file %s", disk6.disk[drive].file_name); } TEMP_FAILURE_RETRY(ret = close(disk6.disk[drive].fd)); if (ret) { - ERRLOG("Error close()ing file %s", disk6.disk[drive].file_name); + LOG("Error close()ing file %s", disk6.disk[drive].file_name); } } @@ -916,7 +916,7 @@ const char *disk6_insert(int fd, int drive, const char * const file_name, int re // disk images inserted read/write are mmap'd/inflated in place ... TEMP_FAILURE_RETRY(fd = dup(fd)); if (fd == -1) { - ERRLOG("OOPS, could not dup() file descriptor %d", fd); + LOG("OOPS, could not dup() file descriptor %d", fd); err = ERR_CANNOT_DUP; break; } @@ -925,13 +925,13 @@ const char *disk6_insert(int fd, int drive, const char * const file_name, int re bool file_actually_was_gzipped; // but we don't care ... err = zlib_inflate_inplace(disk6.disk[drive].fd, expected, &file_actually_was_gzipped); if (err) { - ERRLOG("OOPS, An error occurred when attempting to inflate/load a disk image [%s] : [%s]", file_name, err); + LOG("OOPS, An error occurred when attempting to inflate/load a disk image [%s] : [%s]", file_name, err); break; } TEMP_FAILURE_RETRY(disk6.disk[drive].raw_image_data = mmap(NULL, disk6.disk[drive].whole_len, (readonly ? PROT_READ : PROT_READ|PROT_WRITE), MAP_SHARED|MAP_FILE, disk6.disk[drive].fd, /*offset:*/0)); if (disk6.disk[drive].raw_image_data == MAP_FAILED) { - ERRLOG("OOPS, could not mmap file %s", disk6.disk[drive].file_name); + LOG("OOPS, could not mmap file %s", disk6.disk[drive].file_name); err = ERR_MMAP_FAILED; break; } @@ -959,7 +959,7 @@ const char *disk6_insert(int fd, int drive, const char * const file_name, int re assert(track_width <= NIB_TRACK_SIZE); #if CONFORMANT_TRACKS if (track_width != NI2_TRACK_SIZE) { - ERRLOG("Invalid dsk image creation..."); + LOG("Invalid dsk image creation..."); } #endif if (!disk6.disk[drive].track_width) { @@ -1010,7 +1010,7 @@ void disk6_flush(int drive) { int ret = -1; TEMP_FAILURE_RETRY(ret = msync(disk6.disk[drive].raw_image_data, disk6.disk[drive].whole_len, MS_SYNC)); if (ret) { - ERRLOG("Error syncing file %s", disk6.disk[drive].file_name); + LOG("Error syncing file %s", disk6.disk[drive].file_name); } } diff --git a/src/json_parse.c b/src/json_parse.c index 1fd1ff73..e7c35b56 100644 --- a/src/json_parse.c +++ b/src/json_parse.c @@ -235,7 +235,7 @@ static int _json_createFromString(const char *jsonString, INOUT JSON_ref *jsonRe if (!parsedData->jsonTokens) { parsedData->jsonTokens = CALLOC(numTokens, sizeof(jsmntok_t)); if (UNLIKELY(!parsedData->jsonTokens)) { - ERRLOG("WHOA3 : %s", strerror(errno)); + LOG("WHOA3 : %s", strerror(errno)); break; } } else { @@ -243,7 +243,7 @@ static int _json_createFromString(const char *jsonString, INOUT JSON_ref *jsonRe numTokens <<= 1; jsmntok_t *newTokens = REALLOC(parsedData->jsonTokens, numTokens * sizeof(jsmntok_t)); if (UNLIKELY(!newTokens)) { - ERRLOG("WHOA4 : %s", strerror(errno)); + LOG("WHOA4 : %s", strerror(errno)); break; } memset(newTokens, '\0', numTokens * sizeof(jsmntok_t)); @@ -258,22 +258,22 @@ static int _json_createFromString(const char *jsonString, INOUT JSON_ref *jsonRe } if (errCount < 0) { - ERRLOG("%s", "OOPS error parsing JSON : "); + LOG("%s", "OOPS error parsing JSON : "); switch (errCount) { case JSMN_ERROR_NOMEM: assert(0 && "should not happen"); break; case JSMN_ERROR_INVAL: - ERRLOG("%s", "Invalid character inside JSON string"); + LOG("%s", "Invalid character inside JSON string"); break; case JSMN_ERROR_PART: - ERRLOG("%s", "String is not a complete JSON packet, moar bytes expected"); + LOG("%s", "String is not a complete JSON packet, moar bytes expected"); break; case JSMN_ERROR_PRIMITIVE_INVAL: - ERRLOG("%s", "Invalid character inside JSON primitive"); + LOG("%s", "Invalid character inside JSON primitive"); break; default: - ERRLOG("UNKNOWN errCount : %d", errCount); + LOG("UNKNOWN errCount : %d", errCount); break; } break; @@ -310,7 +310,7 @@ int json_createFromFD(int fd, INOUT JSON_ref *jsonRef) { jsonLen = JSON_LENGTH*2; jsonString = MALLOC(jsonLen); if (UNLIKELY(jsonString == NULL)) { - ERRLOG("WHOA : %s", strerror(errno)); + LOG("WHOA : %s", strerror(errno)); break; } @@ -318,7 +318,7 @@ int json_createFromFD(int fd, INOUT JSON_ref *jsonRef) { do { TEMP_FAILURE_RETRY(bytesRead = read(fd, jsonString+jsonIdx, JSON_LENGTH)); if (bytesRead < 0) { - ERRLOG("Error reading file : %s", strerror(errno)); + LOG("Error reading file : %s", strerror(errno)); break; } if (bytesRead) { @@ -328,7 +328,7 @@ int json_createFromFD(int fd, INOUT JSON_ref *jsonRef) { jsonLen <<= 1; char *newString = REALLOC(jsonString, jsonLen); if (UNLIKELY(!newString)) { - ERRLOG("WHOA2 : %s", strerror(errno)); + LOG("WHOA2 : %s", strerror(errno)); bytesRead = -1; break; } @@ -368,7 +368,7 @@ int json_createFromFile(const char *filePath, INOUT JSON_ref *jsonRef) { TEMP_FAILURE_RETRY(fd = open(filePath, O_RDONLY)); if (fd < 0) { - ERRLOG("Error opening file : %s", strerror(errno)); + LOG("Error opening file : %s", strerror(errno)); break; } @@ -418,7 +418,7 @@ static bool _json_mapGetStringValue(const JSON_s *map, const char *key, INOUT in // should begin as map ... if (map->jsonTokens[idx].type != JSMN_OBJECT) { - ERRLOG("Map JSON : must start with begin map token"); + LOG("Map JSON : must start with begin map token"); break; } ++idx; @@ -430,7 +430,7 @@ static bool _json_mapGetStringValue(const JSON_s *map, const char *key, INOUT in assert(keyTok.parent == 0); if (keyTok.type != JSMN_STRING) { - ERRLOG("Map JSON : expecting a string key at map position %d", idx); + LOG("Map JSON : expecting a string key at map position %d", idx); break; } @@ -641,7 +641,7 @@ static bool _json_mapSetValue(const JSON_ref jsonRef, const char *key, const cha } if (map->jsonTokens[0].type != JSMN_OBJECT) { - ERRLOG("Map JSON : object not a map!"); + LOG("Map JSON : object not a map!"); break; } @@ -750,7 +750,7 @@ static bool _json_mapSetValue(const JSON_ref jsonRef, const char *key, const cha JSON_ref newRef = NULL; int errCount = json_createFromString(jsonString, &newRef); if (errCount < 0) { - ERRLOG("Cannot set new JSON value err : %d", errCount); + LOG("Cannot set new JSON value err : %d", errCount); } else { JSON_s *newMap = (JSON_s *)newRef; FREE(map->jsonString); diff --git a/src/meta/debugger.c b/src/meta/debugger.c index 3996e8ba..03622b4a 100644 --- a/src/meta/debugger.c +++ b/src/meta/debugger.c @@ -1148,10 +1148,10 @@ static int begin_cpu_stepping() { } if ((err = pthread_cond_signal(&cpu_thread_cond))) { - ERRLOG("pthread_cond_signal : %d", err); + LOG("pthread_cond_signal : %d", err); } if ((err = pthread_cond_wait(&dbg_thread_cond, &interface_mutex))) { - ERRLOG("pthread_cond_wait : %d", err); + LOG("pthread_cond_wait : %d", err); } #if defined(INTERFACE_CLASSIC) @@ -1168,7 +1168,7 @@ static int begin_cpu_stepping() { } while (!stepping_struct.should_break); if ((err = pthread_cond_signal(&cpu_thread_cond))) { - ERRLOG("pthread_cond_signal : %d", err); + LOG("pthread_cond_signal : %d", err); } cpu_scale_factor = saved_scale; @@ -1185,7 +1185,7 @@ bool c_debugger_should_break() { if (pthread_self() != cpu_thread_id) { // OOPS ... - ERRLOG("should only call this from cpu thread, bailing..."); + LOG("should only call this from cpu thread, bailing..."); assert(false); } @@ -1489,7 +1489,7 @@ void c_interface_debugging() { is_debugging = false; if ((err = pthread_cond_signal(&cpu_thread_cond))) { - ERRLOG("pthread_cond_signal : %d", err); + LOG("pthread_cond_signal : %d", err); } return; } diff --git a/src/meta/lintrace.c b/src/meta/lintrace.c index f8433aa7..bbf9cafd 100644 --- a/src/meta/lintrace.c +++ b/src/meta/lintrace.c @@ -30,7 +30,7 @@ static int trace_pid = -1; static void _trace_init(void) { TEMP_FAILURE_RETRY(trace_fd = open(TRACING_FILE, O_WRONLY)); if (trace_fd == -1) { - ERRLOG("Could not open kernel trace file"); + LOG("Could not open kernel trace file"); } else { LOG("Initialized Linux tracing facility"); } diff --git a/src/misc.c b/src/misc.c index fd6a6d09..6976163f 100644 --- a/src/misc.c +++ b/src/misc.c @@ -55,7 +55,7 @@ static bool _save_state(int fd, const uint8_t * outbuf, ssize_t outmax) { ssize_t outlen = 0; do { if (TEMP_FAILURE_RETRY(outlen = write(fd, outbuf, outmax)) == -1) { - ERRLOG("OOPS, error writing emulator save-state file"); + LOG("OOPS, error writing emulator save-state file"); break; } outbuf += outlen; @@ -72,13 +72,13 @@ static bool _load_state(int fd, uint8_t * inbuf, ssize_t inmax) { struct stat stat_buf; if (UNLIKELY(fstat(fd, &stat_buf) < 0)) { - ERRLOG("OOPS, could not stat FD"); + LOG("OOPS, could not stat FD"); return false; } off_t fileSiz = stat_buf.st_size; off_t filePos = lseek(fd, 0, SEEK_CUR); if (UNLIKELY(filePos < 0)) { - ERRLOG("OOPS, could not lseek FD"); + LOG("OOPS, could not lseek FD"); return false; } @@ -89,11 +89,11 @@ static bool _load_state(int fd, uint8_t * inbuf, ssize_t inmax) { do { if (TEMP_FAILURE_RETRY(inlen = read(fd, inbuf, inmax)) == -1) { - ERRLOG("error reading emulator save-state file"); + LOG("error reading emulator save-state file"); break; } if (inlen == 0) { - ERRLOG("error reading emulator save-state file (truncated)"); + LOG("error reading emulator save-state file (truncated)"); break; } inbuf += inlen; @@ -118,7 +118,7 @@ static int _load_magick(int fd) { return 1; } - ERRLOG("bad header magick in emulator save state file"); + LOG("bad header magick in emulator save state file"); return -1; } @@ -229,12 +229,12 @@ bool emulator_loadState(int fd, int fdA, int fdB) { struct stat stat_buf; if (fstat(fd, &stat_buf) < 0) { - ERRLOG("OOPS, could not stat FD"); + LOG("OOPS, could not stat FD"); } off_t fileSiz = stat_buf.st_size; off_t filePos = lseek(fd, 0, SEEK_CUR); if (filePos < 0) { - ERRLOG("OOPS, could not lseek FD"); + LOG("OOPS, could not lseek FD"); } if (UNLIKELY(filePos != fileSiz)) { @@ -280,7 +280,7 @@ bool emulator_stateExtractDiskPaths(int fd, JSON_ref json) { // Ensure that we leave the file descriptor ready for a call to emulator_loadState() off_t ret = lseek(fd, 0, SEEK_SET); if (ret != 0) { - ERRLOG("OOPS : state file lseek() failed!"); + LOG("OOPS : state file lseek() failed!"); } } @@ -297,7 +297,7 @@ static void _shutdown_threads(void) { do { DIR *dir = opendir("/proc/self/task"); if (!dir) { - ERRLOG("Cannot open /proc/self/task !"); + LOG("Cannot open /proc/self/task !"); break; } diff --git a/src/prefs.c b/src/prefs.c index 07ee5135..91868b5a 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -92,24 +92,24 @@ bool prefs_save(void) { bool success = false; do { if (!prefsFile) { - ERRLOG("Not saving preferences, no file loaded..."); + LOG("Not saving preferences, no file loaded..."); break; } if (!jsonPrefs) { - ERRLOG("Not saving preferences, none loaded..."); + LOG("Not saving preferences, none loaded..."); break; } if (((JSON_s *)jsonPrefs)->numTokens <= 0) { - ERRLOG("Not saving preferences, no preferences loaded..."); + LOG("Not saving preferences, no preferences loaded..."); break; } assert(((JSON_s *)jsonPrefs)->jsonString && "string should be valid"); #define PREFS_ERRPRINT() \ - ERRLOG( \ + LOG( \ "Cannot open the .apple2.json preferences file for writing.\n" \ "Make sure it has R/W permission in your home directory.") diff --git a/src/timing.c b/src/timing.c index fbfc160f..243b7eab 100644 --- a/src/timing.c +++ b/src/timing.c @@ -371,10 +371,10 @@ cpu_runloop: if (c_debugger_should_break() || (debugging_cycles <= 0)) { int err = 0; if ((err = pthread_cond_signal(&dbg_thread_cond))) { - ERRLOG("pthread_cond_signal : %d", err); + LOG("pthread_cond_signal : %d", err); } if ((err = pthread_cond_wait(&cpu_thread_cond, &interface_mutex))) { - ERRLOG("pthread_cond_wait : %d", err); + LOG("pthread_cond_wait : %d", err); } if (debugging_cycles <= 0) { break; @@ -528,7 +528,7 @@ void timing_startCPU(void) { cpu_shutting_down = false; int err = TEMP_FAILURE_RETRY(pthread_create(&cpu_thread_id, NULL, (void *)&cpu_thread, (void *)NULL)); if (err) { - ERRLOG("pthread_create failed!"); + LOG("pthread_create failed!"); assert(false); } } @@ -538,7 +538,7 @@ void timing_stopCPU(void) { LOG("Emulator waiting for CPU thread clean up..."); if (pthread_join(cpu_thread_id, NULL)) { - ERRLOG("OOPS: pthread_join of CPU thread ..."); + LOG("OOPS: pthread_join of CPU thread ..."); } } diff --git a/src/video/gltouchjoy.c b/src/video/gltouchjoy.c index 816d8c08..f1307b4e 100644 --- a/src/video/gltouchjoy.c +++ b/src/video/gltouchjoy.c @@ -146,13 +146,13 @@ static void *_azimuth_create_model(GLModel *parent) { vtxSource = glshader_createSource("SolidColor.vsh"); if (!vtxSource) { - ERRLOG("Cannot compile vertex shader for joystick azimuth!"); + LOG("Cannot compile vertex shader for joystick azimuth!"); break; } frgSource = glshader_createSource("SolidColor.fsh"); if (!frgSource) { - ERRLOG("Cannot compile fragment shader for joystick azimuth!"); + LOG("Cannot compile fragment shader for joystick azimuth!"); break; } diff --git a/src/video/gltouchkbd.c b/src/video/gltouchkbd.c index 3c6d605c..6b498694 100644 --- a/src/video/gltouchkbd.c +++ b/src/video/gltouchkbd.c @@ -727,21 +727,21 @@ static void _loadAltKbd(const char *kbdPath) { // begin with array if (parsedData.jsonTokens[idx].type != JSMN_ARRAY) { - ERRLOG("Keyboard JSON must start with array"); + LOG("Keyboard JSON must start with array"); break; } ++idx; // next is a global comment string if (parsedData.jsonTokens[idx].type != JSMN_STRING) { - ERRLOG("Expecting a comment string at JSON token position 1"); + LOG("Expecting a comment string at JSON token position 1"); break; } ++idx; // next is the dictionary of special strings if (parsedData.jsonTokens[idx].type != JSMN_OBJECT) { - ERRLOG("Expecting a dictionary at JSON token position 2"); + LOG("Expecting a dictionary at JSON token position 2"); break; } const int dictCount = parsedData.jsonTokens[idx].size; @@ -762,7 +762,7 @@ static void _loadAltKbd(const char *kbdPath) { } } if (!allStrings) { - ERRLOG("Specials dictionary should only contain strings"); + LOG("Specials dictionary should only contain strings"); break; } @@ -771,7 +771,7 @@ static void _loadAltKbd(const char *kbdPath) { while (idx < tokCount) { if (row < 2) { if ( !((parsedData.jsonTokens[idx].type == JSMN_ARRAY) && (parsedData.jsonTokens[idx].parent == 0)) ) { - ERRLOG("Expecting a reserved array at keyboard row %d", row+1); + LOG("Expecting a reserved array at keyboard row %d", row+1); break; } if (parsedData.jsonTokens[idx].size != KBD_TEMPLATE_COLS) { @@ -786,7 +786,7 @@ static void _loadAltKbd(const char *kbdPath) { continue; } } else if ( !((parsedData.jsonTokens[idx].type == JSMN_ARRAY) && (parsedData.jsonTokens[idx].size == KBD_TEMPLATE_COLS) && (parsedData.jsonTokens[idx].parent == 0)) ) { - ERRLOG("Expecting an array of ten items at keyboard row %d", row+1); + LOG("Expecting an array of ten items at keyboard row %d", row+1); break; } @@ -795,7 +795,7 @@ static void _loadAltKbd(const char *kbdPath) { for (int col=0; idx