Skip to content

Commit

Permalink
osx: Make it build again
Browse files Browse the repository at this point in the history
  • Loading branch information
andoma committed Sep 20, 2012
1 parent ccec94a commit 2acdf79
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 114 deletions.
2 changes: 1 addition & 1 deletion configure.osx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
92 changes: 92 additions & 0 deletions src/arch/osx/osx_main.c
Original file line number Diff line number Diff line change
@@ -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 <http:https://www.gnu.org/licenses/>.
*/


#include <sys/types.h>
#include <sys/sysctl.h>

#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;
}

25 changes: 0 additions & 25 deletions src/arch/posix/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,6 @@ const char *showtime_get_system_type(void);

#elif defined(__APPLE__)

const char *
showtime_get_system_type(void)
{
return "Apple";
}

#include <sys/types.h>
#include <sys/sysctl.h>
#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

Expand Down
2 changes: 1 addition & 1 deletion src/arch/threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/fileaccess/fa_spotlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
81 changes: 16 additions & 65 deletions src/ui/glw/glw_cocoa.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand All @@ -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 {
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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];
}
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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 =
Expand All @@ -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);
Expand Down Expand Up @@ -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 };
Expand All @@ -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,
};
38 changes: 19 additions & 19 deletions src/video/vda.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand Down
Loading

0 comments on commit 2acdf79

Please sign in to comment.