p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
p_intf->b_play = VLC_TRUE;
p_intf->pf_run = Run;
-
- [[VLCMain sharedInstance] setIntf: p_intf];
return( 0 );
}
[p_intf->p_sys->o_sendport release];
[p_intf->p_sys->o_pool release];
-
+
free( p_intf->p_sys );
}
* fails to go to real-time priority with the first launched thread
* (???) --Meuuh */
vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
+ [[VLCMain sharedInstance] setIntf: p_intf];
[NSBundle loadNibNamed: @"MainMenu" owner: NSApp];
+ [NSApp run];
+ [[VLCMain sharedInstance] terminate];
}
int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
{
int i_ret = 0;
- NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
+ //NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
if( [target respondsToSelector: @selector(performSelectorOnMainThread:
withObject:waitUntilDone:)] )
{
[target performSelectorOnMainThread: sel
withObject: [NSValue valueWithPointer: p_arg]
- waitUntilDone: YES];
+ waitUntilDone: NO];
}
else if( NSApp != nil && [[VLCMain sharedInstance] respondsToSelector: @selector(getIntf)] )
{
i_ret = 1;
}
- [o_pool release];
+ //[o_pool release];
return( i_ret );
}
- (void)awakeFromNib
{
unsigned int i_key = 0;
- intf_thread_t * p_intf = VLCIntf;
playlist_t *p_playlist;
vlc_value_t val;
vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
}
-/*
+
- (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename
{
NSDictionary *o_dic = [NSDictionary dictionaryWithObjectsAndKeys: o_filename, @"ITEM_URL", nil];
return( TRUE );
}
-*/
+
- (NSString *)localizedString:(char *)psz
{
NSString * o_str = nil;
int i;
val.i_int = 0;
- p_hotkeys = VLCIntf->p_vlc->p_hotkeys;
+ p_hotkeys = p_intf->p_vlc->p_hotkeys;
i_pressed_modifiers = [o_event modifierFlags];
{
if( p_hotkeys[i].i_key == val.i_int )
{
- var_Set( VLCIntf->p_vlc, "key-pressed", val );
+ var_Set( p_intf->p_vlc, "key-pressed", val );
return YES;
}
}
- (void)manage
{
NSDate * o_sleep_date;
+ /* new thread requires a new pool */
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
{
if( [[o_vout_wnd className] isEqualToString: @"VLCWindow"] )
{
- [o_vout_wnd updateTitle];
+ ;//[o_vout_wnd updateTitle];
}
}
vlc_object_release( (vlc_object_t *)p_vout );
- (IBAction)timesliderUpdate:(id)sender
{
- intf_thread_t * p_intf;
input_thread_t * p_input;
float f_updated;
static int vout_Manage ( vout_thread_t * );
static void vout_Display ( vout_thread_t *, picture_t * );
-static int CoSendRequest ( vout_thread_t *, SEL );
static int CoCreateWindow ( vout_thread_t * );
static int CoDestroyWindow ( vout_thread_t * );
static int CoToggleFullscreen ( vout_thread_t * );
return( 1 );
}
+ p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
p_vout->p_sys->b_mouse_moved = VLC_TRUE;
p_vout->p_sys->i_time_mouse_last_moved = mdate();
DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
free( p_vout->p_sys );
return( 1 );
- }
+ }
/* Damn QT isn't thread safe. so keep a lock in the p_vlc object */
vlc_mutex_lock( &p_vout->p_vlc->quicktime_lock );
nil, &p_vout->p_sys->img_dc );
vlc_mutex_unlock( &p_vout->p_vlc->quicktime_lock );
+
if( err == noErr && p_vout->p_sys->img_dc != 0 )
{
p_vout->output.i_chroma = VLC_FOURCC('I','4','2','0');
msg_Dbg( p_vout, "using OpenGL mode" );
}
- NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
NSArray * o_screens = [NSScreen screens];
if( [o_screens count] > 0 && var_Type( p_vout, "video-device" ) == 0 )
{
val.b_bool = VLC_TRUE;
var_Set( p_vout, "intf-change", val );
}
- [o_pool release];
if( CoCreateWindow( p_vout ) )
{
* CloseVideo: destroy video thread output method
*****************************************************************************/
void E_(CloseVideo) ( vlc_object_t *p_this )
-{
+{
+ NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
vout_thread_t * p_vout = (vout_thread_t *)p_this;
if( p_vout->p_sys->i_opengl )
DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
}
+ [o_pool release];
free( p_vout->p_sys );
}
}
/*****************************************************************************
- * CoSendRequest: send request to interface thread
+ * CoCreateWindow: create new window
*****************************************************************************
* Returns 0 on success, 1 otherwise
*****************************************************************************/
-static int CoSendRequest( vout_thread_t *p_vout, SEL sel )
+static int CoCreateWindow( vout_thread_t *p_vout )
{
- int i_ret = 0;
vlc_value_t val;
- intf_thread_t * p_intf;
+ VLCQTView * o_view;
+ NSScreen * o_screen;
+ vlc_bool_t b_main_screen;
+ NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
- VLCVout * o_vlv = [[VLCVout alloc] init];
+ p_vout->p_sys->o_window = [VLCWindow alloc];
+ [p_vout->p_sys->o_window setReleasedWhenClosed: YES];
- if( ( i_ret = ExecuteOnMainThread( o_vlv, sel, (void *)p_vout ) ) )
+ if( var_Get( p_vout, "video-device", &val ) < 0 )
{
- msg_Err( p_vout, "SendRequest: no way to communicate with mt" );
+ o_screen = [NSScreen mainScreen];
+ b_main_screen = 1;
}
+ else
+ {
+ NSArray *o_screens = [NSScreen screens];
+ unsigned int i_index = val.i_int;
+
+ if( [o_screens count] < i_index )
+ {
+ o_screen = [NSScreen mainScreen];
+ b_main_screen = 1;
+ }
+ else
+ {
+ i_index--;
+ o_screen = [o_screens objectAtIndex: i_index];
+ config_PutInt( p_vout, "macosx-vdev", i_index );
+ b_main_screen = (i_index == 0);
+ }
+ }
- [o_vlv release];
+ if( p_vout->b_fullscreen )
+ {
+ NSRect screen_rect = [o_screen frame];
+ screen_rect.origin.x = screen_rect.origin.y = 0;
- /*This makes this function dependant of the presence of a macosx
- interface. We do not check if this interface exists, since it has
- already been done before.*/
+ if ( b_main_screen && p_vout->p_sys->p_fullscreen_state == NULL )
+ BeginFullScreen( &p_vout->p_sys->p_fullscreen_state, NULL, 0, 0,
+ NULL, NULL, fullScreenAllowEvents );
- /*p_intf = VLCIntf;
+ [p_vout->p_sys->o_window
+ initWithContentRect: screen_rect
+ styleMask: NSBorderlessWindowMask
+ backing: NSBackingStoreBuffered
+ defer: NO screen: o_screen];
- val.b_bool = VLC_TRUE;
- var_Create(p_intf,"intf-change",VLC_VAR_BOOL);
- var_Set(p_intf, "intf-change",val);
-*/
- return( i_ret );
-}
+ [p_vout->p_sys->o_window setVout: p_vout];
+ p_vout->p_sys->b_mouse_moved = YES;
+ p_vout->p_sys->i_time_mouse_last_moved = mdate();
+ }
+ else
+ {
+ unsigned int i_stylemask = NSTitledWindowMask |
+ NSMiniaturizableWindowMask |
+ NSClosableWindowMask |
+ NSResizableWindowMask;
+
+ if ( p_vout->p_sys->p_fullscreen_state != NULL )
+ EndFullScreen ( p_vout->p_sys->p_fullscreen_state, NULL );
+ p_vout->p_sys->p_fullscreen_state = NULL;
-/*****************************************************************************
- * CoCreateWindow: create new window
- *****************************************************************************
- * Returns 0 on success, 1 otherwise
- *****************************************************************************/
-static int CoCreateWindow( vout_thread_t *p_vout )
-{
- if( CoSendRequest( p_vout, @selector(createWindow:) ) )
+ [p_vout->p_sys->o_window
+ initWithContentRect: p_vout->p_sys->s_rect
+ styleMask: i_stylemask
+ backing: NSBackingStoreBuffered
+ defer: NO screen: o_screen];
+
+ [p_vout->p_sys->o_window setVout: p_vout];
+ [p_vout->p_sys->o_window setAlphaValue: config_GetFloat( p_vout, "macosx-opaqueness" )];
+
+ if( config_GetInt( p_vout, "video-on-top" ) )
+ {
+ [p_vout->p_sys->o_window setLevel: NSStatusWindowLevel];
+ }
+
+ if( !p_vout->p_sys->b_pos_saved )
+ {
+ [p_vout->p_sys->o_window center];
+ }
+ }
+
+ if( !p_vout->p_sys->i_opengl )
{
- msg_Err( p_vout, "CoSendRequest (createWindow) failed" );
- return( 1 );
+ o_view = [[VLCQTView alloc] init];
+ /* FIXME: [o_view setMenu:] */
+ [p_vout->p_sys->o_window setContentView: o_view];
+ [o_view autorelease];
+
+ [o_view lockFocus];
+ p_vout->p_sys->p_qdport = [o_view qdPort];
+ [o_view unlockFocus];
+ }
+ else
+ {
+#define o_glview p_vout->p_sys->o_glview
+ o_glview = [[VLCGLView alloc] initWithFrame: p_vout->p_sys->s_rect vout: p_vout];
+ [p_vout->p_sys->o_window setContentView: o_glview];
+ [o_glview autorelease];
+#undef o_glview
}
- return( 0 );
+ [p_vout->p_sys->o_window updateTitle];
+ [p_vout->p_sys->o_window makeKeyAndOrderFront: nil];
+
+ [o_pool release];
+ return( 0);
}
/*****************************************************************************
*****************************************************************************/
static int CoDestroyWindow( vout_thread_t *p_vout )
{
-
+ NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
VLCHideMouse( p_vout, NO );
- if( CoSendRequest( p_vout, @selector(destroyWindow:) ) )
+ if( !p_vout->b_fullscreen )
{
- msg_Err( p_vout, "CoSendRequest (destroyWindow) failed" );
- return( 1 );
- }
+ NSRect s_rect;
- return( 0 );
+ s_rect = [[p_vout->p_sys->o_window contentView] frame];
+ p_vout->p_sys->s_rect.size = s_rect.size;
+
+ s_rect = [p_vout->p_sys->o_window frame];
+ p_vout->p_sys->s_rect.origin = s_rect.origin;
+
+ p_vout->p_sys->b_pos_saved = YES;
+ }
+
+ p_vout->p_sys->p_qdport = nil;
+ [p_vout->p_sys->o_window close];
+ p_vout->p_sys->o_window = nil;
+ [o_pool release];
+ return 0;
}
/*****************************************************************************
*****************************************************************************/
static int CoToggleFullscreen( vout_thread_t *p_vout )
{
+ NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
+
if( !p_vout->p_sys->i_opengl )
{
QTDestroySequence( p_vout );
}
}
+ [o_pool release];
return( 0 );
}
{
return( YES );
}
-
+/*
- (BOOL)performKeyEquivalent:(NSEvent *)o_event
{
return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event];
}
-
+*/
- (void)keyDown:(NSEvent *)o_event
{
unichar key = 0;
}
@end
-
-/*****************************************************************************
- * VLCVout implementation
- *****************************************************************************/
-@implementation VLCVout
-
-- (void)createWindow:(NSValue *)o_value
-{
- vlc_value_t val;
- VLCQTView * o_view;
- NSScreen * o_screen;
- vout_thread_t * p_vout;
- vlc_bool_t b_main_screen;
-
- p_vout = (vout_thread_t *)[o_value pointerValue];
-
- p_vout->p_sys->o_window = [VLCWindow alloc];
- [p_vout->p_sys->o_window setVout: p_vout];
- [p_vout->p_sys->o_window setReleasedWhenClosed: YES];
-
- if( var_Get( p_vout, "video-device", &val ) < 0 )
- {
- o_screen = [NSScreen mainScreen];
- b_main_screen = 1;
- }
- else
- {
- NSArray *o_screens = [NSScreen screens];
- unsigned int i_index = val.i_int;
-
- if( [o_screens count] < i_index )
- {
- o_screen = [NSScreen mainScreen];
- b_main_screen = 1;
- }
- else
- {
- i_index--;
- o_screen = [o_screens objectAtIndex: i_index];
- config_PutInt( p_vout, "macosx-vdev", i_index );
- b_main_screen = (i_index == 0);
- }
- }
-
- if( p_vout->b_fullscreen )
- {
- NSRect screen_rect = [o_screen frame];
- screen_rect.origin.x = screen_rect.origin.y = 0;
-
- if ( b_main_screen && p_vout->p_sys->p_fullscreen_state == NULL )
- BeginFullScreen( &p_vout->p_sys->p_fullscreen_state, NULL, 0, 0,
- NULL, NULL, fullScreenAllowEvents );
-
- [p_vout->p_sys->o_window
- initWithContentRect: screen_rect
- styleMask: NSBorderlessWindowMask
- backing: NSBackingStoreBuffered
- defer: NO screen: o_screen];
-
- //[p_vout->p_sys->o_window setLevel: NSPopUpMenuWindowLevel - 1];
- p_vout->p_sys->b_mouse_moved = YES;
- p_vout->p_sys->i_time_mouse_last_moved = mdate();
- }
- else
- {
- unsigned int i_stylemask = NSTitledWindowMask |
- NSMiniaturizableWindowMask |
- NSClosableWindowMask |
- NSResizableWindowMask;
-
- if ( p_vout->p_sys->p_fullscreen_state != NULL )
- EndFullScreen ( p_vout->p_sys->p_fullscreen_state, NULL );
- p_vout->p_sys->p_fullscreen_state = NULL;
-
- [p_vout->p_sys->o_window
- initWithContentRect: p_vout->p_sys->s_rect
- styleMask: i_stylemask
- backing: NSBackingStoreBuffered
- defer: NO screen: o_screen];
-
- [p_vout->p_sys->o_window setAlphaValue: config_GetFloat( p_vout, "macosx-opaqueness" )];
-
- if( config_GetInt( p_vout, "video-on-top" ) )
- {
- [p_vout->p_sys->o_window setLevel: NSStatusWindowLevel];
- }
-
- if( !p_vout->p_sys->b_pos_saved )
- {
- [p_vout->p_sys->o_window center];
- }
- }
-
- if( !p_vout->p_sys->i_opengl )
- {
- o_view = [[VLCQTView alloc] init];
- /* FIXME: [o_view setMenu:] */
- [p_vout->p_sys->o_window setContentView: o_view];
- [o_view autorelease];
-
- [o_view lockFocus];
- p_vout->p_sys->p_qdport = [o_view qdPort];
- [o_view unlockFocus];
- }
- else
- {
-#define o_glview p_vout->p_sys->o_glview
- o_glview = [[VLCGLView alloc] initWithFrame: p_vout->p_sys->s_rect vout: p_vout];
- [p_vout->p_sys->o_window setContentView: o_glview];
- [o_glview autorelease];
-#undef o_glview
- }
-
- [p_vout->p_sys->o_window updateTitle];
- [p_vout->p_sys->o_window makeKeyAndOrderFront: nil];
-
-}
-
-- (void)destroyWindow:(NSValue *)o_value
-{
- vout_thread_t * p_vout;
-
- p_vout = (vout_thread_t *)[o_value pointerValue];
-
- if( !p_vout->b_fullscreen )
- {
- NSRect s_rect;
-
- s_rect = [[p_vout->p_sys->o_window contentView] frame];
- p_vout->p_sys->s_rect.size = s_rect.size;
-
- s_rect = [p_vout->p_sys->o_window frame];
- p_vout->p_sys->s_rect.origin = s_rect.origin;
-
- p_vout->p_sys->b_pos_saved = YES;
- }
-
- p_vout->p_sys->p_qdport = nil;
- [p_vout->p_sys->o_window close];
- p_vout->p_sys->o_window = nil;
-}
-
-@end
static int AddIntfCallback( vlc_object_t *, char const *,
vlc_value_t , vlc_value_t , void * );
+#ifdef SYS_DARWIN
+/*****************************************************************************
+ * VLCApplication interface
+ *****************************************************************************/
+@interface VLCApplication : NSApplication
+{
+}
+
+@end
+#endif
+
/*****************************************************************************
* intf_Create: prepare interface before main loop
*****************************************************************************
int intf_RunThread( intf_thread_t *p_intf )
{
#ifdef SYS_DARWIN
+ NSAutoreleasePool * o_pool;
+
if( p_intf->b_block )
{
/* This is the primary intf */
}
}
- if( p_intf->b_block && !strncmp( p_intf->p_module->psz_shortname, "macosx" , 6 ) )
+ if( p_intf->b_block && strncmp( p_intf->p_module->psz_shortname, "clivlc", 6) )
{
- /* this is OSX, we are cheating :)
- This is NOT I REPEAT NOT blocking since [NSApp run] is */
- p_intf->b_block = VLC_FALSE;
-
- RunInterface( p_intf );
- p_intf->b_block = VLC_TRUE;
+ o_pool = [[NSAutoreleasePool alloc] init];
+ [VLCApplication sharedApplication];
}
- else if( p_intf->b_block && !strncmp( p_intf->p_vlc->psz_object_name, "clivlc", 6 ) )
+
+ if( p_intf->b_block && ( !strncmp( p_intf->p_module->psz_shortname, "macosx" , 6 ) ||
+ !strncmp( p_intf->p_vlc->psz_object_name, "clivlc", 6 ) ) )
{
- /* VLC OS X in cli mode ( no blocking [NSApp run] )
- this is equal to running in normal non-OSX primary intf mode */
+ /* VLC in normal primary interface mode */
RunInterface( p_intf );
p_intf->b_die = VLC_TRUE;
}
else
{
- /* If anything else is the primary intf and we are not in cli mode,
- then don't make it blocking ([NSApp run] will be blocking)
- but run it in a seperate thread. */
- p_intf->b_block = VLC_FALSE;
+ /* Run the interface in a separate thread */
+ if( vlc_thread_create( p_intf, "interface", RunInterface,
+ VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
+ {
+ msg_Err( p_intf, "cannot spawn interface thread" );
+ return VLC_EGENERIC;
+ }
+
+ if( p_intf->b_block )
+ {
+ /* VLC in primary interface mode with a working macosx vout */
+ [NSApp run];
+ p_intf->b_die = VLC_TRUE;
+ }
+ }
#else
if( p_intf->b_block )
{
}
else
{
-#endif
/* Run the interface in a separate thread */
if( vlc_thread_create( p_intf, "interface", RunInterface,
VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
return VLC_EGENERIC;
}
}
+#endif
return VLC_SUCCESS;
}
return VLC_SUCCESS;
}
+
+#ifdef SYS_DARWIN
+/*****************************************************************************
+ * VLCApplication implementation
+ *****************************************************************************/
+@implementation VLCApplication
+
+- (void)stop: (id)sender
+{
+ NSEvent *o_event;
+ NSAutoreleasePool *o_pool;
+ [super stop:sender];
+
+ o_pool = [[NSAutoreleasePool alloc] init];
+ /* send a dummy event to break out of the event loop */
+ o_event = [NSEvent mouseEventWithType: NSLeftMouseDown
+ location: NSMakePoint( 1, 1 ) modifierFlags: 0
+ timestamp: 1 windowNumber: [[NSApp mainWindow] windowNumber]
+ context: [NSGraphicsContext currentContext] eventNumber: 1
+ clickCount: 1 pressure: 0.0];
+ [NSApp postEvent: o_event atStart: YES];
+ [o_pool release];
+}
+
+- (void)terminate: (id)sender
+{
+ if( [NSApp isRunning] )
+ [NSApp stop:sender];
+ [super terminate: sender];
+}
+
+@end
+#endif
+
#ifdef HAVE_TIME_H
# include <time.h> /* time() */
#endif
-#ifdef HAVE_STRINGS_H
-# include <strings.h> /* strncmp() */
-#endif
#include <vlc/vlc.h>
-#ifdef SYS_DARWIN
-#include <Cocoa/Cocoa.h>
-#endif
-
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
static void SigHandler ( int i_signal );
#endif
-#ifdef SYS_DARWIN
-/*****************************************************************************
- * VLCApplication interface
- *****************************************************************************/
-@interface VLCApplication : NSApplication
-{
-}
-
-@end
-
-/*****************************************************************************
- * VLCApplication implementation
- *****************************************************************************/
-@implementation VLCApplication
-
-- (void)stop: (id)sender
-{
- NSEvent *o_event;
- [super stop:sender];
-
- /* send a dummy event to break out of the event loop */
- o_event = [NSEvent mouseEventWithType: NSLeftMouseDown
- location: NSMakePoint( 1, 1 ) modifierFlags: 0
- timestamp: 1 windowNumber: [[NSApp mainWindow] windowNumber]
- context: [NSGraphicsContext currentContext] eventNumber: 1
- clickCount: 1 pressure: 0.0];
- [NSApp postEvent: o_event atStart: YES];
-}
-
-- (void)terminate: (id)sender
-{
- if( [NSApp isRunning] )
- [NSApp stop:sender];
- [super terminate: sender];
-}
-
-@end
-
-#endif /* SYS_DARWIN */
-
/*****************************************************************************
* main: parse command line, start interface and spawn threads.
*****************************************************************************/
return i_ret;
}
-#ifdef HAVE_STRINGS_H
- /* if first 3 chars of argv[0] are cli, then this is clivlc
- * We detect this specifically for Mac OS X, so you can launch vlc
- * from the commandline even if you are not logged in on the GUI */
- if( i_argc > 0 )
- {
- char *psz_temp;
- char *psz_program = psz_temp = ppsz_argv[0];
- while( *psz_temp )
- {
- if( *psz_temp == '/' ) psz_program = ++psz_temp;
- else ++psz_temp;
- }
- b_cli = !strncmp( psz_program, "cli", 3 );
- }
-#endif
-
-#ifdef SYS_DARWIN
- if( !b_cli )
- {
- [VLCApplication sharedApplication];
- }
-
- i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE );
-
- if( !b_cli )
- {
- /* This is a blocking call */
- [NSApp run];
- }
-#else
i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE );
-#endif /* SYS_DARWIN */
/* Finish the threads */
VLC_CleanUp( 0 );
/* Destroy the libvlc structure */
VLC_Destroy( 0 );
-#ifdef SYS_DARWIN
- if( !b_cli )
- {
- [NSApp terminate:NULL];
- }
-#endif /* SYS_DARWIN */
-
return i_ret;
}