summaryrefslogtreecommitdiff
path: root/macosx/main.m
diff options
context:
space:
mode:
authorSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-07-10 00:04:59 +0000
committerSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-07-10 00:04:59 +0000
commit09b52df12a0dc938bdd9b4c2d36a1d13af88ca50 (patch)
treef83efe15234716a8bf0afba10334bf5d7d4143f2 /macosx/main.m
parent0fd6f9301c3d3d568fb58251bb1c38da576701a2 (diff)
downloadpcsxr-09b52df12a0dc938bdd9b4c2d36a1d13af88ca50.tar.gz
minor code tweaks.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@85949 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/main.m')
-rwxr-xr-xmacosx/main.m35
1 files changed, 27 insertions, 8 deletions
diff --git a/macosx/main.m b/macosx/main.m
index 537dfc18..614978cf 100755
--- a/macosx/main.m
+++ b/macosx/main.m
@@ -110,7 +110,7 @@ int SysInit() {
IOReturn success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR("PSX Emu Running"), &powerAssertion);
if (success != kIOReturnSuccess) {
- SysPrintf("Unable to stop sleep, error code %d", success);
+ SysPrintf("Unable to stop sleep, error code %d\n", success);
}
attachHotkeys();
@@ -139,24 +139,34 @@ static NSDateFormatter* debugDateFormatter()
void SysPrintf(const char *fmt, ...) {
va_list list;
- char msg[512];
+ char *msg = calloc(sizeof(char), 512);
va_start(list, fmt);
- vsprintf(msg, fmt, list);
+ vsnprintf(msg, 512, fmt, list);
va_end(list);
- if (Config.PsxOut) printf ("%s", msg);
+
+ dispatch_block_t printfBlock = ^{
+ if (Config.PsxOut) printf ("%s", msg);
#ifdef EMU_LOG
#ifndef LOG_STDOUT
- fprintf(emuLog, "%s %s: %s",[[debugDateFormatter() stringFromDate:[NSDate date]] UTF8String],
- [[[NSBundle mainBundle]objectForInfoDictionaryKey:@"CFBundleName"] UTF8String], msg);
+ fprintf(emuLog, "%s %s: %s",[[debugDateFormatter() stringFromDate:[NSDate date]] UTF8String],
+ [[[NSBundle mainBundle]objectForInfoDictionaryKey:@"CFBundleName"] UTF8String], msg);
#endif
#endif
+ };
+ if ([NSThread isMainThread]) {
+ printfBlock();
+ } else {
+ dispatch_sync(dispatch_get_main_queue(), printfBlock);
+ }
+ free(msg);
}
void SysMessage(const char *fmt, ...) {
va_list list;
+
NSString *locFmtString = NSLocalizedString(@(fmt), nil);
va_start(list, fmt);
@@ -165,7 +175,10 @@ void SysMessage(const char *fmt, ...) {
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:msg forKey:NSLocalizedFailureReasonErrorKey];
RELEASEOBJ(msg);
- dispatch_sync(dispatch_get_main_queue(), ^{
+
+
+ dispatch_block_t sysBlock = ^{
+ if (Config.PsxOut) printf ("%s", [msg UTF8String]);
#ifdef EMU_LOG
#ifndef LOG_STDOUT
fprintf(emuLog, "%s %s: %s",[[debugDateFormatter() stringFromDate:[NSDate date]] UTF8String],
@@ -173,7 +186,13 @@ void SysMessage(const char *fmt, ...) {
#endif
#endif
[NSApp presentError:[NSError errorWithDomain:@"Unknown Domain" code:-1 userInfo:userInfo]];
- });
+ };
+
+ if ([NSThread isMainThread]) {
+ sysBlock();
+ } else {
+ dispatch_sync(dispatch_get_main_queue(), sysBlock);
+ }
}
void *SysLoadLibrary(const char *lib) {