mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-09-28 16:54:51 +00:00
Excise ERRLOG() in favor of LOG()
This commit is contained in:
parent
3b1c72e872
commit
51a5f5fcf7
@ -132,7 +132,7 @@ void Java_org_deadc0de_apple2ix_Apple2CrashHandler_nativeProcessCrash(JNIEnv *en
|
|||||||
do {
|
do {
|
||||||
outputFILE = TEMP_FAILURE_RETRY_FOPEN(fopen(outputPath, "w"));
|
outputFILE = TEMP_FAILURE_RETRY_FOPEN(fopen(outputPath, "w"));
|
||||||
if (!outputFILE) {
|
if (!outputFILE) {
|
||||||
ERRLOG("could not open %s", outputPath);
|
LOG("could not open %s", outputPath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ jstring Java_org_deadc0de_apple2ix_Apple2DisksMenu_nativeChooseDisk(JNIEnv *env,
|
|||||||
} else {
|
} else {
|
||||||
fd = dup(fd);
|
fd = dup(fd);
|
||||||
if (fd == -1) {
|
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 {
|
} else {
|
||||||
fd = dup(fd);
|
fd = dup(fd);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
ERRLOG("OOPS could not dup file descriptor!");
|
LOG("OOPS could not dup file descriptor!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (0);
|
} while (0);
|
||||||
|
@ -86,13 +86,13 @@
|
|||||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&error];
|
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&error];
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
ERRLOG("Error setting AVAudioSessionCategoryAmbient : %s", [[error description] UTF8String]);
|
LOG("Error setting AVAudioSessionCategoryAmbient : %s", [[error description] UTF8String]);
|
||||||
error = nil;
|
error = nil;
|
||||||
}
|
}
|
||||||
[[AVAudioSession sharedInstance] setActive:YES error:&error];
|
[[AVAudioSession sharedInstance] setActive:YES error:&error];
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
ERRLOG("Error activating AVAudioSession : %s", [[error description] UTF8String]);
|
LOG("Error activating AVAudioSession : %s", [[error description] UTF8String]);
|
||||||
error = nil;
|
error = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@
|
|||||||
[[AVAudioSession sharedInstance] setActive:NO error:&error];
|
[[AVAudioSession sharedInstance] setActive:NO error:&error];
|
||||||
if (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)
|
if (error)
|
||||||
{
|
{
|
||||||
ERRLOG("Could not create directory. Error: %s", [[error description] UTF8String]);
|
LOG("Could not create directory. Error: %s", [[error description] UTF8String]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSArray *fileList = [fileManager contentsOfDirectoryAtPath:resourcesPath error:&error];
|
NSArray *fileList = [fileManager contentsOfDirectoryAtPath:resourcesPath error:&error];
|
||||||
if (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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@
|
|||||||
[fileManager copyItemAtPath:resourcesFile toPath:documentsFile error:&error];
|
[fileManager copyItemAtPath:resourcesFile toPath:documentsFile error:&error];
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
ERRLOG("Could not copy file. Error: %s", [[error description] UTF8String]);
|
LOG("Could not copy file. Error: %s", [[error description] UTF8String]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ ALCcontext* InitAL(void)
|
|||||||
device = alcOpenDevice(NULL);
|
device = alcOpenDevice(NULL);
|
||||||
if(!device)
|
if(!device)
|
||||||
{
|
{
|
||||||
ERRLOG("Could not open a device!");
|
LOG("Could not open a device!");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ ALCcontext* InitAL(void)
|
|||||||
alcDestroyContext(ctx);
|
alcDestroyContext(ctx);
|
||||||
}
|
}
|
||||||
alcCloseDevice(device);
|
alcCloseDevice(device);
|
||||||
ERRLOG("Could not set a context!");
|
LOG("Could not set a context!");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1293,7 +1293,7 @@ static void* SSI263Thread(void *lpParameter)
|
|||||||
err = pthread_cond_timedwait(&ssi263_cond, &ssi263_mutex, &wait);
|
err = pthread_cond_timedwait(&ssi263_cond, &ssi263_mutex, &wait);
|
||||||
if (err && (err != ETIMEDOUT))
|
if (err && (err != ETIMEDOUT))
|
||||||
{
|
{
|
||||||
ERRLOG("OOPS pthread_cond_timedwait");
|
LOG("OOPS pthread_cond_timedwait");
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&ssi263_mutex);
|
pthread_mutex_unlock(&ssi263_mutex);
|
||||||
|
|
||||||
@ -1562,12 +1562,12 @@ static bool MB_DSInit()
|
|||||||
int err = 0;
|
int err = 0;
|
||||||
if ((err = pthread_mutex_init(&ssi263_mutex, NULL)))
|
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)))
|
if ((err = pthread_cond_init(&ssi263_cond, NULL)))
|
||||||
{
|
{
|
||||||
ERRLOG("OOPS pthread_cond_init");
|
LOG("OOPS pthread_cond_init");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
g_hSSI263Event[0] = CreateEvent(NULL, // lpEventAttributes
|
g_hSSI263Event[0] = CreateEvent(NULL, // lpEventAttributes
|
||||||
@ -1708,7 +1708,7 @@ static bool MB_DSInit()
|
|||||||
int err = 0;
|
int err = 0;
|
||||||
if ((err = pthread_create(&g_hThread, NULL, SSI263Thread, NULL)))
|
if ((err = pthread_create(&g_hThread, NULL, SSI263Thread, NULL)))
|
||||||
{
|
{
|
||||||
ERRLOG("SSI263Thread");
|
LOG("SSI263Thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
// assuming time critical ...
|
// assuming time critical ...
|
||||||
@ -1719,11 +1719,11 @@ static bool MB_DSInit()
|
|||||||
|
|
||||||
int prio = 0;
|
int prio = 0;
|
||||||
if ((prio = sched_get_priority_max(policy)) < 0) {
|
if ((prio = sched_get_priority_max(policy)) < 0) {
|
||||||
ERRLOG("OOPS sched_get_priority_max");
|
LOG("OOPS sched_get_priority_max");
|
||||||
} else {
|
} else {
|
||||||
if ((err = pthread_setschedprio(thread, prio)))
|
if ((err = pthread_setschedprio(thread, prio)))
|
||||||
{
|
{
|
||||||
ERRLOG("OOPS pthread_setschedprio");
|
LOG("OOPS pthread_setschedprio");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
@ -1757,7 +1757,7 @@ static void MB_DSUninit()
|
|||||||
|
|
||||||
int err = 0;
|
int err = 0;
|
||||||
if ( (err = pthread_join(g_hThread, NULL)) ) {
|
if ( (err = pthread_join(g_hThread, NULL)) ) {
|
||||||
ERRLOG("OOPS pthread_join");
|
LOG("OOPS pthread_join");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
unsigned long dwExitCode;
|
unsigned long dwExitCode;
|
||||||
|
@ -45,7 +45,7 @@ static long playq_enqueue(PlayQueue_s *_this, INOUT PlayNode_s *node) {
|
|||||||
// detach a node from the available pool
|
// detach a node from the available pool
|
||||||
PQListNode_s *listNode = list->availNodes;
|
PQListNode_s *listNode = list->availNodes;
|
||||||
if (!listNode) {
|
if (!listNode) {
|
||||||
ERRLOG("Cannot enqueue: no slots available");
|
LOG("Cannot enqueue: no slots available");
|
||||||
err = -1;
|
err = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -228,14 +228,14 @@ PlayQueue_s *playq_createPlayQueue(const long *nodeIdPtr, unsigned long numBuffe
|
|||||||
do {
|
do {
|
||||||
playq = CALLOC(1, sizeof(PlayQueue_s));
|
playq = CALLOC(1, sizeof(PlayQueue_s));
|
||||||
if (!playq) {
|
if (!playq) {
|
||||||
ERRLOG("no memory");
|
LOG("no memory");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PQList_s *list = CALLOC(1, sizeof(PQList_s));
|
PQList_s *list = CALLOC(1, sizeof(PQList_s));
|
||||||
playq->_internal = list;
|
playq->_internal = list;
|
||||||
if (!list) {
|
if (!list) {
|
||||||
ERRLOG("no memory");
|
LOG("no memory");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ PlayQueue_s *playq_createPlayQueue(const long *nodeIdPtr, unsigned long numBuffe
|
|||||||
LOG("CREATING PlayNode_s node ID: %ld", nodeIdPtr[i]);
|
LOG("CREATING PlayNode_s node ID: %ld", nodeIdPtr[i]);
|
||||||
listNode->node.nodeId = nodeIdPtr[i];
|
listNode->node.nodeId = nodeIdPtr[i];
|
||||||
if (!listNode) {
|
if (!listNode) {
|
||||||
ERRLOG("no memory");
|
LOG("no memory");
|
||||||
allocSuccess = false;
|
allocSuccess = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ static long _ALProcessPlayBuffers(ALVoice *voice, ALuint *bytes_queued) {
|
|||||||
ALint processed = 0;
|
ALint processed = 0;
|
||||||
alGetSourcei(voice->source, AL_BUFFERS_PROCESSED, &processed);
|
alGetSourcei(voice->source, AL_BUFFERS_PROCESSED, &processed);
|
||||||
if ((err = alGetError()) != AL_NO_ERROR) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ static long _ALProcessPlayBuffers(ALVoice *voice, ALuint *bytes_queued) {
|
|||||||
ALuint bufid = 0;
|
ALuint bufid = 0;
|
||||||
alSourceUnqueueBuffers(voice->source, 1, &bufid);
|
alSourceUnqueueBuffers(voice->source, 1, &bufid);
|
||||||
if ((err = alGetError()) != AL_NO_ERROR) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ static long _ALProcessPlayBuffers(ALVoice *voice, ALuint *bytes_queued) {
|
|||||||
};
|
};
|
||||||
err = voice->playq->Get(voice->playq, &playNode);
|
err = voice->playq->Get(voice->playq, &playNode);
|
||||||
if (err) {
|
if (err) {
|
||||||
ERRLOG("OOPS, OpenAL bufid %u not found in playlist...", bufid);
|
LOG("OOPS, OpenAL bufid %u not found in playlist...", bufid);
|
||||||
} else {
|
} else {
|
||||||
_playq_removeNode(voice, &playNode);
|
_playq_removeNode(voice, &playNode);
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ static long _ALProcessPlayBuffers(ALVoice *voice, ALuint *bytes_queued) {
|
|||||||
ALint play_offset = 0;
|
ALint play_offset = 0;
|
||||||
alGetSourcei(voice->source, AL_BYTE_OFFSET, &play_offset);
|
alGetSourcei(voice->source, AL_BYTE_OFFSET, &play_offset);
|
||||||
if ((err = alGetError()) != AL_NO_ERROR) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
assert((play_offset >= 0)/* && (play_offset < voice->buffersize)*/);
|
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);
|
alBufferData(playNode.nodeId, voice->format, playNode.bytes, playNode.numBytes, voice->rate);
|
||||||
if ((err = alGetError()) != AL_NO_ERROR) {
|
if ((err = alGetError()) != AL_NO_ERROR) {
|
||||||
_playq_removeNode(voice, &playNode);
|
_playq_removeNode(voice, &playNode);
|
||||||
ERRLOG("OOPS, Error alBufferData : 0x%08lx", err);
|
LOG("OOPS, Error alBufferData : 0x%08lx", err);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,14 +227,14 @@ static long _ALSubmitBufferToOpenAL(ALVoice *voice) {
|
|||||||
alSourceQueueBuffers(voice->source, 1, &nodeId);
|
alSourceQueueBuffers(voice->source, 1, &nodeId);
|
||||||
if ((err = alGetError()) != AL_NO_ERROR) {
|
if ((err = alGetError()) != AL_NO_ERROR) {
|
||||||
_playq_removeNode(voice, &playNode);
|
_playq_removeNode(voice, &playNode);
|
||||||
ERRLOG("OOPS, Error buffering data : 0x%08lx", err);
|
LOG("OOPS, Error buffering data : 0x%08lx", err);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALint state = 0;
|
ALint state = 0;
|
||||||
alGetSourcei(voice->source, AL_SOURCE_STATE, &state);
|
alGetSourcei(voice->source, AL_SOURCE_STATE, &state);
|
||||||
if ((err = alGetError()) != AL_NO_ERROR) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
if ((state != AL_PLAYING) && (state != AL_PAUSED)) {
|
if ((state != AL_PLAYING) && (state != AL_PAUSED)) {
|
||||||
@ -313,7 +313,7 @@ static long ALGetStatus(AudioBuffer_s *_this, OUTPARM unsigned long *status) {
|
|||||||
ALint state = 0;
|
ALint state = 0;
|
||||||
alGetSourcei(voice->source, AL_SOURCE_STATE, &state);
|
alGetSourcei(voice->source, AL_SOURCE_STATE, &state);
|
||||||
if ((err = alGetError()) != AL_NO_ERROR) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ static long ALGetStatus(AudioBuffer_s *_this, OUTPARM unsigned long *status) {
|
|||||||
static void _openal_destroyVoice(ALVoice *voice) {
|
static void _openal_destroyVoice(ALVoice *voice) {
|
||||||
alDeleteSources(1, &voice->source);
|
alDeleteSources(1, &voice->source);
|
||||||
if (alGetError() != AL_NO_ERROR) {
|
if (alGetError() != AL_NO_ERROR) {
|
||||||
ERRLOG("OOPS, Failed to delete source");
|
LOG("OOPS, Failed to delete source");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (voice->data) {
|
if (voice->data) {
|
||||||
@ -343,7 +343,7 @@ static void _openal_destroyVoice(ALVoice *voice) {
|
|||||||
for (unsigned int i=0; i<OPENAL_NUM_BUFFERS; i++) {
|
for (unsigned int i=0; i<OPENAL_NUM_BUFFERS; i++) {
|
||||||
alDeleteBuffers(1, voice->buffers);
|
alDeleteBuffers(1, voice->buffers);
|
||||||
if (alGetError() != AL_NO_ERROR) {
|
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 {
|
do {
|
||||||
voice = CALLOC(1, sizeof(*voice));
|
voice = CALLOC(1, sizeof(*voice));
|
||||||
if (voice == NULL) {
|
if (voice == NULL) {
|
||||||
ERRLOG("OOPS, Out of memory!");
|
LOG("OOPS, Out of memory!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
alGenBuffers(OPENAL_NUM_BUFFERS, voice->buffers);
|
alGenBuffers(OPENAL_NUM_BUFFERS, voice->buffers);
|
||||||
if (alGetError() != AL_NO_ERROR) {
|
if (alGetError() != AL_NO_ERROR) {
|
||||||
ERRLOG("OOPS, Could not create buffers");
|
LOG("OOPS, Could not create buffers");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
alGenSources(1, &voice->source);
|
alGenSources(1, &voice->source);
|
||||||
if (alGetError() != AL_NO_ERROR) {
|
if (alGetError() != AL_NO_ERROR) {
|
||||||
ERRLOG("OOPS, Could not create source");
|
LOG("OOPS, Could not create source");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set parameters so mono sources play out the front-center speaker and won't distance attenuate.
|
// Set parameters so mono sources play out the front-center speaker and won't distance attenuate.
|
||||||
alSource3i(voice->source, AL_POSITION, 0, 0, -1);
|
alSource3i(voice->source, AL_POSITION, 0, 0, -1);
|
||||||
if (alGetError() != AL_NO_ERROR) {
|
if (alGetError() != AL_NO_ERROR) {
|
||||||
ERRLOG("OOPS, Could not set AL_POSITION source parameter");
|
LOG("OOPS, Could not set AL_POSITION source parameter");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
alSourcei(voice->source, AL_SOURCE_RELATIVE, AL_TRUE);
|
alSourcei(voice->source, AL_SOURCE_RELATIVE, AL_TRUE);
|
||||||
if (alGetError() != AL_NO_ERROR) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
alSourcei(voice->source, AL_ROLLOFF_FACTOR, 0);
|
alSourcei(voice->source, AL_ROLLOFF_FACTOR, 0);
|
||||||
if (alGetError() != AL_NO_ERROR) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
alSourcei(voice->source, AL_STREAMING, AL_TRUE);
|
alSourcei(voice->source, AL_STREAMING, AL_TRUE);
|
||||||
if (alGetError() != AL_NO_ERROR) {
|
if (alGetError() != AL_NO_ERROR) {
|
||||||
ERRLOG("OOPS, Could not set AL_STREAMING source parameter");
|
LOG("OOPS, Could not set AL_STREAMING source parameter");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -406,7 +406,7 @@ static ALVoice *_openal_createVoice(unsigned long numChannels) {
|
|||||||
}
|
}
|
||||||
voice->playq = playq_createPlayQueue(longBuffers, OPENAL_NUM_BUFFERS);
|
voice->playq = playq_createPlayQueue(longBuffers, OPENAL_NUM_BUFFERS);
|
||||||
if (!voice->playq) {
|
if (!voice->playq) {
|
||||||
ERRLOG("OOPS, Not enough memory for PlayQueue");
|
LOG("OOPS, Not enough memory for PlayQueue");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +426,7 @@ static ALVoice *_openal_createVoice(unsigned long numChannels) {
|
|||||||
|
|
||||||
voice->data = CALLOC(1, voice->buffersize);
|
voice->data = CALLOC(1, voice->buffersize);
|
||||||
if (voice->data == NULL) {
|
if (voice->data == NULL) {
|
||||||
ERRLOG("OOPS, Error allocating %d bytes", voice->buffersize);
|
LOG("OOPS, Error allocating %d bytes", voice->buffersize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,14 +483,14 @@ static long openal_createSoundBuffer(const AudioContext_s *audio_context, INOUT
|
|||||||
assert(ctx != NULL);
|
assert(ctx != NULL);
|
||||||
|
|
||||||
if ((voice = _openal_createVoice(NUM_CHANNELS)) == NULL) {
|
if ((voice = _openal_createVoice(NUM_CHANNELS)) == NULL) {
|
||||||
ERRLOG("OOPS, Cannot create new voice");
|
LOG("OOPS, Cannot create new voice");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ALVoices immutableNode = { /*const*/.source = voice->source };
|
ALVoices immutableNode = { /*const*/.source = voice->source };
|
||||||
ALVoices *vnode = CALLOC(1, sizeof(ALVoices));
|
ALVoices *vnode = CALLOC(1, sizeof(ALVoices));
|
||||||
if (!vnode) {
|
if (!vnode) {
|
||||||
ERRLOG("OOPS, Not enough memory");
|
LOG("OOPS, Not enough memory");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memcpy(vnode, &immutableNode, sizeof(ALVoices));
|
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);
|
HASH_ADD_INT(voices, source, vnode);
|
||||||
|
|
||||||
if ((*soundbuf_struct = CALLOC(1, sizeof(AudioBuffer_s))) == NULL) {
|
if ((*soundbuf_struct = CALLOC(1, sizeof(AudioBuffer_s))) == NULL) {
|
||||||
ERRLOG("OOPS, Not enough memory");
|
LOG("OOPS, Not enough memory");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,7 +556,7 @@ static long openal_systemSetup(INOUT AudioContext_s **audio_context) {
|
|||||||
|
|
||||||
if ((ctx = InitAL()) == NULL) {
|
if ((ctx = InitAL()) == NULL) {
|
||||||
// NOTE : currently assuming just one OpenAL global context
|
// NOTE : currently assuming just one OpenAL global context
|
||||||
ERRLOG("OOPS, OpenAL initialize failed");
|
LOG("OOPS, OpenAL initialize failed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,7 +567,7 @@ static long openal_systemSetup(INOUT AudioContext_s **audio_context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((*audio_context = CALLOC(1, sizeof(AudioContext_s))) == NULL) {
|
if ((*audio_context = CALLOC(1, sizeof(AudioContext_s))) == NULL) {
|
||||||
ERRLOG("OOPS, Not enough memory");
|
LOG("OOPS, Not enough memory");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,7 +600,7 @@ static long openal_systemPause(AudioContext_s *audio_context) {
|
|||||||
alSourcePause(vnode->source);
|
alSourcePause(vnode->source);
|
||||||
err = alGetError();
|
err = alGetError();
|
||||||
if (err != AL_NO_ERROR) {
|
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);
|
alSourcePlay(vnode->source);
|
||||||
err = alGetError();
|
err = alGetError();
|
||||||
if (err != AL_NO_ERROR) {
|
if (err != AL_NO_ERROR) {
|
||||||
ERRLOG("OOPS, Failed to pause source : 0x%08lx", err);
|
LOG("OOPS, Failed to pause source : 0x%08lx", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ static long _SLMaybeSubmitAndStart(SLVoice *voice) {
|
|||||||
EngineContext_s *ctx = (EngineContext_s *)voice->ctx;
|
EngineContext_s *ctx = (EngineContext_s *)voice->ctx;
|
||||||
SLresult result = (*(ctx->bqPlayerPlay))->GetPlayState(ctx->bqPlayerPlay, &state);
|
SLresult result = (*(ctx->bqPlayerPlay))->GetPlayState(ctx->bqPlayerPlay, &state);
|
||||||
if (result != SL_RESULT_SUCCESS) {
|
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 {
|
} else {
|
||||||
if ((state != SL_PLAYSTATE_PLAYING) && (state != SL_PLAYSTATE_PAUSED)) {
|
if ((state != SL_PLAYSTATE_PLAYING) && (state != SL_PLAYSTATE_PAUSED)) {
|
||||||
LOG("FORCING restart audio buffer queue playback ...");
|
LOG("FORCING restart audio buffer queue playback ...");
|
||||||
@ -338,7 +338,7 @@ static long SLGetStatus(AudioBuffer_s *_this, OUTPARM unsigned long *status) {
|
|||||||
SLuint32 state = 0;
|
SLuint32 state = 0;
|
||||||
result = (*(ctx->bqPlayerPlay))->GetPlayState(ctx->bqPlayerPlay, &state);
|
result = (*(ctx->bqPlayerPlay))->GetPlayState(ctx->bqPlayerPlay, &state);
|
||||||
if (result != SL_RESULT_SUCCESS) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,14 +428,14 @@ static long opensl_createSoundBuffer(const AudioContext_s *audio_context, INOUT
|
|||||||
LOG("Creating new SLVoice ...");
|
LOG("Creating new SLVoice ...");
|
||||||
voice = CALLOC(1, sizeof(*voice));
|
voice = CALLOC(1, sizeof(*voice));
|
||||||
if (voice == NULL) {
|
if (voice == NULL) {
|
||||||
ERRLOG("OOPS, Out of memory!");
|
LOG("OOPS, Out of memory!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
voice->bufferSize = bufferSize;
|
voice->bufferSize = bufferSize;
|
||||||
// Allocate enough space for the temp buffer (including a maximum allowed overflow)
|
// Allocate enough space for the temp buffer (including a maximum allowed overflow)
|
||||||
voice->ringBuffer = CALLOC(1, voice->bufferSize + ctx->submitSize/*max overflow*/);
|
voice->ringBuffer = CALLOC(1, voice->bufferSize + ctx->submitSize/*max overflow*/);
|
||||||
if (voice->ringBuffer == NULL) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -445,7 +445,7 @@ static long opensl_createSoundBuffer(const AudioContext_s *audio_context, INOUT
|
|||||||
voice->ctx = ctx;
|
voice->ctx = ctx;
|
||||||
|
|
||||||
if ((*soundbuf_struct = CALLOC(1, sizeof(AudioBuffer_s))) == NULL) {
|
if ((*soundbuf_struct = CALLOC(1, sizeof(AudioBuffer_s))) == NULL) {
|
||||||
ERRLOG("OOPS, Not enough memory");
|
LOG("OOPS, Not enough memory");
|
||||||
break;
|
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->submitSize = android_stereoBufferSubmitSizeSamples * opensles_audio_backend.systemSettings.bytesPerSample * NUM_CHANNELS;
|
||||||
ctx->mixBuf = CALLOC(1, ctx->submitSize);
|
ctx->mixBuf = CALLOC(1, ctx->submitSize);
|
||||||
if (ctx->mixBuf == NULL) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create basic engine
|
// create basic engine
|
||||||
result = slCreateEngine(&(ctx->engineObject), 0, NULL, /*engineMixIIDCount:*/0, /*engineMixIIDs:*/NULL, /*engineMixReqs:*/NULL);
|
result = slCreateEngine(&(ctx->engineObject), 0, NULL, /*engineMixIIDCount:*/0, /*engineMixIIDs:*/NULL, /*engineMixReqs:*/NULL);
|
||||||
if (result != SL_RESULT_SUCCESS) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// realize the engine
|
// realize the engine
|
||||||
result = (*(ctx->engineObject))->Realize(ctx->engineObject, /*asynchronous_realization:*/SL_BOOLEAN_FALSE);
|
result = (*(ctx->engineObject))->Realize(ctx->engineObject, /*asynchronous_realization:*/SL_BOOLEAN_FALSE);
|
||||||
if (result != SL_RESULT_SUCCESS) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the actual engine interface
|
// get the actual engine interface
|
||||||
result = (*(ctx->engineObject))->GetInterface(ctx->engineObject, SL_IID_ENGINE, &(ctx->engineEngine));
|
result = (*(ctx->engineObject))->GetInterface(ctx->engineObject, SL_IID_ENGINE, &(ctx->engineEngine));
|
||||||
if (result != SL_RESULT_SUCCESS) {
|
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;
|
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);
|
result = (*(ctx->engineEngine))->CreateOutputMix(ctx->engineEngine, &(ctx->outputMixObject), 0, NULL, NULL);
|
||||||
if (result != SL_RESULT_SUCCESS) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// realize the output mix
|
// realize the output mix
|
||||||
result = (*(ctx->outputMixObject))->Realize(ctx->outputMixObject, SL_BOOLEAN_FALSE);
|
result = (*(ctx->outputMixObject))->Realize(ctx->outputMixObject, SL_BOOLEAN_FALSE);
|
||||||
if (result != SL_RESULT_SUCCESS) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create soundcore API wrapper
|
// create soundcore API wrapper
|
||||||
if ((*audio_context = CALLOC(1, sizeof(AudioContext_s))) == NULL) {
|
if ((*audio_context = CALLOC(1, sizeof(AudioContext_s))) == NULL) {
|
||||||
result = -1;
|
result = -1;
|
||||||
ERRLOG("OOPS, Not enough memory");
|
LOG("OOPS, Not enough memory");
|
||||||
break;
|
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);
|
result = (*(ctx->engineEngine))->CreateAudioPlayer(ctx->engineEngine, &(ctx->bqPlayerObject), &audioSrc, &audioSnk, _NUM_INTERFACES, ids, req);
|
||||||
if (result != SL_RESULT_SUCCESS) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// realize the player
|
// realize the player
|
||||||
result = (*(ctx->bqPlayerObject))->Realize(ctx->bqPlayerObject, /*asynchronous_realization:*/SL_BOOLEAN_FALSE);
|
result = (*(ctx->bqPlayerObject))->Realize(ctx->bqPlayerObject, /*asynchronous_realization:*/SL_BOOLEAN_FALSE);
|
||||||
if (result != SL_RESULT_SUCCESS) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the play interface
|
// get the play interface
|
||||||
result = (*(ctx->bqPlayerObject))->GetInterface(ctx->bqPlayerObject, SL_IID_PLAY, &(ctx->bqPlayerPlay));
|
result = (*(ctx->bqPlayerObject))->GetInterface(ctx->bqPlayerObject, SL_IID_PLAY, &(ctx->bqPlayerPlay));
|
||||||
if (result != SL_RESULT_SUCCESS) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the buffer queue interface
|
// get the buffer queue interface
|
||||||
result = (*(ctx->bqPlayerObject))->GetInterface(ctx->bqPlayerObject, SL_IID_BUFFERQUEUE, &(ctx->bqPlayerBufferQueue));
|
result = (*(ctx->bqPlayerObject))->GetInterface(ctx->bqPlayerObject, SL_IID_BUFFERQUEUE, &(ctx->bqPlayerBufferQueue));
|
||||||
if (result != SL_RESULT_SUCCESS) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// register callback on the buffer queue
|
// register callback on the buffer queue
|
||||||
result = (*(ctx->bqPlayerBufferQueue))->RegisterCallback(ctx->bqPlayerBufferQueue, bqPlayerCallback, ctx);
|
result = (*(ctx->bqPlayerBufferQueue))->RegisterCallback(ctx->bqPlayerBufferQueue, bqPlayerCallback, ctx);
|
||||||
if (result != SL_RESULT_SUCCESS) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -737,12 +737,12 @@ static long opensles_systemResume(AudioContext_s *audio_context) {
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
if (result != SL_RESULT_SUCCESS) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state != SL_PLAYSTATE_PLAYING) {
|
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) {
|
if (state == SL_PLAYSTATE_PAUSED) {
|
||||||
|
@ -52,7 +52,7 @@ long audio_createSoundBuffer(INOUT AudioBuffer_s **audioBuffer) {
|
|||||||
long err = 0;
|
long err = 0;
|
||||||
do {
|
do {
|
||||||
if (!audioContext) {
|
if (!audioContext) {
|
||||||
ERRLOG("Cannot create sound buffer, no context");
|
LOG("Cannot create sound buffer, no context");
|
||||||
err = -1;
|
err = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ static unsigned int _submit_samples_buffer(const unsigned long num_channel_sampl
|
|||||||
unsigned long counter = 0;
|
unsigned long counter = 0;
|
||||||
do {
|
do {
|
||||||
if (speakerBuffer->Lock(speakerBuffer, curr_buffer_size, &system_samples_buffer, &system_buffer_size)) {
|
if (speakerBuffer->Lock(speakerBuffer, curr_buffer_size, &system_samples_buffer, &system_buffer_size)) {
|
||||||
ERRLOG("Problem locking speaker buffer");
|
LOG("Problem locking speaker buffer");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,7 +352,7 @@ static unsigned int _submit_samples_buffer(const unsigned long num_channel_sampl
|
|||||||
|
|
||||||
err = speakerBuffer->Unlock(speakerBuffer, system_buffer_size);
|
err = speakerBuffer->Unlock(speakerBuffer, system_buffer_size);
|
||||||
if (err) {
|
if (err) {
|
||||||
ERRLOG("Problem unlocking speaker buffer");
|
LOG("Problem unlocking speaker buffer");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/common.h
10
src/common.h
@ -230,13 +230,6 @@ static const char *log_end = "\n";
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LOG(...) \
|
#define LOG(...) \
|
||||||
if (do_logging) { \
|
|
||||||
errno = 0; \
|
|
||||||
GLenum _glerr = 0; \
|
|
||||||
_LOG(__VA_ARGS__); \
|
|
||||||
} //
|
|
||||||
|
|
||||||
#define ERRLOG(...) \
|
|
||||||
if (do_logging) { \
|
if (do_logging) { \
|
||||||
GLenum _glerr = safeGLGetError(); \
|
GLenum _glerr = safeGLGetError(); \
|
||||||
_LOG(__VA_ARGS__); \
|
_LOG(__VA_ARGS__); \
|
||||||
@ -274,9 +267,6 @@ static const char *log_end = "\n";
|
|||||||
|
|
||||||
#else // NDEBUG
|
#else // NDEBUG
|
||||||
|
|
||||||
#define ERRLOG(...) \
|
|
||||||
do { } while (0)
|
|
||||||
|
|
||||||
#define ERRQUIT(...) \
|
#define ERRQUIT(...) \
|
||||||
do { } while (0)
|
do { } while (0)
|
||||||
|
|
||||||
|
26
src/disk.c
26
src/disk.c
@ -453,7 +453,7 @@ static void save_track_data(int drive) {
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
TEMP_FAILURE_RETRY(ret = msync(disk6.disk[drive].raw_image_data+niboff, NIB_TRACK_SIZE, MS_SYNC));
|
TEMP_FAILURE_RETRY(ret = msync(disk6.disk[drive].raw_image_data+niboff, NIB_TRACK_SIZE, MS_SYNC));
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ERRLOG("Error syncing file %s", disk6.disk[drive].file_name);
|
LOG("Error syncing file %s", disk6.disk[drive].file_name);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
@ -464,7 +464,7 @@ static void save_track_data(int drive) {
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
TEMP_FAILURE_RETRY(ret = msync(disk6.disk[drive].raw_image_data+dskoff, DSK_TRACK_SIZE, MS_SYNC));
|
TEMP_FAILURE_RETRY(ret = msync(disk6.disk[drive].raw_image_data+dskoff, DSK_TRACK_SIZE, MS_SYNC));
|
||||||
if (ret) {
|
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 ...
|
// 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);
|
err = zlib_deflate_buffer(/*src:*/disk6.disk[drive].raw_image_data, disk6.disk[drive].whole_len, /*dst:*/compressed_data, &compressed_size);
|
||||||
if (err) {
|
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) {
|
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));
|
TEMP_FAILURE_RETRY(ret = msync(disk6.disk[drive].raw_image_data, disk6.disk[drive].whole_len, MS_SYNC));
|
||||||
if (ret) {
|
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));
|
TEMP_FAILURE_RETRY(ret = munmap(disk6.disk[drive].raw_image_data, disk6.disk[drive].whole_len));
|
||||||
if (ret) {
|
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) {
|
if (compressed_size > 0) {
|
||||||
TEMP_FAILURE_RETRY(ret = ftruncate(disk6.disk[drive].fd, compressed_size));
|
TEMP_FAILURE_RETRY(ret = ftruncate(disk6.disk[drive].fd, compressed_size));
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
ERRLOG("OOPS, cannot truncate file descriptor!");
|
LOG("OOPS, cannot truncate file descriptor!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMP_FAILURE_RETRY(ret = fsync(disk6.disk[drive].fd));
|
TEMP_FAILURE_RETRY(ret = fsync(disk6.disk[drive].fd));
|
||||||
if (ret) {
|
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));
|
TEMP_FAILURE_RETRY(ret = close(disk6.disk[drive].fd));
|
||||||
if (ret) {
|
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 ...
|
// disk images inserted read/write are mmap'd/inflated in place ...
|
||||||
TEMP_FAILURE_RETRY(fd = dup(fd));
|
TEMP_FAILURE_RETRY(fd = dup(fd));
|
||||||
if (fd == -1) {
|
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;
|
err = ERR_CANNOT_DUP;
|
||||||
break;
|
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 ...
|
bool file_actually_was_gzipped; // but we don't care ...
|
||||||
err = zlib_inflate_inplace(disk6.disk[drive].fd, expected, &file_actually_was_gzipped);
|
err = zlib_inflate_inplace(disk6.disk[drive].fd, expected, &file_actually_was_gzipped);
|
||||||
if (err) {
|
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;
|
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));
|
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) {
|
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;
|
err = ERR_MMAP_FAILED;
|
||||||
break;
|
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);
|
assert(track_width <= NIB_TRACK_SIZE);
|
||||||
#if CONFORMANT_TRACKS
|
#if CONFORMANT_TRACKS
|
||||||
if (track_width != NI2_TRACK_SIZE) {
|
if (track_width != NI2_TRACK_SIZE) {
|
||||||
ERRLOG("Invalid dsk image creation...");
|
LOG("Invalid dsk image creation...");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!disk6.disk[drive].track_width) {
|
if (!disk6.disk[drive].track_width) {
|
||||||
@ -1010,7 +1010,7 @@ void disk6_flush(int drive) {
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
TEMP_FAILURE_RETRY(ret = msync(disk6.disk[drive].raw_image_data, disk6.disk[drive].whole_len, MS_SYNC));
|
TEMP_FAILURE_RETRY(ret = msync(disk6.disk[drive].raw_image_data, disk6.disk[drive].whole_len, MS_SYNC));
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ERRLOG("Error syncing file %s", disk6.disk[drive].file_name);
|
LOG("Error syncing file %s", disk6.disk[drive].file_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ static int _json_createFromString(const char *jsonString, INOUT JSON_ref *jsonRe
|
|||||||
if (!parsedData->jsonTokens) {
|
if (!parsedData->jsonTokens) {
|
||||||
parsedData->jsonTokens = CALLOC(numTokens, sizeof(jsmntok_t));
|
parsedData->jsonTokens = CALLOC(numTokens, sizeof(jsmntok_t));
|
||||||
if (UNLIKELY(!parsedData->jsonTokens)) {
|
if (UNLIKELY(!parsedData->jsonTokens)) {
|
||||||
ERRLOG("WHOA3 : %s", strerror(errno));
|
LOG("WHOA3 : %s", strerror(errno));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -243,7 +243,7 @@ static int _json_createFromString(const char *jsonString, INOUT JSON_ref *jsonRe
|
|||||||
numTokens <<= 1;
|
numTokens <<= 1;
|
||||||
jsmntok_t *newTokens = REALLOC(parsedData->jsonTokens, numTokens * sizeof(jsmntok_t));
|
jsmntok_t *newTokens = REALLOC(parsedData->jsonTokens, numTokens * sizeof(jsmntok_t));
|
||||||
if (UNLIKELY(!newTokens)) {
|
if (UNLIKELY(!newTokens)) {
|
||||||
ERRLOG("WHOA4 : %s", strerror(errno));
|
LOG("WHOA4 : %s", strerror(errno));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memset(newTokens, '\0', numTokens * sizeof(jsmntok_t));
|
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) {
|
if (errCount < 0) {
|
||||||
ERRLOG("%s", "OOPS error parsing JSON : ");
|
LOG("%s", "OOPS error parsing JSON : ");
|
||||||
switch (errCount) {
|
switch (errCount) {
|
||||||
case JSMN_ERROR_NOMEM:
|
case JSMN_ERROR_NOMEM:
|
||||||
assert(0 && "should not happen");
|
assert(0 && "should not happen");
|
||||||
break;
|
break;
|
||||||
case JSMN_ERROR_INVAL:
|
case JSMN_ERROR_INVAL:
|
||||||
ERRLOG("%s", "Invalid character inside JSON string");
|
LOG("%s", "Invalid character inside JSON string");
|
||||||
break;
|
break;
|
||||||
case JSMN_ERROR_PART:
|
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;
|
break;
|
||||||
case JSMN_ERROR_PRIMITIVE_INVAL:
|
case JSMN_ERROR_PRIMITIVE_INVAL:
|
||||||
ERRLOG("%s", "Invalid character inside JSON primitive");
|
LOG("%s", "Invalid character inside JSON primitive");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERRLOG("UNKNOWN errCount : %d", errCount);
|
LOG("UNKNOWN errCount : %d", errCount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -310,7 +310,7 @@ int json_createFromFD(int fd, INOUT JSON_ref *jsonRef) {
|
|||||||
jsonLen = JSON_LENGTH*2;
|
jsonLen = JSON_LENGTH*2;
|
||||||
jsonString = MALLOC(jsonLen);
|
jsonString = MALLOC(jsonLen);
|
||||||
if (UNLIKELY(jsonString == NULL)) {
|
if (UNLIKELY(jsonString == NULL)) {
|
||||||
ERRLOG("WHOA : %s", strerror(errno));
|
LOG("WHOA : %s", strerror(errno));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ int json_createFromFD(int fd, INOUT JSON_ref *jsonRef) {
|
|||||||
do {
|
do {
|
||||||
TEMP_FAILURE_RETRY(bytesRead = read(fd, jsonString+jsonIdx, JSON_LENGTH));
|
TEMP_FAILURE_RETRY(bytesRead = read(fd, jsonString+jsonIdx, JSON_LENGTH));
|
||||||
if (bytesRead < 0) {
|
if (bytesRead < 0) {
|
||||||
ERRLOG("Error reading file : %s", strerror(errno));
|
LOG("Error reading file : %s", strerror(errno));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (bytesRead) {
|
if (bytesRead) {
|
||||||
@ -328,7 +328,7 @@ int json_createFromFD(int fd, INOUT JSON_ref *jsonRef) {
|
|||||||
jsonLen <<= 1;
|
jsonLen <<= 1;
|
||||||
char *newString = REALLOC(jsonString, jsonLen);
|
char *newString = REALLOC(jsonString, jsonLen);
|
||||||
if (UNLIKELY(!newString)) {
|
if (UNLIKELY(!newString)) {
|
||||||
ERRLOG("WHOA2 : %s", strerror(errno));
|
LOG("WHOA2 : %s", strerror(errno));
|
||||||
bytesRead = -1;
|
bytesRead = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -368,7 +368,7 @@ int json_createFromFile(const char *filePath, INOUT JSON_ref *jsonRef) {
|
|||||||
|
|
||||||
TEMP_FAILURE_RETRY(fd = open(filePath, O_RDONLY));
|
TEMP_FAILURE_RETRY(fd = open(filePath, O_RDONLY));
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
ERRLOG("Error opening file : %s", strerror(errno));
|
LOG("Error opening file : %s", strerror(errno));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,7 +418,7 @@ static bool _json_mapGetStringValue(const JSON_s *map, const char *key, INOUT in
|
|||||||
|
|
||||||
// should begin as map ...
|
// should begin as map ...
|
||||||
if (map->jsonTokens[idx].type != JSMN_OBJECT) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
++idx;
|
++idx;
|
||||||
@ -430,7 +430,7 @@ static bool _json_mapGetStringValue(const JSON_s *map, const char *key, INOUT in
|
|||||||
assert(keyTok.parent == 0);
|
assert(keyTok.parent == 0);
|
||||||
|
|
||||||
if (keyTok.type != JSMN_STRING) {
|
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;
|
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) {
|
if (map->jsonTokens[0].type != JSMN_OBJECT) {
|
||||||
ERRLOG("Map JSON : object not a map!");
|
LOG("Map JSON : object not a map!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -750,7 +750,7 @@ static bool _json_mapSetValue(const JSON_ref jsonRef, const char *key, const cha
|
|||||||
JSON_ref newRef = NULL;
|
JSON_ref newRef = NULL;
|
||||||
int errCount = json_createFromString(jsonString, &newRef);
|
int errCount = json_createFromString(jsonString, &newRef);
|
||||||
if (errCount < 0) {
|
if (errCount < 0) {
|
||||||
ERRLOG("Cannot set new JSON value err : %d", errCount);
|
LOG("Cannot set new JSON value err : %d", errCount);
|
||||||
} else {
|
} else {
|
||||||
JSON_s *newMap = (JSON_s *)newRef;
|
JSON_s *newMap = (JSON_s *)newRef;
|
||||||
FREE(map->jsonString);
|
FREE(map->jsonString);
|
||||||
|
@ -1148,10 +1148,10 @@ static int begin_cpu_stepping() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((err = pthread_cond_signal(&cpu_thread_cond))) {
|
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))) {
|
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)
|
#if defined(INTERFACE_CLASSIC)
|
||||||
@ -1168,7 +1168,7 @@ static int begin_cpu_stepping() {
|
|||||||
} while (!stepping_struct.should_break);
|
} while (!stepping_struct.should_break);
|
||||||
|
|
||||||
if ((err = pthread_cond_signal(&cpu_thread_cond))) {
|
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;
|
cpu_scale_factor = saved_scale;
|
||||||
@ -1185,7 +1185,7 @@ bool c_debugger_should_break() {
|
|||||||
|
|
||||||
if (pthread_self() != cpu_thread_id) {
|
if (pthread_self() != cpu_thread_id) {
|
||||||
// OOPS ...
|
// OOPS ...
|
||||||
ERRLOG("should only call this from cpu thread, bailing...");
|
LOG("should only call this from cpu thread, bailing...");
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1489,7 +1489,7 @@ void c_interface_debugging() {
|
|||||||
is_debugging = false;
|
is_debugging = false;
|
||||||
if ((err = pthread_cond_signal(&cpu_thread_cond)))
|
if ((err = pthread_cond_signal(&cpu_thread_cond)))
|
||||||
{
|
{
|
||||||
ERRLOG("pthread_cond_signal : %d", err);
|
LOG("pthread_cond_signal : %d", err);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ static int trace_pid = -1;
|
|||||||
static void _trace_init(void) {
|
static void _trace_init(void) {
|
||||||
TEMP_FAILURE_RETRY(trace_fd = open(TRACING_FILE, O_WRONLY));
|
TEMP_FAILURE_RETRY(trace_fd = open(TRACING_FILE, O_WRONLY));
|
||||||
if (trace_fd == -1) {
|
if (trace_fd == -1) {
|
||||||
ERRLOG("Could not open kernel trace file");
|
LOG("Could not open kernel trace file");
|
||||||
} else {
|
} else {
|
||||||
LOG("Initialized Linux tracing facility");
|
LOG("Initialized Linux tracing facility");
|
||||||
}
|
}
|
||||||
|
20
src/misc.c
20
src/misc.c
@ -55,7 +55,7 @@ static bool _save_state(int fd, const uint8_t * outbuf, ssize_t outmax) {
|
|||||||
ssize_t outlen = 0;
|
ssize_t outlen = 0;
|
||||||
do {
|
do {
|
||||||
if (TEMP_FAILURE_RETRY(outlen = write(fd, outbuf, outmax)) == -1) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
outbuf += outlen;
|
outbuf += outlen;
|
||||||
@ -72,13 +72,13 @@ static bool _load_state(int fd, uint8_t * inbuf, ssize_t inmax) {
|
|||||||
|
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
if (UNLIKELY(fstat(fd, &stat_buf) < 0)) {
|
if (UNLIKELY(fstat(fd, &stat_buf) < 0)) {
|
||||||
ERRLOG("OOPS, could not stat FD");
|
LOG("OOPS, could not stat FD");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
off_t fileSiz = stat_buf.st_size;
|
off_t fileSiz = stat_buf.st_size;
|
||||||
off_t filePos = lseek(fd, 0, SEEK_CUR);
|
off_t filePos = lseek(fd, 0, SEEK_CUR);
|
||||||
if (UNLIKELY(filePos < 0)) {
|
if (UNLIKELY(filePos < 0)) {
|
||||||
ERRLOG("OOPS, could not lseek FD");
|
LOG("OOPS, could not lseek FD");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,11 +89,11 @@ static bool _load_state(int fd, uint8_t * inbuf, ssize_t inmax) {
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
if (TEMP_FAILURE_RETRY(inlen = read(fd, inbuf, inmax)) == -1) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
if (inlen == 0) {
|
if (inlen == 0) {
|
||||||
ERRLOG("error reading emulator save-state file (truncated)");
|
LOG("error reading emulator save-state file (truncated)");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
inbuf += inlen;
|
inbuf += inlen;
|
||||||
@ -118,7 +118,7 @@ static int _load_magick(int fd) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ERRLOG("bad header magick in emulator save state file");
|
LOG("bad header magick in emulator save state file");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,12 +229,12 @@ bool emulator_loadState(int fd, int fdA, int fdB) {
|
|||||||
|
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
if (fstat(fd, &stat_buf) < 0) {
|
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 fileSiz = stat_buf.st_size;
|
||||||
off_t filePos = lseek(fd, 0, SEEK_CUR);
|
off_t filePos = lseek(fd, 0, SEEK_CUR);
|
||||||
if (filePos < 0) {
|
if (filePos < 0) {
|
||||||
ERRLOG("OOPS, could not lseek FD");
|
LOG("OOPS, could not lseek FD");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UNLIKELY(filePos != fileSiz)) {
|
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()
|
// Ensure that we leave the file descriptor ready for a call to emulator_loadState()
|
||||||
off_t ret = lseek(fd, 0, SEEK_SET);
|
off_t ret = lseek(fd, 0, SEEK_SET);
|
||||||
if (ret != 0) {
|
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 {
|
do {
|
||||||
DIR *dir = opendir("/proc/self/task");
|
DIR *dir = opendir("/proc/self/task");
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
ERRLOG("Cannot open /proc/self/task !");
|
LOG("Cannot open /proc/self/task !");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,24 +92,24 @@ bool prefs_save(void) {
|
|||||||
bool success = false;
|
bool success = false;
|
||||||
do {
|
do {
|
||||||
if (!prefsFile) {
|
if (!prefsFile) {
|
||||||
ERRLOG("Not saving preferences, no file loaded...");
|
LOG("Not saving preferences, no file loaded...");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!jsonPrefs) {
|
if (!jsonPrefs) {
|
||||||
ERRLOG("Not saving preferences, none loaded...");
|
LOG("Not saving preferences, none loaded...");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((JSON_s *)jsonPrefs)->numTokens <= 0) {
|
if (((JSON_s *)jsonPrefs)->numTokens <= 0) {
|
||||||
ERRLOG("Not saving preferences, no preferences loaded...");
|
LOG("Not saving preferences, no preferences loaded...");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(((JSON_s *)jsonPrefs)->jsonString && "string should be valid");
|
assert(((JSON_s *)jsonPrefs)->jsonString && "string should be valid");
|
||||||
|
|
||||||
#define PREFS_ERRPRINT() \
|
#define PREFS_ERRPRINT() \
|
||||||
ERRLOG( \
|
LOG( \
|
||||||
"Cannot open the .apple2.json preferences file for writing.\n" \
|
"Cannot open the .apple2.json preferences file for writing.\n" \
|
||||||
"Make sure it has R/W permission in your home directory.")
|
"Make sure it has R/W permission in your home directory.")
|
||||||
|
|
||||||
|
@ -371,10 +371,10 @@ cpu_runloop:
|
|||||||
if (c_debugger_should_break() || (debugging_cycles <= 0)) {
|
if (c_debugger_should_break() || (debugging_cycles <= 0)) {
|
||||||
int err = 0;
|
int err = 0;
|
||||||
if ((err = pthread_cond_signal(&dbg_thread_cond))) {
|
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))) {
|
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) {
|
if (debugging_cycles <= 0) {
|
||||||
break;
|
break;
|
||||||
@ -528,7 +528,7 @@ void timing_startCPU(void) {
|
|||||||
cpu_shutting_down = false;
|
cpu_shutting_down = false;
|
||||||
int err = TEMP_FAILURE_RETRY(pthread_create(&cpu_thread_id, NULL, (void *)&cpu_thread, (void *)NULL));
|
int err = TEMP_FAILURE_RETRY(pthread_create(&cpu_thread_id, NULL, (void *)&cpu_thread, (void *)NULL));
|
||||||
if (err) {
|
if (err) {
|
||||||
ERRLOG("pthread_create failed!");
|
LOG("pthread_create failed!");
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -538,7 +538,7 @@ void timing_stopCPU(void) {
|
|||||||
|
|
||||||
LOG("Emulator waiting for CPU thread clean up...");
|
LOG("Emulator waiting for CPU thread clean up...");
|
||||||
if (pthread_join(cpu_thread_id, NULL)) {
|
if (pthread_join(cpu_thread_id, NULL)) {
|
||||||
ERRLOG("OOPS: pthread_join of CPU thread ...");
|
LOG("OOPS: pthread_join of CPU thread ...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,13 +146,13 @@ static void *_azimuth_create_model(GLModel *parent) {
|
|||||||
|
|
||||||
vtxSource = glshader_createSource("SolidColor.vsh");
|
vtxSource = glshader_createSource("SolidColor.vsh");
|
||||||
if (!vtxSource) {
|
if (!vtxSource) {
|
||||||
ERRLOG("Cannot compile vertex shader for joystick azimuth!");
|
LOG("Cannot compile vertex shader for joystick azimuth!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
frgSource = glshader_createSource("SolidColor.fsh");
|
frgSource = glshader_createSource("SolidColor.fsh");
|
||||||
if (!frgSource) {
|
if (!frgSource) {
|
||||||
ERRLOG("Cannot compile fragment shader for joystick azimuth!");
|
LOG("Cannot compile fragment shader for joystick azimuth!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -727,21 +727,21 @@ static void _loadAltKbd(const char *kbdPath) {
|
|||||||
|
|
||||||
// begin with array
|
// begin with array
|
||||||
if (parsedData.jsonTokens[idx].type != JSMN_ARRAY) {
|
if (parsedData.jsonTokens[idx].type != JSMN_ARRAY) {
|
||||||
ERRLOG("Keyboard JSON must start with array");
|
LOG("Keyboard JSON must start with array");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++idx;
|
++idx;
|
||||||
|
|
||||||
// next is a global comment string
|
// next is a global comment string
|
||||||
if (parsedData.jsonTokens[idx].type != JSMN_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;
|
break;
|
||||||
}
|
}
|
||||||
++idx;
|
++idx;
|
||||||
|
|
||||||
// next is the dictionary of special strings
|
// next is the dictionary of special strings
|
||||||
if (parsedData.jsonTokens[idx].type != JSMN_OBJECT) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
const int dictCount = parsedData.jsonTokens[idx].size;
|
const int dictCount = parsedData.jsonTokens[idx].size;
|
||||||
@ -762,7 +762,7 @@ static void _loadAltKbd(const char *kbdPath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!allStrings) {
|
if (!allStrings) {
|
||||||
ERRLOG("Specials dictionary should only contain strings");
|
LOG("Specials dictionary should only contain strings");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,7 +771,7 @@ static void _loadAltKbd(const char *kbdPath) {
|
|||||||
while (idx < tokCount) {
|
while (idx < tokCount) {
|
||||||
if (row < 2) {
|
if (row < 2) {
|
||||||
if ( !((parsedData.jsonTokens[idx].type == JSMN_ARRAY) && (parsedData.jsonTokens[idx].parent == 0)) ) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
if (parsedData.jsonTokens[idx].size != KBD_TEMPLATE_COLS) {
|
if (parsedData.jsonTokens[idx].size != KBD_TEMPLATE_COLS) {
|
||||||
@ -786,7 +786,7 @@ static void _loadAltKbd(const char *kbdPath) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if ( !((parsedData.jsonTokens[idx].type == JSMN_ARRAY) && (parsedData.jsonTokens[idx].size == KBD_TEMPLATE_COLS) && (parsedData.jsonTokens[idx].parent == 0)) ) {
|
} 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -795,7 +795,7 @@ static void _loadAltKbd(const char *kbdPath) {
|
|||||||
for (int col=0; idx<count; col++, idx++) {
|
for (int col=0; idx<count; col++, idx++) {
|
||||||
|
|
||||||
if (parsedData.jsonTokens[idx].type != JSMN_STRING) {
|
if (parsedData.jsonTokens[idx].type != JSMN_STRING) {
|
||||||
ERRLOG("Unexpected non-string at keyboard row %d", row+1);
|
LOG("Unexpected non-string at keyboard row %d", row+1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -839,7 +839,7 @@ static void _loadAltKbd(const char *kbdPath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!foundMatch) {
|
if (!foundMatch) {
|
||||||
ERRLOG("no match for found multichar value in keyboard row %d", row+1);
|
LOG("no match for found multichar value in keyboard row %d", row+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -851,7 +851,7 @@ static void _loadAltKbd(const char *kbdPath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (row != KBD_TEMPLATE_ROWS) {
|
if (row != KBD_TEMPLATE_ROWS) {
|
||||||
ERRLOG("Did not find expected number of keyboard rows");
|
LOG("Did not find expected number of keyboard rows");
|
||||||
} else {
|
} else {
|
||||||
LOG("Parsed keyboard at %s", kbdPath);
|
LOG("Parsed keyboard at %s", kbdPath);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ static void _glvideo_setup_hackarounds(void) {
|
|||||||
if (vendor && renderer && version) {
|
if (vendor && renderer && version) {
|
||||||
LOG("GL_VENDOR:[%s] GL_RENDERER:[%s] GL_VERSION:[%s]", vendor, renderer, version);
|
LOG("GL_VENDOR:[%s] GL_RENDERER:[%s] GL_VERSION:[%s]", vendor, renderer, version);
|
||||||
} else {
|
} else {
|
||||||
ERRLOG("One or more of GL_VENDOR, GL_RENDERER, and GL_VERSION is NULL ... this is bad ...");
|
LOG("One or more of GL_VENDOR, GL_RENDERER, and GL_VERSION is NULL ... this is bad ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ static void glvideo_init(void) {
|
|||||||
|
|
||||||
if (maxTextureUnits < TEXTURE_ID_MAX) {
|
if (maxTextureUnits < TEXTURE_ID_MAX) {
|
||||||
#warning FIXME TODO ... gracefully handle devices with low max texture units?
|
#warning FIXME TODO ... gracefully handle devices with low max texture units?
|
||||||
ERRLOG("OOPS ... MAX TEXTURE UNITS : %d (<%d)", maxTextureUnits, TEXTURE_ID_MAX);
|
LOG("OOPS ... MAX TEXTURE UNITS : %d (<%d)", maxTextureUnits, TEXTURE_ID_MAX);
|
||||||
} else {
|
} else {
|
||||||
LOG("GL_MAX_TEXTURE_IMAGE_UNITS : %d", maxTextureUnits);
|
LOG("GL_MAX_TEXTURE_IMAGE_UNITS : %d", maxTextureUnits);
|
||||||
}
|
}
|
||||||
|
@ -551,7 +551,7 @@ GLModel *mdlCreateQuad(GLModelParams_s parms, GLCustom clazz) {
|
|||||||
return model;
|
return model;
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
ERRLOG("error in quad creation");
|
LOG("error in quad creation");
|
||||||
if (model) {
|
if (model) {
|
||||||
mdlDestroyModel(&model);
|
mdlDestroyModel(&model);
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ demoSource *glshader_createSource(const char *fileName) {
|
|||||||
src = srcLoadSource(filePath);
|
src = srcLoadSource(filePath);
|
||||||
FREE(filePath);
|
FREE(filePath);
|
||||||
} else {
|
} else {
|
||||||
ERRLOG("OOPS Could not load shader from %s (%s)", filePath, fileName);
|
LOG("OOPS Could not load shader from %s (%s)", filePath, fileName);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return src;
|
return src;
|
||||||
|
@ -39,10 +39,10 @@ static int _gzread_data(gzFile gzsource, uint8_t *buf, const int expected_bytesc
|
|||||||
int bytesread = gzread(gzsource, buf+bytescount, expected_bytescount-bytescount);
|
int bytesread = gzread(gzsource, buf+bytescount, expected_bytescount-bytescount);
|
||||||
if (bytesread <= 0) {
|
if (bytesread <= 0) {
|
||||||
if (--maxtries == 0) {
|
if (--maxtries == 0) {
|
||||||
ERRLOG("OOPS, giving up on gzread() ...");
|
LOG("OOPS, giving up on gzread() ...");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ERRLOG("OOPS, gzread() ...");
|
LOG("OOPS, gzread() ...");
|
||||||
usleep(100);
|
usleep(100);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -67,10 +67,10 @@ static int _read_data(int fd_own, uint8_t *buf, const int expected_bytescount) {
|
|||||||
TEMP_FAILURE_RETRY(bytesread = read(fd_own, buf+bytescount, expected_bytescount-bytescount));
|
TEMP_FAILURE_RETRY(bytesread = read(fd_own, buf+bytescount, expected_bytescount-bytescount));
|
||||||
if (bytesread <= 0) {
|
if (bytesread <= 0) {
|
||||||
if (--maxtries == 0) {
|
if (--maxtries == 0) {
|
||||||
ERRLOG("OOPS, giving up on read() ...");
|
LOG("OOPS, giving up on read() ...");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ERRLOG("OOPS, read() ...");
|
LOG("OOPS, read() ...");
|
||||||
usleep(100);
|
usleep(100);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -97,10 +97,10 @@ static int _write_data(int fd_own, uint8_t *buf, const int expected_bytescount)
|
|||||||
|
|
||||||
if (byteswritten <= 0) {
|
if (byteswritten <= 0) {
|
||||||
if (--maxtries == 0) {
|
if (--maxtries == 0) {
|
||||||
ERRLOG("OOPS, giving up on write() ...");
|
LOG("OOPS, giving up on write() ...");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ERRLOG("OOPS, write ...");
|
LOG("OOPS, write ...");
|
||||||
usleep(100);
|
usleep(100);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -124,13 +124,13 @@ static a2gzip_t _check_gzip_magick(int fd_own, const int expected_bytescount) {
|
|||||||
uint8_t stkbuf[2];
|
uint8_t stkbuf[2];
|
||||||
int bytescount = _read_data(fd_own, &stkbuf[0], sizeof(stkbuf));
|
int bytescount = _read_data(fd_own, &stkbuf[0], sizeof(stkbuf));
|
||||||
if (bytescount != sizeof(stkbuf)) {
|
if (bytescount != sizeof(stkbuf)) {
|
||||||
ERRLOG("OOPS, could not read file magick for file descriptor");
|
LOG("OOPS, could not read file magick for file descriptor");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bytescount = lseek(fd_own, 0L, SEEK_END);
|
bytescount = lseek(fd_own, 0L, SEEK_END);
|
||||||
if (bytescount == -1) {
|
if (bytescount == -1) {
|
||||||
ERRLOG("OOPS, cannot seek to end of file descriptor!");
|
LOG("OOPS, cannot seek to end of file descriptor!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ const char *zlib_inflate_to_buffer(int fd, const int expected_bytescount, uint8_
|
|||||||
|
|
||||||
TEMP_FAILURE_RETRY(fd_own = dup(fd)); // balance gzclose() behavior
|
TEMP_FAILURE_RETRY(fd_own = dup(fd)); // balance gzclose() behavior
|
||||||
if (fd_own == -1) {
|
if (fd_own == -1) {
|
||||||
ERRLOG("OOPS, could not dup() file descriptor %d", fd);
|
LOG("OOPS, could not dup() file descriptor %d", fd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fd = -1;
|
fd = -1;
|
||||||
@ -183,7 +183,7 @@ const char *zlib_inflate_to_buffer(int fd, const int expected_bytescount, uint8_
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lseek(fd_own, 0L, SEEK_SET) == -1) {
|
if (lseek(fd_own, 0L, SEEK_SET) == -1) {
|
||||||
ERRLOG("OOPS, cannot seek to start of file descriptor!");
|
LOG("OOPS, cannot seek to start of file descriptor!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,17 +197,17 @@ const char *zlib_inflate_to_buffer(int fd, const int expected_bytescount, uint8_
|
|||||||
|
|
||||||
gzsource = gzdopen(fd_own, "r");
|
gzsource = gzdopen(fd_own, "r");
|
||||||
if (gzsource == NULL) {
|
if (gzsource == NULL) {
|
||||||
ERRLOG("OOPS, cannot open file descriptor for reading");
|
LOG("OOPS, cannot open file descriptor for reading");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bytescount = _gzread_data(gzsource, buf, expected_bytescount);
|
bytescount = _gzread_data(gzsource, buf, expected_bytescount);
|
||||||
if (bytescount != expected_bytescount) {
|
if (bytescount != expected_bytescount) {
|
||||||
// could not gzread(), maybe it's not actually a gzip stream? ...
|
// could not gzread(), maybe it's not actually a gzip stream? ...
|
||||||
ERRLOG("OOPS, did not gzread() expected_bytescount of %d ... apparently read %d ... checking file length heuristic ...", expected_bytescount, bytescount);
|
LOG("OOPS, did not gzread() expected_bytescount of %d ... apparently read %d ... checking file length heuristic ...", expected_bytescount, bytescount);
|
||||||
|
|
||||||
if (lseek(fd_own, 0L, SEEK_SET) == -1) {
|
if (lseek(fd_own, 0L, SEEK_SET) == -1) {
|
||||||
ERRLOG("OOPS, cannot seek to start of file descriptor!");
|
LOG("OOPS, cannot seek to start of file descriptor!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ const char *zlib_inflate_to_buffer(int fd, const int expected_bytescount, uint8_
|
|||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
if (bytescount != expected_bytescount) {
|
if (bytescount != expected_bytescount) {
|
||||||
ERRLOG("OOPS did not read expected_bytescount of %d ... apparently read %d", expected_bytescount, bytescount);
|
LOG("OOPS did not read expected_bytescount of %d ... apparently read %d", expected_bytescount, bytescount);
|
||||||
if (gzsource) {
|
if (gzsource) {
|
||||||
err = (char *)_gzerr(gzsource);
|
err = (char *)_gzerr(gzsource);
|
||||||
}
|
}
|
||||||
@ -265,7 +265,7 @@ const char *zlib_inflate_inplace(int fd, const int expected_bytescount, bool *is
|
|||||||
|
|
||||||
TEMP_FAILURE_RETRY(fd_own = dup(fd)); // balance gzclose()
|
TEMP_FAILURE_RETRY(fd_own = dup(fd)); // balance gzclose()
|
||||||
if (fd_own == -1) {
|
if (fd_own == -1) {
|
||||||
ERRLOG("OOPS, could not dup() file descriptor %d", fd);
|
LOG("OOPS, could not dup() file descriptor %d", fd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fd = -1;
|
fd = -1;
|
||||||
@ -284,29 +284,29 @@ const char *zlib_inflate_inplace(int fd, const int expected_bytescount, bool *is
|
|||||||
|
|
||||||
buf = MALLOC(expected_bytescount);
|
buf = MALLOC(expected_bytescount);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
ERRLOG("OOPS, failed allocation of %d bytes", expected_bytescount);
|
LOG("OOPS, failed allocation of %d bytes", expected_bytescount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lseek(fd_own, 0L, SEEK_SET) == -1) {
|
if (lseek(fd_own, 0L, SEEK_SET) == -1) {
|
||||||
ERRLOG("OOPS, cannot seek to start of file descriptor!");
|
LOG("OOPS, cannot seek to start of file descriptor!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gzsource = gzdopen(fd_own, "r");
|
gzsource = gzdopen(fd_own, "r");
|
||||||
if (gzsource == NULL) {
|
if (gzsource == NULL) {
|
||||||
ERRLOG("OOPS, cannot open file file descriptor for reading");
|
LOG("OOPS, cannot open file file descriptor for reading");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bytescount = _gzread_data(gzsource, buf, expected_bytescount);
|
bytescount = _gzread_data(gzsource, buf, expected_bytescount);
|
||||||
if (bytescount != expected_bytescount) {
|
if (bytescount != expected_bytescount) {
|
||||||
// could not gzread(), maybe it's not actually a gzip stream? ...
|
// could not gzread(), maybe it's not actually a gzip stream? ...
|
||||||
ERRLOG("OOPS, did not in-place gzread() expected_bytescount of %d ... apparently read %d ... checking file length heuristic ...", expected_bytescount, bytescount);
|
LOG("OOPS, did not in-place gzread() expected_bytescount of %d ... apparently read %d ... checking file length heuristic ...", expected_bytescount, bytescount);
|
||||||
|
|
||||||
bytescount = lseek(fd_own, 0L, SEEK_END);
|
bytescount = lseek(fd_own, 0L, SEEK_END);
|
||||||
if (bytescount == -1) {
|
if (bytescount == -1) {
|
||||||
ERRLOG("OOPS, cannot seek to end of file descriptor!");
|
LOG("OOPS, cannot seek to end of file descriptor!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ const char *zlib_inflate_inplace(int fd, const int expected_bytescount, bool *is
|
|||||||
// inplace write file
|
// inplace write file
|
||||||
|
|
||||||
if (lseek(fd_own, 0L, SEEK_SET) == -1) {
|
if (lseek(fd_own, 0L, SEEK_SET) == -1) {
|
||||||
ERRLOG("OOPS, cannot seek to start of file descriptor!");
|
LOG("OOPS, cannot seek to start of file descriptor!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ const char *zlib_inflate_inplace(int fd, const int expected_bytescount, bool *is
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
TEMP_FAILURE_RETRY(ret = ftruncate(fd_own, expected_bytescount));
|
TEMP_FAILURE_RETRY(ret = ftruncate(fd_own, expected_bytescount));
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
ERRLOG("OOPS, ftruncate file descriptor failed");
|
LOG("OOPS, ftruncate file descriptor failed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,7 +345,7 @@ const char *zlib_inflate_inplace(int fd, const int expected_bytescount, bool *is
|
|||||||
|
|
||||||
char *err = NULL;
|
char *err = NULL;
|
||||||
if (bytescount != expected_bytescount) {
|
if (bytescount != expected_bytescount) {
|
||||||
ERRLOG("OOPS, did not write expected_bytescount of %d ... apparently wrote %d", expected_bytescount, bytescount);
|
LOG("OOPS, did not write expected_bytescount of %d ... apparently wrote %d", expected_bytescount, bytescount);
|
||||||
if (gzsource) {
|
if (gzsource) {
|
||||||
err = (char *)_gzerr(gzsource);
|
err = (char *)_gzerr(gzsource);
|
||||||
}
|
}
|
||||||
@ -392,20 +392,20 @@ const char *zlib_deflate_buffer(const uint8_t *src, const int src_bytescount, ui
|
|||||||
|
|
||||||
TEMP_FAILURE_RETRY(fd_own = open(gzPath, O_RDWR|O_CREAT|O_TRUNC));
|
TEMP_FAILURE_RETRY(fd_own = open(gzPath, O_RDWR|O_CREAT|O_TRUNC));
|
||||||
if (fd_own == -1) {
|
if (fd_own == -1) {
|
||||||
ERRLOG("OOPS could not open temp image path : %s", gzPath);
|
LOG("OOPS could not open temp image path : %s", gzPath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gzdest = gzdopen(fd_own, "w");
|
gzdest = gzdopen(fd_own, "w");
|
||||||
if (gzdest == NULL) {
|
if (gzdest == NULL) {
|
||||||
ERRLOG("OOPS, cannot open file descriptor for writing");
|
LOG("OOPS, cannot open file descriptor for writing");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
int byteswritten = gzwrite(gzdest, src+bytescount, expected_bytescount-bytescount);
|
int byteswritten = gzwrite(gzdest, src+bytescount, expected_bytescount-bytescount);
|
||||||
if (byteswritten <= 0) {
|
if (byteswritten <= 0) {
|
||||||
ERRLOG("OOPS, gzwrite() returned %d", byteswritten);
|
LOG("OOPS, gzwrite() returned %d", byteswritten);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,7 +423,7 @@ const char *zlib_deflate_buffer(const uint8_t *src, const int src_bytescount, ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gzflush(gzdest, Z_FINISH) != Z_OK) {
|
if (gzflush(gzdest, Z_FINISH) != Z_OK) {
|
||||||
ERRLOG("Error flushing compressed output : %s", err);
|
LOG("Error flushing compressed output : %s", err);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,7 +436,7 @@ const char *zlib_deflate_buffer(const uint8_t *src, const int src_bytescount, ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lseek(fd_own, 0L, SEEK_SET) == -1) {
|
if (lseek(fd_own, 0L, SEEK_SET) == -1) {
|
||||||
ERRLOG("OOPS, cannot seek to start of file descriptor!");
|
LOG("OOPS, cannot seek to start of file descriptor!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,7 +450,7 @@ const char *zlib_deflate_buffer(const uint8_t *src, const int src_bytescount, ui
|
|||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
if (bytescount != expected_bytescount) {
|
if (bytescount != expected_bytescount) {
|
||||||
ERRLOG("OOPS, did not write/read expected number of bytes of %d ... apparently wrote %d", expected_bytescount, bytescount);
|
LOG("OOPS, did not write/read expected number of bytes of %d ... apparently wrote %d", expected_bytescount, bytescount);
|
||||||
if (gzdest) {
|
if (gzdest) {
|
||||||
err = (char *)_gzerr(gzdest);
|
err = (char *)_gzerr(gzdest);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user