memset( p_intf->p_sys, 0, sizeof( *p_intf->p_sys ) );
- p_intf->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
-
/* subscribe to LibVLCCore's messages */
p_intf->p_sys->p_sub = msg_Subscribe( p_intf->p_libvlc, MsgCallback, NULL );
p_intf->pf_run = Run;
{
intf_thread_t *p_intf = (intf_thread_t*) p_this;
- [p_intf->p_sys->o_pool release];
-
free( p_intf->p_sys );
}
else
_o_sharedMainInstance = [super init];
+ p_intf = NULL;
+
o_msg_lock = [[NSLock alloc] init];
- o_msg_arr = [[NSMutableArray arrayWithCapacity: 200] retain];
+ o_msg_arr = [[NSMutableArray arrayWithCapacity: 600] retain];
/* subscribe to LibVLC's debug messages as early as possible (for us) */
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(libvlcMessageReceived:) name: @"VLCCoreMessageReceived" object: nil];
i_lastShownVolume = -1;
-#ifndef __x86_64__
o_remote = [[AppleRemote alloc] init];
[o_remote setClickCountEnabledButtons: kRemoteButtonPlay];
[o_remote setDelegate: _o_sharedMainInstance];
-#endif
o_eyetv = [[VLCEyeTVController alloc] init];
playlist_t *p_playlist;
vlc_value_t val;
- /* Check if we already did this once. Opening the other nibs calls it too, because VLCMain is the owner */
+ if( !p_intf ) return;
+
+ /* Check if we already did this once. Opening the other nibs calls it too,
+ because VLCMain is the owner */
if( nib_main_loaded ) return;
/* check whether the user runs a valid version of OS X */
i_key = config_GetInt( p_intf, "key-snapshot" );
[o_mi_snapshot setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]];
[o_mi_snapshot setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)];
+ i_key = config_GetInt( p_intf, "key-random" );
+ [o_mi_random setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]];
+ [o_mi_random setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)];
+ i_key = config_GetInt( p_intf, "key-zoom-half" );
+ [o_mi_half_window setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]];
+ [o_mi_half_window setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)];
+ i_key = config_GetInt( p_intf, "key-zoom-original" );
+ [o_mi_normal_window setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]];
+ [o_mi_normal_window setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)];
+ i_key = config_GetInt( p_intf, "key-zoom-double" );
+ [o_mi_double_window setKeyEquivalent: [NSString stringWithFormat:@"%C", VLCKeyToCocoa( i_key )]];
+ [o_mi_double_window setKeyEquivalentModifierMask: VLCModifiersToCocoa(i_key)];
var_Create( p_intf, "intf-change", VLC_VAR_BOOL );
nib_coredialogs_loaded = [NSBundle loadNibNamed:@"CoreDialogs" owner: NSApp];
/* subscribe to various interactive dialogues */
- var_Create( p_intf, "dialog-fatal", VLC_VAR_ADDRESS );
- var_AddCallback( p_intf, "dialog-fatal", DialogCallback, self );
+ var_Create( p_intf, "dialog-error", VLC_VAR_ADDRESS );
+ var_AddCallback( p_intf, "dialog-error", DialogCallback, self );
+ var_Create( p_intf, "dialog-critical", VLC_VAR_ADDRESS );
+ var_AddCallback( p_intf, "dialog-critical", DialogCallback, self );
var_Create( p_intf, "dialog-login", VLC_VAR_ADDRESS );
var_AddCallback( p_intf, "dialog-login", DialogCallback, self );
var_Create( p_intf, "dialog-question", VLC_VAR_ADDRESS );
- (void)applicationWillFinishLaunching:(NSNotification *)o_notification
{
+ if( !p_intf ) return;
+
/* FIXME: don't poll */
interfaceTimer = [[NSTimer scheduledTimerWithTimeInterval: 0.5
target: self selector: @selector(manageIntf:)
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
+ if( !p_intf ) return;
+
[self _removeOldPreferences];
#ifdef UPDATE_CHECK
- (void)initStrings
{
+ if( !p_intf ) return;
+
[o_window setTitle: _NS("VLC media player")];
[self setScrollField:_NS("VLC media player") stopAfter:-1];
- (void)releaseRepresentedObjects:(NSMenu *)the_menu
{
+ if( !p_intf ) return;
+
NSArray *menuitems_array = [the_menu itemArray];
for( int i=0; i<[menuitems_array count]; i++ )
{
vout_thread_t * p_vout;
int returnedValue = 0;
+ if( !p_intf ) return;
+
msg_Dbg( p_intf, "Terminating" );
/* Make sure the manage_thread won't call -terminate: again */
/* unsubscribe from the interactive dialogues */
dialog_Unregister( p_intf );
- var_DelCallback( p_intf, "dialog-fatal", DialogCallback, self );
+ var_DelCallback( p_intf, "dialog-error", DialogCallback, self );
+ var_DelCallback( p_intf, "dialog-critical", DialogCallback, self );
var_DelCallback( p_intf, "dialog-login", DialogCallback, self );
var_DelCallback( p_intf, "dialog-question", DialogCallback, self );
var_DelCallback( p_intf, "dialog-progress-bar", DialogCallback, self );
{
NSToolbarItem *toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdentifier] autorelease];
-
if( [itemIdentifier isEqual: VLCToolbarMediaControl] )
{
[toolbarItem setLabel:@"Media Controls"];
application */
- (void)applicationDidBecomeActive:(NSNotification *)aNotification
{
-#ifndef __x86_64__
- [o_remote startListening: self];
-#endif
+ if( !p_intf ) return;
+ if( config_GetInt( p_intf, "macosx-appleremote" ) == YES )
+ [o_remote startListening: self];
}
- (void)applicationDidResignActive:(NSNotification *)aNotification
{
-#ifndef __x86_64__
+ if( !p_intf ) return;
[o_remote stopListening: self];
-#endif
}
/* Triggered when the computer goes to sleep */
- (void)computerWillSleep: (NSNotification *)notification
{
/* Pause */
- if( p_intf->p_sys->i_play_status == PLAYING_S )
+ if( p_intf && p_intf->p_sys->i_play_status == PLAYING_S )
{
- vlc_value_t val;
- val.i_int = config_GetInt( p_intf, "key-play-pause" );
- var_Set( p_intf->p_libvlc, "key-pressed", val );
+ var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE );
}
}
return nil;
}
+- (id)appleRemoteController
+{
+ return o_remote;
+}
+
#pragma mark -
#pragma mark Polling
id self = manage_cleanup_stack->self;
playlist_t * p_playlist = manage_cleanup_stack->p_playlist;
- var_AddCallback( p_playlist, "item-current", PlaylistChanged, self );
- var_AddCallback( p_playlist, "intf-change", PlaylistChanged, self );
- var_AddCallback( p_playlist, "item-change", PlaylistChanged, self );
- var_AddCallback( p_playlist, "playlist-item-append", PlaylistChanged, self );
- var_AddCallback( p_playlist, "playlist-item-deleted", PlaylistChanged, self );
+ var_DelCallback( p_playlist, "item-current", PlaylistChanged, self );
+ var_DelCallback( p_playlist, "intf-change", PlaylistChanged, self );
+ var_DelCallback( p_playlist, "item-change", PlaylistChanged, self );
+ var_DelCallback( p_playlist, "playlist-item-append", PlaylistChanged, self );
+ var_DelCallback( p_playlist, "playlist-item-deleted", PlaylistChanged, self );
pl_Release( p_intf );
- (void)manageVolumeSlider
{
audio_volume_t i_volume;
- aout_VolumeGet( p_intf, &i_volume );
+ playlist_t * p_playlist = pl_Hold( p_intf );
+
+ aout_VolumeGet( p_playlist, &i_volume );
+ pl_Release( p_intf );
if( i_volume != i_lastShownVolume )
{
[o_controls setupVarMenuItem: o_mi_deinterlace target: (vlc_object_t *)p_vout
var: "deinterlace" selector: @selector(toggleVar:)];
-#if 0
-/* FIXME Post processing. */
- p_dec_obj = (vlc_object_t *)vlc_object_find(
- (vlc_object_t *)p_vout,
- VLC_OBJECT_DECODER,
- FIND_PARENT );
- if( p_dec_obj != NULL )
- {
- [o_controls setupVarMenuItem: o_mi_ffmpeg_pp target:
- (vlc_object_t *)p_dec_obj var:"ffmpeg-pp-q" selector:
+#if 1
+ [o_controls setupVarMenuItem: o_mi_ffmpeg_pp target:
+ (vlc_object_t *)p_vout var:"postprocess" selector:
@selector(toggleVar:)];
- vlc_object_release(p_dec_obj);
- }
#endif
vlc_object_release( (vlc_object_t *)p_vout );
}
if( [o_msg_arr count] + 2 > 600 )
{
- [o_msg_arr removeObjectAtIndex: 0];
+ [o_msg_arr removeObjectAtIndex: 0];
[o_msg_arr removeObjectAtIndex: 1];
- }
+ }
o_attr = [NSDictionary dictionaryWithObject: o_gray
forKey: NSForegroundColorAttributeName];
@implementation VLCApplication
-- (void)sendEvent: (NSEvent*)event
+- (void)awakeFromNib
{
- if( [event type] == NSSystemDefined && [event subtype] == 8 )
- {
- int keyCode = (([event data1] & 0xFFFF0000) >> 16);
- int keyFlags = ([event data1] & 0x0000FFFF);
- int keyState = (((keyFlags & 0xFF00) >> 8)) == 0xA;
- int keyRepeat = (keyFlags & 0x1);
+ b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" );
+ [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(coreChangedMediaKeySupportSetting:) name: @"VLCMediaKeySupportSettingChanged" object: nil];
+}
- if( keyCode == NX_KEYTYPE_PLAY && keyState == 0 )
- var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE );
+- (void)dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver: self];
+ [super dealloc];
+}
- if( keyCode == NX_KEYTYPE_FAST && !b_justJumped )
- {
- if( keyState == 0 && keyRepeat == 0 )
- {
- var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_NEXT );
- }
- else if( keyRepeat == 1 )
- {
- var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_FORWARD_SHORT );
- b_justJumped = YES;
- [self performSelector:@selector(resetJump)
- withObject: NULL
- afterDelay:0.25];
- }
- }
+- (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification
+{
+ b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" );
+}
- if( keyCode == NX_KEYTYPE_REWIND && !b_justJumped )
- {
- if( keyState == 0 && keyRepeat == 0 )
- {
- var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_PREV );
- }
- else if( keyRepeat == 1 )
- {
- var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_BACKWARD_SHORT );
- b_justJumped = YES;
- [self performSelector:@selector(resetJump)
- withObject: NULL
- afterDelay:0.25];
- }
- }
+- (void)sendEvent: (NSEvent*)event
+{
+ if( b_mediaKeySupport )
+ {
+ if( [event type] == NSSystemDefined && [event subtype] == 8 )
+ {
+ int keyCode = (([event data1] & 0xFFFF0000) >> 16);
+ int keyFlags = ([event data1] & 0x0000FFFF);
+ int keyState = (((keyFlags & 0xFF00) >> 8)) == 0xA;
+ int keyRepeat = (keyFlags & 0x1);
+
+ if( keyCode == NX_KEYTYPE_PLAY && keyState == 0 )
+ var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE );
+
+ if( keyCode == NX_KEYTYPE_FAST && !b_justJumped )
+ {
+ if( keyState == 0 && keyRepeat == 0 )
+ {
+ var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_NEXT );
+ }
+ else if( keyRepeat == 1 )
+ {
+ var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_FORWARD_SHORT );
+ b_justJumped = YES;
+ [self performSelector:@selector(resetJump)
+ withObject: NULL
+ afterDelay:0.25];
+ }
+ }
+
+ if( keyCode == NX_KEYTYPE_REWIND && !b_justJumped )
+ {
+ if( keyState == 0 && keyRepeat == 0 )
+ {
+ var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_PREV );
+ }
+ else if( keyRepeat == 1 )
+ {
+ var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_BACKWARD_SHORT );
+ b_justJumped = YES;
+ [self performSelector:@selector(resetJump)
+ withObject: NULL
+ afterDelay:0.25];
+ }
+ }
+ }
}
[super sendEvent: event];
}