diff --git a/configure.osx b/configure.osx
index 811c160fc0..b52da655ff 100755
--- a/configure.osx
+++ b/configure.osx
@@ -39,7 +39,7 @@ enable glw
enable glw_frontend_cocoa
enable glw_backend_opengl
enable coreaudio
-enable appleremote
+#enable appleremote
enable bonjour
enable spotlight
enable spidermonkey
diff --git a/src/arch/osx/osx_main.c b/src/arch/osx/osx_main.c
new file mode 100644
index 0000000000..13b614d7ac
--- /dev/null
+++ b/src/arch/osx/osx_main.c
@@ -0,0 +1,92 @@
+/*
+ * Showtime mediacenter
+ * Copyright (C) 2007-2012 Andreas Ă–man
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+
+#include
+#include
+
+#include "showtime.h"
+#include "arch/arch.h"
+#include "arch/darwin.h"
+#include "arch/posix/posix.h"
+
+
+static int get_system_concurrency(void);
+
+
+
+/**
+ * OSX main
+ */
+int
+main(int argc, char **argv)
+{
+ gconf.binary = argv[0];
+
+ posix_init();
+
+ parse_opts(argc, argv);
+
+ gconf.concurrency = get_system_concurrency();
+
+ showtime_init();
+
+ darwin_init_cpu_monitor();
+
+ extern void glw_cocoa_start(void);
+ glw_cocoa_start();
+
+ showtime_fini();
+
+ arch_exit();
+}
+
+
+/**
+ *
+ */
+void
+arch_exit(void)
+{
+ exit(gconf.exit_code);
+}
+
+
+const char *
+showtime_get_system_type(void)
+{
+ return "Apple";
+}
+
+
+
+static int
+get_system_concurrency(void)
+{
+ int mib[2];
+ int ncpu;
+ size_t len;
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_NCPU;
+ len = sizeof(ncpu);
+ sysctl(mib, 2, &ncpu, &len, NULL, 0);
+
+ return ncpu;
+}
+
diff --git a/src/arch/posix/posix.c b/src/arch/posix/posix.c
index a46d3e6e7d..b3e4acbf5b 100644
--- a/src/arch/posix/posix.c
+++ b/src/arch/posix/posix.c
@@ -32,31 +32,6 @@ const char *showtime_get_system_type(void);
#elif defined(__APPLE__)
-const char *
-showtime_get_system_type(void)
-{
- return "Apple";
-}
-
-#include
-#include
-#include "darwin.h"
-
-static int
-get_system_concurrency(void)
-{
- int mib[2];
- int ncpu;
- size_t len;
-
- mib[0] = CTL_HW;
- mib[1] = HW_NCPU;
- len = sizeof(ncpu);
- sysctl(mib, 2, &ncpu, &len, NULL, 0);
-
- return ncpu;
-
-}
#else
diff --git a/src/arch/threads.h b/src/arch/threads.h
index b1c431171c..c40cade007 100644
--- a/src/arch/threads.h
+++ b/src/arch/threads.h
@@ -20,7 +20,7 @@
#include "config.h"
-#ifdef linux
+#if defined(linux) || defined(__APPLE__)
#include "posix/posix_threads.h"
#elif PS3
#include "ps3/ps3_threads.h"
diff --git a/src/fileaccess/fa_spotlight.c b/src/fileaccess/fa_spotlight.c
index b33f28f516..ac0d2f689a 100644
--- a/src/fileaccess/fa_spotlight.c
+++ b/src/fileaccess/fa_spotlight.c
@@ -194,7 +194,7 @@ spotlight_searcher(void *aux)
path = malloc(len);
CFStringGetCString(pathRef, path, len, kCFStringEncodingUTF8);
CFRelease(pathRef);
- metadata_t *md = fa_probe_metadata(path, NULL, 0);
+ metadata_t *md = fa_probe_metadata(path, NULL, 0, NULL);
if(md == NULL)
continue;
diff --git a/src/ui/glw/glw_cocoa.m b/src/ui/glw/glw_cocoa.m
index eacb26c6ef..6336777059 100644
--- a/src/ui/glw/glw_cocoa.m
+++ b/src/ui/glw/glw_cocoa.m
@@ -46,11 +46,6 @@
typedef struct glw_cocoa {
glw_root_t gr;
- /* used to pass args from glw_cocoa_start to prepareOpenGL */
- ui_t *start_ui;
- int start_primary;
- const char *theme_path;
-
int glready; /* prepareOpenGL has been run */
int is_fullscreen;
@@ -130,7 +125,6 @@
static void glw_cocoa_set_fullscreen(void *opaque, int value);
static void glw_cocoa_in_fullwindow(void *opaque, int v);
-static void glw_cocoa_dispatch_event(uii_t *uii, event_t *e);
@implementation GLWGLView
@@ -147,18 +141,16 @@ - (void)windowWillClose:(NSNotification *)aNotification {
- (IBAction)clickIncreaseZoom:(id)sender {
- glw_cocoa_dispatch_event(&gcocoa.gr.gr_uii,
- event_create_action(ACTION_ZOOM_UI_INCR));
+ event_to_ui(event_create_action(ACTION_ZOOM_UI_INCR));
+
}
- (IBAction)clickDecreaseZoom:(id)sender {
- glw_cocoa_dispatch_event(&gcocoa.gr.gr_uii,
- event_create_action(ACTION_ZOOM_UI_DECR));
+ event_to_ui(event_create_action(ACTION_ZOOM_UI_DECR));
}
- (IBAction)clickFullscreen:(id)sender {
- glw_cocoa_dispatch_event(&gcocoa.gr.gr_uii,
- event_create_action(ACTION_FULLSCREEN_TOGGLE));
+ event_to_ui(event_create_action(ACTION_FULLSCREEN_TOGGLE));
}
- (IBAction)clickAbout:(id)sender {
@@ -523,7 +515,7 @@ - (void)glwEventFromMouseEvent:(NSEvent *)event {
if([event type] == NSOtherMouseUp) {
event_t *e = event_create_action(ACTION_MENU);
- glw_cocoa_dispatch_event(&gcocoa.gr.gr_uii, e);
+ event_to_ui(e);
}
}
@@ -654,7 +646,7 @@ - (void)insertText:(id)aString {
NSString *su = [[NSString alloc] initWithCharacters:&uc length:1];
event_t *e = NULL;
e = event_create_int(EVENT_UNICODE, uc);
- glw_cocoa_dispatch_event(&gcocoa.gr.gr_uii, e);
+ event_to_ui(e);
[su release];
}
}
@@ -709,8 +701,8 @@ - (void)keyDown:(NSEvent *)event {
if(e == NULL)
e = event_create_int(EVENT_UNICODE, c);
-
- glw_cocoa_dispatch_event(&gcocoa.gr.gr_uii, e);
+
+ event_to_ui(e);
}
- (void)reshape {
@@ -723,10 +715,10 @@ - (void)prepareOpenGL {
timer_cursor = nil;
+ gcocoa.gr.gr_prop = prop_create(prop_get_global(), "ui");
+
/* must be called after GL is ready, calls GL functions */
- if(glw_init(&gcocoa.gr, gcocoa.theme_path,
- gcocoa.start_ui, gcocoa.start_primary,
- "glw/cocoa/default", NULL))
+ if(glw_init(&gcocoa.gr, gconf.theme, "glw/cocoa/default"))
return;
gcocoa.fullscreen_setting =
@@ -739,7 +731,7 @@ - (void)prepareOpenGL {
prop_subscribe(0,
PROP_TAG_NAME("ui","fullwindow"),
PROP_TAG_CALLBACK_INT, glw_cocoa_in_fullwindow, self,
- PROP_TAG_ROOT, gcocoa.gr.gr_uii.uii_prop,
+ PROP_TAG_ROOT, gcocoa.gr.gr_prop,
NULL);
glw_load_universe(&gcocoa.gr);
@@ -816,30 +808,12 @@ - (void)drawRect:(NSRect)rect {
UpdateSystemActivity(OverallAct);
}
-static int
-glw_cocoa_start(ui_t *ui, prop_t *root, int argc, char *argv[], int primary)
-{
- gcocoa.start_ui = ui;
- gcocoa.start_primary = primary;
- gcocoa.gr.gr_uii.uii_prop = root;
-
- /* Parse options */
-
- argv++;
- argc--;
-
- while(argc > 0) {
- if(!strcmp(argv[0], "--theme") && argc > 1) {
- gcocoa.theme_path = argv[1];
- argc -= 2; argv += 2;
-
- continue;
- } else {
- break;
- }
- }
+void glw_cocoa_start(void);
+void
+glw_cocoa_start(void)
+{
CFRunLoopTimerRef timer;
CFRunLoopTimerContext context = { 0, NULL, NULL, NULL, NULL };
@@ -848,27 +822,4 @@ - (void)drawRect:(NSRect)rect {
CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopCommonModes);
NSApplicationMain(0, NULL);
-
- return 0;
-}
-
-static void
-glw_cocoa_dispatch_event(uii_t *uii, event_t *e)
-{
- glw_cocoa_t *gc = (glw_cocoa_t *)uii;
-
- if(event_is_action(e, ACTION_FULLSCREEN_TOGGLE)) {
- settings_toggle_bool(gc->fullscreen_setting);
- } else {
- glw_dispatch_event(uii, e);
- }
- event_release(e);
}
-
-ui_t glw_ui = {
- .ui_title = "glw",
- .ui_start = glw_cocoa_start,
- .ui_dispatch_event = glw_cocoa_dispatch_event,
- /* NSApplicationMain must run in main thread */
- .ui_flags = UI_MAINTHREAD,
-};
diff --git a/src/video/vda.c b/src/video/vda.c
index de831181d2..a06a6fcf41 100644
--- a/src/video/vda.c
+++ b/src/video/vda.c
@@ -21,7 +21,7 @@ typedef struct vda_frame {
int64_t vf_pts;
int vf_duration;
uint8_t vf_epoch;
- uint8_t vf_send_pts;
+ uint8_t vf_drive_clock;
} vda_frame_t;
@@ -86,27 +86,27 @@ emit_frame(vda_decoder_t *vdad, vda_frame_t *vf)
memset(&fi, 0, sizeof(fi));
siz = CVImageBufferGetEncodedSize(vf->vf_buf);
- fi.width = siz.width;
- fi.height = siz.height;
+ fi.fi_width = siz.width;
+ fi.fi_height = siz.height;
- fi.duration = vf->vf_duration > 10000 ? vf->vf_duration : vdad->vdad_estimated_duration;
+ fi.fi_duration = vf->vf_duration > 10000 ? vf->vf_duration : vdad->vdad_estimated_duration;
siz = CVImageBufferGetDisplaySize(vf->vf_buf);
- fi.dar.num = siz.width;
- fi.dar.den = siz.height;
+ fi.fi_dar.num = siz.width;
+ fi.fi_dar.den = siz.height;
- fi.pix_fmt = PIX_FMT_YUV420P;
- fi.pts = vf->vf_pts;
- fi.color_space = -1;
- fi.epoch = vf->vf_epoch;
+ fi.fi_pix_fmt = PIX_FMT_YUV420P;
+ fi.fi_pts = vf->vf_pts;
+ fi.fi_color_space = -1;
+ fi.fi_epoch = vf->vf_epoch;
+ fi.fi_drive_clock = 1;
video_decoder_t *vd = vdad->vdad_vd;
- vd->vd_estimated_duration = fi.duration; // For bitrate calculations
+ vd->vd_estimated_duration = fi.fi_duration; // For bitrate calculations
- if(fi.duration > 0)
- video_deliver_frame(vd, FRAME_BUFFER_TYPE_LIBAV_FRAME, &frame,
- &fi, vf->vf_send_pts);
+ if(fi.fi_duration > 0)
+ video_deliver_frame(vd, FRAME_BUFFER_TYPE_LIBAV_FRAME, &frame, &fi);
CVPixelBufferUnlockBaseAddress(vf->vf_buf, 0);
vdad->vdad_last_pts = vf->vf_pts;
@@ -165,8 +165,8 @@ vda_callback(void *aux, CFDictionaryRef frame_info, OSStatus status,
ref = CFDictionaryGetValue(frame_info, CFSTR("epoch"));
CFNumberGetValue(ref, kCFNumberSInt8Type, &vf->vf_epoch);
- ref = CFDictionaryGetValue(frame_info, CFSTR("send_pts"));
- CFNumberGetValue(ref, kCFNumberSInt8Type, &vf->vf_send_pts);
+ ref = CFDictionaryGetValue(frame_info, CFSTR("drive_clock"));
+ CFNumberGetValue(ref, kCFNumberSInt8Type, &vf->vf_drive_clock);
vf->vf_buf = buf;
@@ -202,7 +202,7 @@ vda_decode(struct media_codec *mc, struct video_decoder *vd,
CFStringRef keys[num_kvs];
CFNumberRef values[num_kvs];
const int keyframe = mb->mb_keyframe;
- const int send_pts = mb->mb_send_pts;
+ const int drive_clock = mb->mb_drive_clock;
vda_frame_t *vf;
int i;
uint8_t skip = mb->mb_skip;
@@ -227,14 +227,14 @@ vda_decode(struct media_codec *mc, struct video_decoder *vd,
keys[1] = CFSTR("duration");
keys[2] = CFSTR("keyframe");
keys[3] = CFSTR("epoch");
- keys[4] = CFSTR("send_pts");
+ keys[4] = CFSTR("drive_clock");
keys[5] = CFSTR("skip");
values[0] = CFNumberCreate(NULL, kCFNumberSInt64Type, &mb->mb_pts);
values[1] = CFNumberCreate(NULL, kCFNumberSInt32Type, &mb->mb_duration);
values[2] = CFNumberCreate(NULL, kCFNumberSInt32Type, &keyframe);
values[3] = CFNumberCreate(NULL, kCFNumberSInt8Type, &mb->mb_epoch);
- values[4] = CFNumberCreate(NULL, kCFNumberSInt8Type, &send_pts);
+ values[4] = CFNumberCreate(NULL, kCFNumberSInt8Type, &drive_clock);
values[5] = CFNumberCreate(NULL, kCFNumberSInt8Type, &skip);
user_info = CFDictionaryCreate(kCFAllocatorDefault,
diff --git a/support/osx.mk b/support/osx.mk
index e59381777a..08886356e0 100644
--- a/support/osx.mk
+++ b/support/osx.mk
@@ -1,8 +1,10 @@
#
# Source modification and extra flags
#
-SRCS += src/arch/darwin.c \
- src/arch/arch_posix.c \
+SRCS += src/arch/osx/osx_main.c \
+ src/arch/darwin.c \
+ src/arch/posix/posix.c \
+ src/arch/posix/posix_threads.c \
src/networking/net_posix.c \
DVDCSS_CFLAGS = -DDARWIN_DVD_IOCTL -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE