Commit a9ae88b7 authored by Rafaël Carré's avatar Rafaël Carré Committed by Felix Paul Kühne

OSX GUI: store the interface pointer to avoid multiple accesses.

It saves quite a bit of CPU time over when VLCIntf is accessed several times.
(cherry picked from commit a8a01ed0)
Signed-off-by: default avatarFelix Paul Kühne <fkuehne@videolan.org>
parent cb8e90f3
...@@ -118,8 +118,10 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -118,8 +118,10 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (void)toggleRecord - (void)toggleRecord
{ {
intf_thread_t *p_intf = VLCIntf;
input_thread_t * p_input; input_thread_t * p_input;
p_input = pl_CurrentInput( VLCIntf ); p_input = pl_CurrentInput( p_intf );
if( p_input ) if( p_input )
{ {
var_ToggleBool( p_input, "record" ); var_ToggleBool( p_input, "record" );
...@@ -142,8 +144,10 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -142,8 +144,10 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
{ {
float f_rate; float f_rate;
intf_thread_t *p_intf = VLCIntf;
input_thread_t * p_input; input_thread_t * p_input;
p_input = pl_CurrentInput( VLCIntf ); p_input = pl_CurrentInput( p_intf );
if (p_input) if (p_input)
{ {
f_rate = var_GetFloat( p_input, "rate" ); f_rate = var_GetFloat( p_input, "rate" );
...@@ -179,7 +183,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -179,7 +183,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (BOOL)isPlaying - (BOOL)isPlaying
{ {
input_thread_t * p_input = pl_CurrentInput( VLCIntf ); intf_thread_t *p_intf = VLCIntf;
input_thread_t * p_input = pl_CurrentInput( p_intf );
if (!p_input) return NO; if (!p_input) return NO;
...@@ -216,7 +222,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -216,7 +222,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (int)durationOfCurrentPlaylistItem - (int)durationOfCurrentPlaylistItem
{ {
input_thread_t * p_input = pl_CurrentInput( VLCIntf ); intf_thread_t *p_intf = VLCIntf;
input_thread_t * p_input = pl_CurrentInput( p_intf );
int64_t i_duration = -1; int64_t i_duration = -1;
if (!p_input) return i_duration; if (!p_input) return i_duration;
...@@ -229,7 +237,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -229,7 +237,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (NSURL*)URLOfCurrentPlaylistItem - (NSURL*)URLOfCurrentPlaylistItem
{ {
input_thread_t *p_input = pl_CurrentInput( VLCIntf ); intf_thread_t *p_intf = VLCIntf;
input_thread_t *p_input = pl_CurrentInput( p_intf );
if (!p_input) return nil; if (!p_input) return nil;
input_item_t *p_item = input_GetItem( p_input ); input_item_t *p_item = input_GetItem( p_input );
...@@ -255,7 +265,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -255,7 +265,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (NSString*)nameOfCurrentPlaylistItem - (NSString*)nameOfCurrentPlaylistItem
{ {
input_thread_t *p_input = pl_CurrentInput( VLCIntf ); intf_thread_t *p_intf = VLCIntf;
input_thread_t *p_input = pl_CurrentInput( p_intf );
if (!p_input) return nil; if (!p_input) return nil;
input_item_t *p_item = input_GetItem( p_input ); input_item_t *p_item = input_GetItem( p_input );
...@@ -347,8 +359,10 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -347,8 +359,10 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (void)shuffle - (void)shuffle
{ {
intf_thread_t *p_intf = VLCIntf;
vlc_value_t val; vlc_value_t val;
playlist_t * p_playlist = pl_Get( VLCIntf ); playlist_t * p_playlist = pl_Get( p_intf );
vout_thread_t *p_vout = getVout(); vout_thread_t *p_vout = getVout();
var_Get( p_playlist, "random", &val ); var_Get( p_playlist, "random", &val );
...@@ -376,7 +390,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -376,7 +390,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (void)repeatAll - (void)repeatAll
{ {
playlist_t * p_playlist = pl_Get( VLCIntf ); intf_thread_t *p_intf = VLCIntf;
playlist_t * p_playlist = pl_Get( p_intf );
var_SetBool( p_playlist, "repeat", NO ); var_SetBool( p_playlist, "repeat", NO );
var_SetBool( p_playlist, "loop", YES ); var_SetBool( p_playlist, "loop", YES );
...@@ -393,7 +409,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -393,7 +409,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (void)repeatOne - (void)repeatOne
{ {
playlist_t * p_playlist = pl_Get( VLCIntf ); intf_thread_t *p_intf = VLCIntf;
playlist_t * p_playlist = pl_Get( p_intf );
var_SetBool( p_playlist, "repeat", YES ); var_SetBool( p_playlist, "repeat", YES );
var_SetBool( p_playlist, "loop", NO ); var_SetBool( p_playlist, "loop", NO );
...@@ -410,7 +428,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -410,7 +428,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (void)repeatOff - (void)repeatOff
{ {
playlist_t * p_playlist = pl_Get( VLCIntf ); intf_thread_t *p_intf = VLCIntf;
playlist_t * p_playlist = pl_Get( p_intf );
var_SetBool( p_playlist, "repeat", NO ); var_SetBool( p_playlist, "repeat", NO );
var_SetBool( p_playlist, "loop", NO ); var_SetBool( p_playlist, "loop", NO );
...@@ -427,46 +447,49 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -427,46 +447,49 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (void)volumeUp - (void)volumeUp
{ {
playlist_t * p_playlist = pl_Get( VLCIntf ); intf_thread_t *p_intf = VLCIntf;
aout_VolumeUp( p_playlist, 1, NULL );
aout_VolumeUp( pl_Get( p_intf ), 1, NULL );
} }
- (void)volumeDown - (void)volumeDown
{ {
playlist_t * p_playlist = pl_Get( VLCIntf ); intf_thread_t *p_intf = VLCIntf;
aout_VolumeDown( p_playlist, 1, NULL );
aout_VolumeDown( pl_Get( p_intf ), 1, NULL );
} }
- (void)mute - (void)mute
{ {
playlist_t * p_playlist = pl_Get( VLCIntf ); intf_thread_t *p_intf = VLCIntf;
aout_ToggleMute( p_playlist, NULL );
aout_ToggleMute( pl_Get( p_intf ), NULL );
} }
- (BOOL)isMuted - (BOOL)isMuted
{ {
playlist_t * p_playlist = pl_Get( VLCIntf ); intf_thread_t *p_intf = VLCIntf;
BOOL b_is_muted = NO; BOOL b_is_muted = NO;
b_is_muted = aout_IsMuted( VLC_OBJECT(p_playlist) ); b_is_muted = aout_IsMuted( VLC_OBJECT(pl_Get( p_intf )) );
return b_is_muted; return b_is_muted;
} }
- (int)volume - (int)volume
{ {
intf_thread_t * p_intf = VLCIntf; intf_thread_t *p_intf = VLCIntf;
playlist_t * p_playlist = pl_Get( VLCIntf );
audio_volume_t i_volume = aout_VolumeGet( p_playlist ); audio_volume_t i_volume = aout_VolumeGet( pl_Get( p_intf ) );
return (int)i_volume; return (int)i_volume;
} }
- (void)setVolume: (int)i_value - (void)setVolume: (int)i_value
{ {
intf_thread_t * p_intf = VLCIntf; intf_thread_t *p_intf = VLCIntf;
playlist_t * p_playlist = pl_Get( VLCIntf );
aout_VolumeSet( p_playlist, i_value ); aout_VolumeSet( pl_Get( p_intf ), i_value );
} }
#pragma mark - #pragma mark -
...@@ -484,8 +507,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -484,8 +507,9 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (void)toggleFullscreen - (void)toggleFullscreen
{ {
playlist_t * p_playlist = pl_Get( VLCIntf ); intf_thread_t *p_intf = VLCIntf;
var_ToggleBool( p_playlist, "fullscreen" );
var_ToggleBool( pl_Get( p_intf ), "fullscreen" );
} }
@end @end
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