Commit e4ceccd3 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

-

parent 359a9baf
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* darwin_specific.h: Darwin specific features * darwin_specific.h: Darwin specific features
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: darwin_specific.h,v 1.8 2004/01/25 18:17:08 zorglub Exp $ * $Id$
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -20,4 +20,3 @@ ...@@ -20,4 +20,3 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/ *****************************************************************************/
...@@ -69,8 +69,6 @@ int E_(OpenIntf) ( vlc_object_t *p_this ) ...@@ -69,8 +69,6 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
p_intf->p_sys->p_sub = msg_Subscribe( p_intf ); p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
p_intf->b_play = VLC_TRUE; p_intf->b_play = VLC_TRUE;
p_intf->pf_run = Run; p_intf->pf_run = Run;
[[VLCMain sharedInstance] setIntf: p_intf];
return( 0 ); return( 0 );
} }
...@@ -86,7 +84,7 @@ void E_(CloseIntf) ( vlc_object_t *p_this ) ...@@ -86,7 +84,7 @@ void E_(CloseIntf) ( vlc_object_t *p_this )
[p_intf->p_sys->o_sendport release]; [p_intf->p_sys->o_sendport release];
[p_intf->p_sys->o_pool release]; [p_intf->p_sys->o_pool release];
free( p_intf->p_sys ); free( p_intf->p_sys );
} }
...@@ -99,21 +97,24 @@ static void Run( intf_thread_t *p_intf ) ...@@ -99,21 +97,24 @@ static void Run( intf_thread_t *p_intf )
* fails to go to real-time priority with the first launched thread * fails to go to real-time priority with the first launched thread
* (???) --Meuuh */ * (???) --Meuuh */
vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
[[VLCMain sharedInstance] setIntf: p_intf];
[NSBundle loadNibNamed: @"MainMenu" owner: NSApp]; [NSBundle loadNibNamed: @"MainMenu" owner: NSApp];
[NSApp run];
[[VLCMain sharedInstance] terminate];
} }
int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
{ {
int i_ret = 0; int i_ret = 0;
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; //NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
if( [target respondsToSelector: @selector(performSelectorOnMainThread: if( [target respondsToSelector: @selector(performSelectorOnMainThread:
withObject:waitUntilDone:)] ) withObject:waitUntilDone:)] )
{ {
[target performSelectorOnMainThread: sel [target performSelectorOnMainThread: sel
withObject: [NSValue valueWithPointer: p_arg] withObject: [NSValue valueWithPointer: p_arg]
waitUntilDone: YES]; waitUntilDone: NO];
} }
else if( NSApp != nil && [[VLCMain sharedInstance] respondsToSelector: @selector(getIntf)] ) else if( NSApp != nil && [[VLCMain sharedInstance] respondsToSelector: @selector(getIntf)] )
{ {
...@@ -161,7 +162,7 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) ...@@ -161,7 +162,7 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
i_ret = 1; i_ret = 1;
} }
[o_pool release]; //[o_pool release];
return( i_ret ); return( i_ret );
} }
...@@ -290,7 +291,6 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -290,7 +291,6 @@ static VLCMain *_o_sharedMainInstance = nil;
- (void)awakeFromNib - (void)awakeFromNib
{ {
unsigned int i_key = 0; unsigned int i_key = 0;
intf_thread_t * p_intf = VLCIntf;
playlist_t *p_playlist; playlist_t *p_playlist;
vlc_value_t val; vlc_value_t val;
...@@ -527,7 +527,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -527,7 +527,7 @@ static VLCMain *_o_sharedMainInstance = nil;
vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
} }
/*
- (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename - (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename
{ {
NSDictionary *o_dic = [NSDictionary dictionaryWithObjectsAndKeys: o_filename, @"ITEM_URL", nil]; NSDictionary *o_dic = [NSDictionary dictionaryWithObjectsAndKeys: o_filename, @"ITEM_URL", nil];
...@@ -536,7 +536,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -536,7 +536,7 @@ static VLCMain *_o_sharedMainInstance = nil;
return( TRUE ); return( TRUE );
} }
*/
- (NSString *)localizedString:(char *)psz - (NSString *)localizedString:(char *)psz
{ {
NSString * o_str = nil; NSString * o_str = nil;
...@@ -637,7 +637,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -637,7 +637,7 @@ static VLCMain *_o_sharedMainInstance = nil;
int i; int i;
val.i_int = 0; 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]; i_pressed_modifiers = [o_event modifierFlags];
...@@ -658,7 +658,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -658,7 +658,7 @@ static VLCMain *_o_sharedMainInstance = nil;
{ {
if( p_hotkeys[i].i_key == val.i_int ) 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; return YES;
} }
} }
...@@ -696,6 +696,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -696,6 +696,7 @@ static VLCMain *_o_sharedMainInstance = nil;
- (void)manage - (void)manage
{ {
NSDate * o_sleep_date; NSDate * o_sleep_date;
/* new thread requires a new pool */
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW );
...@@ -809,7 +810,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -809,7 +810,7 @@ static VLCMain *_o_sharedMainInstance = nil;
{ {
if( [[o_vout_wnd className] isEqualToString: @"VLCWindow"] ) if( [[o_vout_wnd className] isEqualToString: @"VLCWindow"] )
{ {
[o_vout_wnd updateTitle]; ;//[o_vout_wnd updateTitle];
} }
} }
vlc_object_release( (vlc_object_t *)p_vout ); vlc_object_release( (vlc_object_t *)p_vout );
...@@ -1134,7 +1135,6 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -1134,7 +1135,6 @@ static VLCMain *_o_sharedMainInstance = nil;
- (IBAction)timesliderUpdate:(id)sender - (IBAction)timesliderUpdate:(id)sender
{ {
intf_thread_t * p_intf;
input_thread_t * p_input; input_thread_t * p_input;
float f_updated; float f_updated;
......
...@@ -74,29 +74,18 @@ ...@@ -74,29 +74,18 @@
@end @end
/*****************************************************************************
* VLCVout interface
*****************************************************************************/
@interface VLCVout : NSObject
{
}
- (void)createWindow:(NSValue *)o_value;
- (void)destroyWindow:(NSValue *)o_value;
@end
/***************************************************************************** /*****************************************************************************
* vout_sys_t: MacOS X video output method descriptor * vout_sys_t: MacOS X video output method descriptor
*****************************************************************************/ *****************************************************************************/
struct vout_sys_t struct vout_sys_t
{ {
int i_opengl; NSAutoreleasePool *o_pool;
NSRect s_rect; NSRect s_rect;
int b_pos_saved;
VLCWindow * o_window; VLCWindow * o_window;
int i_opengl;
int b_pos_saved;
vlc_bool_t b_mouse_moved; vlc_bool_t b_mouse_moved;
mtime_t i_time_mouse_last_moved; mtime_t i_time_mouse_last_moved;
......
This diff is collapsed.
...@@ -60,6 +60,17 @@ static int SwitchIntfCallback( vlc_object_t *, char const *, ...@@ -60,6 +60,17 @@ static int SwitchIntfCallback( vlc_object_t *, char const *,
static int AddIntfCallback( vlc_object_t *, char const *, static int AddIntfCallback( vlc_object_t *, char const *,
vlc_value_t , vlc_value_t , void * ); vlc_value_t , vlc_value_t , void * );
#ifdef SYS_DARWIN
/*****************************************************************************
* VLCApplication interface
*****************************************************************************/
@interface VLCApplication : NSApplication
{
}
@end
#endif
/***************************************************************************** /*****************************************************************************
* intf_Create: prepare interface before main loop * intf_Create: prepare interface before main loop
***************************************************************************** *****************************************************************************
...@@ -131,6 +142,8 @@ intf_thread_t* __intf_Create( vlc_object_t *p_this, const char *psz_module ) ...@@ -131,6 +142,8 @@ intf_thread_t* __intf_Create( vlc_object_t *p_this, const char *psz_module )
int intf_RunThread( intf_thread_t *p_intf ) int intf_RunThread( intf_thread_t *p_intf )
{ {
#ifdef SYS_DARWIN #ifdef SYS_DARWIN
NSAutoreleasePool * o_pool;
if( p_intf->b_block ) if( p_intf->b_block )
{ {
/* This is the primary intf */ /* This is the primary intf */
...@@ -143,28 +156,36 @@ int intf_RunThread( intf_thread_t *p_intf ) ...@@ -143,28 +156,36 @@ int intf_RunThread( intf_thread_t *p_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 :) o_pool = [[NSAutoreleasePool alloc] init];
This is NOT I REPEAT NOT blocking since [NSApp run] is */ [VLCApplication sharedApplication];
p_intf->b_block = VLC_FALSE;
RunInterface( p_intf );
p_intf->b_block = VLC_TRUE;
} }
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] ) /* VLC in normal primary interface mode */
this is equal to running in normal non-OSX primary intf mode */
RunInterface( p_intf ); RunInterface( p_intf );
p_intf->b_die = VLC_TRUE; p_intf->b_die = VLC_TRUE;
} }
else else
{ {
/* If anything else is the primary intf and we are not in cli mode, /* Run the interface in a separate thread */
then don't make it blocking ([NSApp run] will be blocking) if( vlc_thread_create( p_intf, "interface", RunInterface,
but run it in a seperate thread. */ VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
p_intf->b_block = 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 #else
if( p_intf->b_block ) if( p_intf->b_block )
{ {
...@@ -183,7 +204,6 @@ int intf_RunThread( intf_thread_t *p_intf ) ...@@ -183,7 +204,6 @@ int intf_RunThread( intf_thread_t *p_intf )
} }
else else
{ {
#endif
/* Run the interface in a separate thread */ /* Run the interface in a separate thread */
if( vlc_thread_create( p_intf, "interface", RunInterface, if( vlc_thread_create( p_intf, "interface", RunInterface,
VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) ) VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
...@@ -192,6 +212,7 @@ int intf_RunThread( intf_thread_t *p_intf ) ...@@ -192,6 +212,7 @@ int intf_RunThread( intf_thread_t *p_intf )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
} }
#endif
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -418,3 +439,37 @@ static int AddIntfCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -418,3 +439,37 @@ static int AddIntfCallback( vlc_object_t *p_this, char const *psz_cmd,
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
...@@ -1316,3 +1316,4 @@ static struct hotkey p_hotkeys[] = ...@@ -1316,3 +1316,4 @@ static struct hotkey p_hotkeys[] =
{ "key-history-forward", ACTIONID_HISTORY_FORWARD, 0}, { "key-history-forward", ACTIONID_HISTORY_FORWARD, 0},
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* darwin_specific.m: Darwin specific features * darwin_specific.m: Darwin specific features
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2004 VideoLAN * Copyright (C) 2001-2004 VideoLAN
* $Id: darwin_specific.m,v 1.18 2004/01/06 12:02:06 zorglub Exp $ * $Id$
* *
* Authors: Sam Hocevar <sam@zoy.org> * Authors: Sam Hocevar <sam@zoy.org>
* Christophe Massiot <massiot@via.ecp.fr> * Christophe Massiot <massiot@via.ecp.fr>
......
...@@ -1099,7 +1099,7 @@ static void ErrorThread( vout_thread_t *p_vout ) ...@@ -1099,7 +1099,7 @@ static void ErrorThread( vout_thread_t *p_vout )
* EndThread: thread destruction * EndThread: thread destruction
***************************************************************************** *****************************************************************************
* This function is called when the thread ends after a sucessful * This function is called when the thread ends after a sucessful
* initialization. It frees all ressources allocated by InitThread. * initialization. It frees all resources allocated by InitThread.
*****************************************************************************/ *****************************************************************************/
static void EndThread( vout_thread_t *p_vout ) static void EndThread( vout_thread_t *p_vout )
{ {
......
...@@ -35,16 +35,9 @@ ...@@ -35,16 +35,9 @@
#ifdef HAVE_TIME_H #ifdef HAVE_TIME_H
# include <time.h> /* time() */ # include <time.h> /* time() */
#endif #endif
#ifdef HAVE_STRINGS_H
# include <strings.h> /* strncmp() */
#endif
#include <vlc/vlc.h> #include <vlc/vlc.h>
#ifdef SYS_DARWIN
#include <Cocoa/Cocoa.h>
#endif
/***************************************************************************** /*****************************************************************************
* Local prototypes. * Local prototypes.
*****************************************************************************/ *****************************************************************************/
...@@ -52,46 +45,6 @@ ...@@ -52,46 +45,6 @@
static void SigHandler ( int i_signal ); static void SigHandler ( int i_signal );
#endif #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. * main: parse command line, start interface and spawn threads.
*****************************************************************************/ *****************************************************************************/
...@@ -150,39 +103,7 @@ int main( int i_argc, char *ppsz_argv[] ) ...@@ -150,39 +103,7 @@ int main( int i_argc, char *ppsz_argv[] )
return i_ret; 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 ); i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE );
#endif /* SYS_DARWIN */
/* Finish the threads */ /* Finish the threads */
VLC_CleanUp( 0 ); VLC_CleanUp( 0 );
...@@ -190,13 +111,6 @@ int main( int i_argc, char *ppsz_argv[] ) ...@@ -190,13 +111,6 @@ int main( int i_argc, char *ppsz_argv[] )
/* Destroy the libvlc structure */ /* Destroy the libvlc structure */
VLC_Destroy( 0 ); VLC_Destroy( 0 );
#ifdef SYS_DARWIN
if( !b_cli )
{
[NSApp terminate:NULL];
}
#endif /* SYS_DARWIN */
return i_ret; return i_ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment