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];
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 );
/* 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 );
- (void)applicationDidBecomeActive:(NSNotification *)aNotification
{
if( !p_intf ) return;
-#ifndef __x86_64__
- [o_remote startListening: self];
-#endif
+ if( config_GetInt( p_intf, "macosx-appleremote" ) == YES )
+ [o_remote startListening: self];
}
- (void)applicationDidResignActive:(NSNotification *)aNotification
{
if( !p_intf ) return;
-#ifndef __x86_64__
[o_remote stopListening: self];
-#endif
}
/* Triggered when the computer goes to sleep */
return nil;
}
+- (id)appleRemoteController
+{
+ return o_remote;
+}
+
#pragma mark -
#pragma mark Polling
- (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 )
{
@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_active = b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" );
+ b_activeInBackground = config_GetInt( VLCIntf, "macosx-mediakeys-background" );
+ [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(coreChangedMediaKeySupportSetting:) name: @"VLCMediaKeySupportSettingChanged" object: nil];
+ [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(appGotActiveOrInactive:) name: @"NSApplicationDidBecomeActiveNotification" object: nil];
+ [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(appGotActiveOrInactive:) name: @"NSApplicationWillResignActiveNotification" 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)appGotActiveOrInactive: (NSNotification *)o_notification
+{
+ if(( [[o_notification name] isEqualToString: @"NSApplicationWillResignActiveNotification"] && !b_activeInBackground ) || !b_mediaKeySupport)
+ b_active = NO;
+ else
+ b_active = YES;
+}
- if( keyCode == NX_KEYTYPE_REWIND && !b_justJumped )
+- (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification
+{
+ b_active = b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" );
+ b_activeInBackground = config_GetInt( VLCIntf, "macosx-mediakeys-background" );
+}
+
+
+- (void)sendEvent: (NSEvent*)event
+{
+ if( b_active )
+ {
+ if( [event type] == NSSystemDefined && [event subtype] == 8 )
{
- if( keyState == 0 && keyRepeat == 0 )
+ 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 )
{
- var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_PREV );
+ 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];
+ }
}
- else if( keyRepeat == 1 )
+
+ if( keyCode == NX_KEYTYPE_REWIND && !b_justJumped )
{
- var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_JUMP_BACKWARD_SHORT );
- b_justJumped = YES;
- [self performSelector:@selector(resetJump)
- withObject: NULL
- afterDelay:0.25];
+ 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];
}