Some cleanups

This commit is contained in:
twinaphex 2015-01-09 02:12:08 +01:00
parent 41b5ae5dd6
commit 3521bfadd9
2 changed files with 16 additions and 8 deletions

View File

@ -49,6 +49,7 @@ size_t fifo_read_avail(fifo_buffer_t *buffer)
{ {
size_t first = buffer->first; size_t first = buffer->first;
size_t end = buffer->end; size_t end = buffer->end;
if (end < first) if (end < first)
end += buffer->bufsize; end += buffer->bufsize;
return end - first; return end - first;
@ -58,6 +59,7 @@ size_t fifo_write_avail(fifo_buffer_t *buffer)
{ {
size_t first = buffer->first; size_t first = buffer->first;
size_t end = buffer->end; size_t end = buffer->end;
if (end < first) if (end < first)
end += buffer->bufsize; end += buffer->bufsize;
@ -86,6 +88,7 @@ void fifo_read(fifo_buffer_t *buffer, void *in_buf, size_t size)
{ {
size_t first_read = size; size_t first_read = size;
size_t rest_read = 0; size_t rest_read = 0;
if (buffer->first + size > buffer->bufsize) if (buffer->first + size > buffer->bufsize)
{ {
first_read = buffer->bufsize - buffer->first; first_read = buffer->bufsize - buffer->first;

View File

@ -105,7 +105,8 @@ static void do_iteration(void)
void apple_start_iteration(void) void apple_start_iteration(void)
{ {
if (iterate_observer == NULL) { if (iterate_observer == NULL)
{
iterate_observer = iterate_observer =
CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting, CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting,
true, 0, (CFRunLoopObserverCallBack)do_iteration, 0); true, 0, (CFRunLoopObserverCallBack)do_iteration, 0);
@ -116,7 +117,8 @@ void apple_start_iteration(void)
void apple_stop_iteration(void) void apple_stop_iteration(void)
{ {
if (iterate_observer != NULL) { if (iterate_observer != NULL)
{
CFRunLoopObserverInvalidate(iterate_observer); CFRunLoopObserverInvalidate(iterate_observer);
CFRelease(iterate_observer); CFRelease(iterate_observer);
iterate_observer = NULL; iterate_observer = NULL;
@ -126,14 +128,17 @@ void apple_stop_iteration(void)
static void frontend_apple_get_environment_settings(int *argc, char *argv[], static void frontend_apple_get_environment_settings(int *argc, char *argv[],
void *args, void *params_data) void *args, void *params_data)
{ {
char bundle_path_buf[PATH_MAX + 1], home_dir_buf[PATH_MAX + 1],
char bundle_path_buf[PATH_MAX + 1], home_dir_buf[PATH_MAX + 1]; support_path_buf[PATH_MAX + 1];
CFURLRef bundle_url; CFURLRef bundle_url;
CFStringRef bundle_path;
CFBundleRef bundle = CFBundleGetMainBundle(); CFBundleRef bundle = CFBundleGetMainBundle();
if (!bundle) if (!bundle)
return; return;
bundle_url = CFBundleCopyBundleURL(bundle);
CFStringRef bundle_path = CFURLCopyPath(bundle_url); bundle_url = CFBundleCopyBundleURL(bundle);
bundle_path = CFURLCopyPath(bundle_url);
CFStringGetCString(bundle_path, bundle_path_buf, sizeof(bundle_path_buf), kCFStringEncodingUTF8); CFStringGetCString(bundle_path, bundle_path_buf, sizeof(bundle_path_buf), kCFStringEncodingUTF8);
(void)home_dir_buf; (void)home_dir_buf;
@ -162,7 +167,6 @@ static void frontend_apple_get_environment_settings(int *argc, char *argv[],
RARCH_ERR("Failed to create or access system directory: %s.\n", g_defaults.system_dir); RARCH_ERR("Failed to create or access system directory: %s.\n", g_defaults.system_dir);
} }
#elif defined(OSX) #elif defined(OSX)
char support_path_buf[PATH_MAX + 1];
CFSearchPathForDirectoriesInDomains(CFApplicationSupportDirectory, CFUserDomainMask, 1, support_path_buf, sizeof(support_path_buf)); CFSearchPathForDirectoriesInDomains(CFApplicationSupportDirectory, CFUserDomainMask, 1, support_path_buf, sizeof(support_path_buf));
fill_pathname_join(g_defaults.core_dir, bundle_path_buf, "Contents/Resources/modules", sizeof(g_defaults.core_dir)); fill_pathname_join(g_defaults.core_dir, bundle_path_buf, "Contents/Resources/modules", sizeof(g_defaults.core_dir));
@ -189,7 +193,8 @@ static void frontend_apple_load_content(void)
if ( driver.menu_ctx && driver.menu_ctx == &menu_ctx_ios && driver.menu && driver.menu->userdata ) if ( driver.menu_ctx && driver.menu_ctx == &menu_ctx_ios && driver.menu && driver.menu->userdata )
{ {
ios_handle_t *ih = (ios_handle_t*)driver.menu->userdata; ios_handle_t *ih = (ios_handle_t*)driver.menu->userdata;
ih->notify_content_loaded(); if (ih)
ih->notify_content_loaded();
} }
#endif #endif
} }