Commit e5d609fd authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: remove 2 interface update timers (2 threads), 1 additional interface...

macosx: remove 2 interface update timers (2 threads), 1 additional interface update thread and replaced everything by callbacks
parent 4e33295f
...@@ -179,9 +179,6 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -179,9 +179,6 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
//vout_OSDMessage( VLCIntf, SPU_DEFAULT_CHANNEL, "%s", _( "Random Off" ) ); //vout_OSDMessage( VLCIntf, SPU_DEFAULT_CHANNEL, "%s", _( "Random Off" ) );
config_PutInt( p_playlist, "random", 0 ); config_PutInt( p_playlist, "random", 0 );
} }
VLCIntf->p_sys->b_playmode_update = true;
VLCIntf->p_sys->b_intf_update = true;
} }
- (void)repeatAll - (void)repeatAll
...@@ -194,9 +191,6 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -194,9 +191,6 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
config_PutInt( p_playlist, "loop", YES ); config_PutInt( p_playlist, "loop", YES );
//vout_OSDMessage( VLCIntf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat All" ) ); //vout_OSDMessage( VLCIntf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat All" ) );
VLCIntf->p_sys->b_playmode_update = true;
VLCIntf->p_sys->b_intf_update = true;
} }
- (void)repeatOne - (void)repeatOne
...@@ -209,9 +203,6 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -209,9 +203,6 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
config_PutInt( p_playlist, "loop", NO ); config_PutInt( p_playlist, "loop", NO );
//vout_OSDMessage( VLCIntf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat One" ) ); //vout_OSDMessage( VLCIntf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat One" ) );
VLCIntf->p_sys->b_playmode_update = true;
VLCIntf->p_sys->b_intf_update = true;
} }
- (void)repeatOff - (void)repeatOff
...@@ -224,9 +215,6 @@ static VLCCoreInteraction *_o_sharedInstance = nil; ...@@ -224,9 +215,6 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
config_PutInt( p_playlist, "loop", NO ); config_PutInt( p_playlist, "loop", NO );
//vout_OSDMessage( VLCIntf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat Off" ) ); //vout_OSDMessage( VLCIntf, SPU_DEFAULT_CHANNEL, "%s", _( "Repeat Off" ) );
VLCIntf->p_sys->b_playmode_update = true;
VLCIntf->p_sys->b_intf_update = true;
} }
// CAVE: [o_main manageVolumeSlider] // CAVE: [o_main manageVolumeSlider]
......
...@@ -207,6 +207,7 @@ ...@@ -207,6 +207,7 @@
- (IBAction)intfOpenCapture:(id)sender; - (IBAction)intfOpenCapture:(id)sender;
- (IBAction)setPlaybackRate:(id)sender; - (IBAction)setPlaybackRate:(id)sender;
- (void)updatePlaybackRate;
- (IBAction)showWizard:(id)sender; - (IBAction)showWizard:(id)sender;
- (IBAction)showVideoEffects:(id)sender; - (IBAction)showVideoEffects:(id)sender;
...@@ -228,6 +229,10 @@ ...@@ -228,6 +229,10 @@
- (void)setPlay; - (void)setPlay;
- (void)setPause; - (void)setPause;
- (void)setRepeatOne;
- (void)setRepeatAll;
- (void)setRepeatOff;
- (void)setShuffle;
- (IBAction)toggleVar:(id)sender; - (IBAction)toggleVar:(id)sender;
- (int)toggleVarThread:(id)_o_data; - (int)toggleVarThread:(id)_o_data;
......
...@@ -549,6 +549,14 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -549,6 +549,14 @@ static VLCMainMenu *_o_sharedInstance = nil;
[o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%ix", i]]; [o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%ix", i]];
} }
- (void)updatePlaybackRate
{
int i = [[VLCCoreInteraction sharedInstance] playbackRate];
if (i == 0)
i = 1;
[o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%ix", i]];
[o_mi_rate_sld setIntValue: i];
}
#pragma mark - #pragma mark -
#pragma mark Panels #pragma mark Panels
...@@ -721,6 +729,32 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -721,6 +729,32 @@ static VLCMainMenu *_o_sharedInstance = nil;
[o_vmi_play setTitle: _NS("Pause")]; [o_vmi_play setTitle: _NS("Pause")];
} }
- (void)setRepeatOne
{
[o_mi_repeat setState: NSOnState];
[o_mi_loop setState: NSOffState];
}
- (void)setRepeatAll
{
[o_mi_repeat setState: NSOffState];
[o_mi_loop setState: NSOnState];
}
- (void)setRepeatOff
{
[o_mi_repeat setState: NSOffState];
[o_mi_loop setState: NSOffState];
}
- (void)setShuffle
{
bool b_value;
playlist_t *p_playlist = pl_Get( VLCIntf );
b_value = var_GetBool( p_playlist, "random" );
[o_mi_random setState: b_value];
}
#pragma mark - #pragma mark -
#pragma mark Dynamic menu creation and validation #pragma mark Dynamic menu creation and validation
......
...@@ -95,7 +95,12 @@ ...@@ -95,7 +95,12 @@
- (void)updateTimeSlider; - (void)updateTimeSlider;
- (void)updateVolumeSlider; - (void)updateVolumeSlider;
- (void)updateWindow; - (void)updateWindow;
- (void)updateTitle;
- (void)setPause; - (void)setPause;
- (void)setPlay; - (void)setPlay;
- (void)setRepeatOne;
- (void)setRepeatAll;
- (void)setRepeatOff;
- (void)setShuffle;
@end @end
\ No newline at end of file
...@@ -255,6 +255,24 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -255,6 +255,24 @@ static VLCMainWindow *_o_sharedInstance = nil;
} }
} }
- (void)setRepeatOne
{
[o_repeat_btn setImage: o_repeat_one_img];
[o_repeat_btn setAlternateImage: o_repeat_one_pressed_img];
}
- (void)setRepeatAll
{
[o_repeat_btn setImage: o_repeat_all_img];
[o_repeat_btn setAlternateImage: o_repeat_all_pressed_img];
}
- (void)setRepeatOff
{
[o_repeat_btn setImage: o_repeat_img];
[o_repeat_btn setAlternateImage: o_repeat_pressed_img];
}
- (IBAction)repeat:(id)sender - (IBAction)repeat:(id)sender
{ {
vlc_value_t looping,repeating; vlc_value_t looping,repeating;
...@@ -268,36 +286,28 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -268,36 +286,28 @@ static VLCMainWindow *_o_sharedInstance = nil;
{ {
/* was: no repeating at all, switching to Repeat One */ /* was: no repeating at all, switching to Repeat One */
[[VLCCoreInteraction sharedInstance] repeatOne]; [[VLCCoreInteraction sharedInstance] repeatOne];
[self setRepeatOne];
[o_repeat_btn setImage: o_repeat_one_img];
[o_repeat_btn setAlternateImage: o_repeat_one_pressed_img];
} }
else if( repeating.b_bool && !looping.b_bool ) else if( repeating.b_bool && !looping.b_bool )
{ {
/* was: Repeat One, switching to Repeat All */ /* was: Repeat One, switching to Repeat All */
[[VLCCoreInteraction sharedInstance] repeatAll]; [[VLCCoreInteraction sharedInstance] repeatAll];
[self setRepeatAll];
[o_repeat_btn setImage: o_repeat_all_img];
[o_repeat_btn setAlternateImage: o_repeat_all_pressed_img];
} }
else else
{ {
/* was: Repeat All or bug in VLC, switching to Repeat Off */ /* was: Repeat All or bug in VLC, switching to Repeat Off */
[[VLCCoreInteraction sharedInstance] repeatOff]; [[VLCCoreInteraction sharedInstance] repeatOff];
[self setRepeatOff];
[o_repeat_btn setImage: o_repeat_img];
[o_repeat_btn setAlternateImage: o_repeat_pressed_img];
} }
} }
- (IBAction)shuffle:(id)sender - (void)setShuffle
{ {
[[VLCCoreInteraction sharedInstance] shuffle]; bool b_value;
vlc_value_t val;
playlist_t *p_playlist = pl_Get( VLCIntf ); playlist_t *p_playlist = pl_Get( VLCIntf );
var_Get( p_playlist, "random", &val ); b_value = var_GetBool( p_playlist, "random" );
if(val.b_bool) { if(b_value) {
[o_shuffle_btn setImage: o_shuffle_on_img]; [o_shuffle_btn setImage: o_shuffle_on_img];
[o_shuffle_btn setAlternateImage: o_shuffle_on_pressed_img]; [o_shuffle_btn setAlternateImage: o_shuffle_on_pressed_img];
} }
...@@ -308,6 +318,12 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -308,6 +318,12 @@ static VLCMainWindow *_o_sharedInstance = nil;
} }
} }
- (IBAction)shuffle:(id)sender
{
[[VLCCoreInteraction sharedInstance] shuffle];
[self setShuffle];
}
- (IBAction)timeSliderAction:(id)sender - (IBAction)timeSliderAction:(id)sender
{ {
float f_updated; float f_updated;
...@@ -383,35 +399,32 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -383,35 +399,32 @@ static VLCMainWindow *_o_sharedInstance = nil;
#pragma mark Update interface and respond to foreign events #pragma mark Update interface and respond to foreign events
- (void)updateTimeSlider - (void)updateTimeSlider
{ {
if ([o_time_sld isEnabled]) input_thread_t * p_input;
p_input = pl_CurrentInput( VLCIntf );
if( p_input )
{ {
input_thread_t * p_input; vlc_value_t time;
p_input = pl_CurrentInput( VLCIntf ); NSString * o_time;
if( p_input ) vlc_value_t pos;
char psz_time[MSTRTIME_MAX_SIZE];
float f_updated;
var_Get( p_input, "position", &pos );
f_updated = 10000. * pos.f_float;
[o_time_sld setFloatValue: f_updated];
var_Get( p_input, "time", &time );
mtime_t dur = input_item_GetDuration( input_GetItem( p_input ) );
if( b_time_remaining && dur != -1 )
{ {
vlc_value_t time; o_time = [NSString stringWithFormat: @"-%s", secstotimestr( psz_time, ((dur - time.i_time) / 1000000))];
NSString * o_time;
vlc_value_t pos;
char psz_time[MSTRTIME_MAX_SIZE];
float f_updated;
var_Get( p_input, "position", &pos );
f_updated = 10000. * pos.f_float;
[o_time_sld setFloatValue: f_updated];
var_Get( p_input, "time", &time );
mtime_t dur = input_item_GetDuration( input_GetItem( p_input ) );
if( b_time_remaining && dur != -1 )
{
o_time = [NSString stringWithFormat: @"-%s", secstotimestr( psz_time, ((dur - time.i_time) / 1000000))];
}
else
o_time = [NSString stringWithUTF8String: secstotimestr( psz_time, (time.i_time / 1000000) )];
[o_time_fld setStringValue: o_time];
// [[[[VLCMain sharedInstance] controls] fspanel] setStreamPos: f_updated andTime: o_time];
} }
else
o_time = [NSString stringWithUTF8String: secstotimestr( psz_time, (time.i_time / 1000000) )];
[o_time_fld setStringValue: o_time];
// [[[[VLCMain sharedInstance] controls] fspanel] setStreamPos: f_updated andTime: o_time];
} }
} }
...@@ -432,6 +445,29 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -432,6 +445,29 @@ static VLCMainWindow *_o_sharedInstance = nil;
} }
} }
- (void)updateTitle
{
input_thread_t * p_input;
p_input = pl_CurrentInput( VLCIntf );
if( p_input )
{
NSString *aString;
input_item_t * p_item = input_GetItem( p_input );
char * name = input_item_GetNowPlaying( p_item );
if( !name )
name = input_item_GetName( p_item );
aString = [NSString stringWithUTF8String:name];
free(name);
[self setTitle: aString];
[[[[VLCMain sharedInstance] controls] fspanel] setStreamTitle: aString];
}
}
- (void)updateWindow - (void)updateWindow
{ {
bool b_input = false; bool b_input = false;
...@@ -483,10 +519,9 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -483,10 +519,9 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_bwd_btn setEnabled: (b_seekable || b_plmul || b_chapters)]; [o_bwd_btn setEnabled: (b_seekable || b_plmul || b_chapters)];
[[VLCMainMenu sharedInstance] setRateControlsEnabled: b_control]; [[VLCMainMenu sharedInstance] setRateControlsEnabled: b_control];
[o_time_sld setFloatValue: 0.0];
[o_time_sld setEnabled: b_seekable]; [o_time_sld setEnabled: b_seekable];
[o_time_fld setStringValue: @"0:00:00"]; [self updateTimeSlider];
[[[[VLCMain sharedInstance] controls] fspanel] setStreamPos: 0 andTime: @"0:00:00"];
[[[[VLCMain sharedInstance] controls] fspanel] setSeekable: b_seekable]; [[[[VLCMain sharedInstance] controls] fspanel] setSeekable: b_seekable];
} }
......
...@@ -33,11 +33,6 @@ ...@@ -33,11 +33,6 @@
{ {
IBOutlet id o_main; IBOutlet id o_main;
IBOutlet id o_volumeslider;
IBOutlet id o_btn_repeat;
IBOutlet id o_btn_shuffle;
IBOutlet id o_specificTime_cancel_btn; IBOutlet id o_specificTime_cancel_btn;
IBOutlet id o_specificTime_enter_fld; IBOutlet id o_specificTime_enter_fld;
IBOutlet id o_specificTime_goTo_lbl; IBOutlet id o_specificTime_goTo_lbl;
...@@ -51,16 +46,12 @@ ...@@ -51,16 +46,12 @@
} }
- (IBAction)play:(id)sender; - (IBAction)play:(id)sender;
- (IBAction)stop:(id)sender; - (IBAction)stop:(id)sender;
- (IBAction)faster:(id)sender;
- (IBAction)slower:(id)sender;
- (IBAction)normalSpeed:(id)sender;
- (IBAction)prev:(id)sender; - (IBAction)prev:(id)sender;
- (IBAction)next:(id)sender; - (IBAction)next:(id)sender;
- (IBAction)random:(id)sender; - (IBAction)random:(id)sender;
- (IBAction)repeat:(id)sender; - (IBAction)repeat:(id)sender;
- (IBAction)loop:(id)sender; - (IBAction)loop:(id)sender;
- (IBAction)repeatButtonAction:(id)sender;
- (IBAction)quitAfterPlayback:(id)sender; - (IBAction)quitAfterPlayback:(id)sender;
- (IBAction)forward:(id)sender; - (IBAction)forward:(id)sender;
......
...@@ -80,21 +80,6 @@ ...@@ -80,21 +80,6 @@
[[VLCCoreInteraction sharedInstance] stop]; [[VLCCoreInteraction sharedInstance] stop];
} }
- (IBAction)faster:(id)sender
{
[[VLCCoreInteraction sharedInstance] faster];
}
- (IBAction)slower:(id)sender
{
[[VLCCoreInteraction sharedInstance] slower];
}
- (IBAction)normalSpeed:(id)sender
{
[[VLCCoreInteraction sharedInstance] normalSpeed];
}
- (IBAction)prev:(id)sender - (IBAction)prev:(id)sender
{ {
[[VLCCoreInteraction sharedInstance] previous]; [[VLCCoreInteraction sharedInstance] previous];
...@@ -108,57 +93,8 @@ ...@@ -108,57 +93,8 @@
- (IBAction)random:(id)sender - (IBAction)random:(id)sender
{ {
[[VLCCoreInteraction sharedInstance] shuffle]; [[VLCCoreInteraction sharedInstance] shuffle];
vlc_value_t val;
playlist_t *p_playlist = pl_Get( VLCIntf );
var_Get( p_playlist, "random", &val );
if(val.b_bool) {
[o_btn_shuffle setImage: [NSImage imageNamed:@"shuffle-on"]];
[o_btn_shuffle setAlternateImage: [NSImage imageNamed:@"shuffle-blue-pressed"]];
}
else
{
[o_btn_shuffle setImage: [NSImage imageNamed:@"shuffle"]];
[o_btn_shuffle setAlternateImage: [NSImage imageNamed:@"shuffle-pressed"]];
}
} }
- (IBAction)repeatButtonAction:(id)sender
{
vlc_value_t looping,repeating;
intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = pl_Get( p_intf );
var_Get( p_playlist, "repeat", &repeating );
var_Get( p_playlist, "loop", &looping );
if( !repeating.b_bool && !looping.b_bool )
{
/* was: no repeating at all, switching to Repeat One */
[[VLCCoreInteraction sharedInstance] repeatOne];
[o_btn_repeat setImage: [NSImage imageNamed:@"repeat-one"]];
[o_btn_repeat setAlternateImage: [NSImage imageNamed:@"repeat-one-pressed"]];
}
else if( repeating.b_bool && !looping.b_bool )
{
/* was: Repeat One, switching to Repeat All */
[[VLCCoreInteraction sharedInstance] repeatAll];
[o_btn_repeat setImage: [NSImage imageNamed:@"repeat-all"]];
[o_btn_repeat setAlternateImage: [NSImage imageNamed:@"repeat-all-pressed"]];
}
else
{
/* was: Repeat All or bug in VLC, switching to Repeat Off */
[[VLCCoreInteraction sharedInstance] repeatOff];
[o_btn_repeat setImage: [NSImage imageNamed:@"repeat"]];
[o_btn_repeat setAlternateImage: [NSImage imageNamed:@"repeat-pressed"]];
}
}
- (IBAction)repeat:(id)sender - (IBAction)repeat:(id)sender
{ {
vlc_value_t val; vlc_value_t val;
...@@ -202,7 +138,6 @@ ...@@ -202,7 +138,6 @@
[[VLCCoreInteraction sharedInstance] backward]; [[VLCCoreInteraction sharedInstance] backward];
} }
- (IBAction)volumeUp:(id)sender - (IBAction)volumeUp:(id)sender
{ {
[[VLCCoreInteraction sharedInstance] volumeUp]; [[VLCCoreInteraction sharedInstance] volumeUp];
......
...@@ -66,16 +66,6 @@ aout_instance_t *getAout(void); ...@@ -66,16 +66,6 @@ aout_instance_t *getAout(void);
*****************************************************************************/ *****************************************************************************/
struct intf_sys_t struct intf_sys_t
{ {
/* special actions */
int i_play_status;
int i_old_play_status;
/* interface update */
bool b_intf_update;
bool b_playlist_update;
bool b_playmode_update;
bool b_current_title_update;
/* menus handlers */ /* menus handlers */
bool b_input_update; bool b_input_update;
bool b_aout_update; bool b_aout_update;
...@@ -141,12 +131,6 @@ struct intf_sys_t ...@@ -141,12 +131,6 @@ struct intf_sys_t
input_state_e cachedInputState; input_state_e cachedInputState;
/* the manage thread */
pthread_t manage_thread;
/* The timer that update the interface */
NSTimer * interfaceTimer;
NSURLConnection * crashLogURLConnection; NSURLConnection * crashLogURLConnection;
AppleRemote * o_remote; AppleRemote * o_remote;
...@@ -187,15 +171,20 @@ struct intf_sys_t ...@@ -187,15 +171,20 @@ struct intf_sys_t
- (NSString *)VLCKeyToString:(NSString *)theString; - (NSString *)VLCKeyToString:(NSString *)theString;
- (unsigned int)VLCModifiersToCocoa:(NSString *)theString; - (unsigned int)VLCModifiersToCocoa:(NSString *)theString;
- (void)updateCurrentlyUsedHotkeys; - (void)updateCurrentlyUsedHotkeys;
- (void)PlaylistItemChanged;
- (void)playbackStatusUpdated;
- (void)playbackModeUpdated;
- (void)updateVolume;
- (void)updatePlaybackPosition;
- (void)updateTitle;
- (void)playlistUpdated;
- (void)updateInfoandMetaPanel;
- (void)updateMainWindow;
- (void)initStrings; - (void)initStrings;
- (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename; - (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename;
- (void)manage;
- (void)manageIntf:(NSTimer *)o_timer;
- (void)updateMessageDisplay; - (void)updateMessageDisplay;
- (void)playStatusUpdated:(int) i_status;
- (IBAction)showController:(id)sender; - (IBAction)showController:(id)sender;
- (IBAction)crashReporterAction:(id)sender; - (IBAction)crashReporterAction:(id)sender;
......
...@@ -66,14 +66,23 @@ ...@@ -66,14 +66,23 @@
*****************************************************************************/ *****************************************************************************/
static void Run ( intf_thread_t *p_intf ); static void Run ( intf_thread_t *p_intf );
static void * ManageThread( void *user_data );
static void updateProgressPanel (void *, const char *, float); static void updateProgressPanel (void *, const char *, float);
static bool checkProgressPanel (void *); static bool checkProgressPanel (void *);
static void destroyProgressPanel (void *); static void destroyProgressPanel (void *);
static void MsgCallback( msg_cb_data_t *, const msg_item_t * ); static void MsgCallback( msg_cb_data_t *, const msg_item_t * );
static int InputEvent( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int PLItemChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int PlaylistUpdated( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int PlaybackModeUpdated( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int VolumeUpdated( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
#pragma mark - #pragma mark -
#pragma mark VLC Interface Object Callbacks #pragma mark VLC Interface Object Callbacks
...@@ -175,7 +184,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -175,7 +184,7 @@ static void Run( intf_thread_t *p_intf )
/* Make sure the "force quit" menu item does quit instantly. /* Make sure the "force quit" menu item does quit instantly.
* VLC overrides SIGTERM which is sent by the "force quit" * VLC overrides SIGTERM which is sent by the "force quit"
* menu item to make sure deamon mode quits gracefully, so * menu item to make sure daemon mode quits gracefully, so
* we un-override SIGTERM here. */ * we un-override SIGTERM here. */
sigemptyset( &set ); sigemptyset( &set );
sigaddset( &set, SIGTERM ); sigaddset( &set, SIGTERM );
...@@ -219,22 +228,106 @@ static void MsgCallback( msg_cb_data_t *data, const msg_item_t *item ) ...@@ -219,22 +228,106 @@ static void MsgCallback( msg_cb_data_t *data, const msg_item_t *item )
vlc_restorecancel( canc ); vlc_restorecancel( canc );
} }
/***************************************************************************** static int InputEvent( vlc_object_t *p_this, const char *psz_var,
* playlistChanged: Callback triggered by the intf-change playlist vlc_value_t oldval, vlc_value_t new_val, void *param )
* variable, to let the intf update the playlist.
*****************************************************************************/
static int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void *param )
{ {
intf_thread_t * p_intf = VLCIntf; switch (new_val.i_int) {
if( p_intf && p_intf->p_sys ) case INPUT_EVENT_STATE:
{ [[VLCMain sharedInstance] playbackStatusUpdated];
NSLog( @"event from %s", psz_variable ); break;
p_intf->p_sys->b_intf_update = true; case INPUT_EVENT_RATE:
p_intf->p_sys->b_playlist_update = true; [[VLCMainMenu sharedInstance] performSelectorOnMainThread:@selector(updatePlaybackRate) withObject: nil waitUntilDone:NO];
p_intf->p_sys->b_playmode_update = true; break;
p_intf->p_sys->b_current_title_update = true; case INPUT_EVENT_POSITION:
[[VLCMain sharedInstance] updatePlaybackPosition];
break;
case INPUT_EVENT_TITLE:
case INPUT_EVENT_CHAPTER:
[[VLCMain sharedInstance] updateTitle];
break;
case INPUT_EVENT_CACHE:
[[VLCMain sharedInstance] updateMainWindow];
break;
case INPUT_EVENT_STATISTICS:
[[[VLCMain sharedInstance] info] performSelectorOnMainThread:@selector(updateStatistics) withObject: nil waitUntilDone: NO];
break;
case INPUT_EVENT_ES:
break;
case INPUT_EVENT_TELETEXT:
NSLog( @"teletext" );
break;
case INPUT_EVENT_AOUT:
break;
case INPUT_EVENT_VOUT:
break;
case INPUT_EVENT_ITEM_META:
case INPUT_EVENT_ITEM_INFO:
[[VLCMain sharedInstance] updateInfoandMetaPanel];
break;
case INPUT_EVENT_BOOKMARK:
break;
case INPUT_EVENT_RECORD:
break;
case INPUT_EVENT_PROGRAM:
break;
case INPUT_EVENT_ITEM_EPG:
break;
case INPUT_EVENT_SIGNAL:
break;
case INPUT_EVENT_ITEM_NAME:
[[VLCMain sharedInstance] updateTitle];
break;
case INPUT_EVENT_AUDIO_DELAY:
case INPUT_EVENT_SUBTITLE_DELAY:
break;
case INPUT_EVENT_DEAD:
//NSLog( @"dying input" );
break;
case INPUT_EVENT_ABORT:
//NSLog( @"input stopped by user" );
break;
default:
//msg_Warn( p_this, "unhandled input event (%lld)", new_val.i_int );
break;
} }
return VLC_SUCCESS;
}
static int PLItemChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param )
{
[[VLCMain sharedInstance] performSelectorOnMainThread:@selector(PlaylistItemChanged) withObject:nil waitUntilDone:NO];
return VLC_SUCCESS;
}
static int PlaylistUpdated( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param )
{
[[VLCMain sharedInstance] performSelectorOnMainThread:@selector(playlistUpdated) withObject:nil waitUntilDone:NO];
return VLC_SUCCESS;
}
static int PlaybackModeUpdated( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param )
{
[[VLCMain sharedInstance] playbackModeUpdated];
return VLC_SUCCESS;
}
static int VolumeUpdated( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param )
{
[[VLCMain sharedInstance] updateVolume];
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -437,6 +530,17 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -437,6 +530,17 @@ static VLCMain *_o_sharedMainInstance = nil;
var_AddCallback( p_playlist, "fullscreen", FullscreenChanged, self); var_AddCallback( p_playlist, "fullscreen", FullscreenChanged, self);
var_AddCallback( p_intf->p_libvlc, "intf-show", ShowController, self); var_AddCallback( p_intf->p_libvlc, "intf-show", ShowController, self);
// var_AddCallback(p_playlist, "item-change", PLItemChanged, self);
var_AddCallback(p_playlist, "item-current", PLItemChanged, self);
var_AddCallback(p_playlist, "activity", PLItemChanged, self);
var_AddCallback(p_playlist, "leaf-to-parent", PlaylistUpdated, self);
var_AddCallback(p_playlist, "playlist-item-append", PlaylistUpdated, self);
var_AddCallback(p_playlist, "playlist-item-deleted", PlaylistUpdated, self);
var_AddCallback(p_playlist, "random", PlaybackModeUpdated, self);
var_AddCallback(p_playlist, "repeat", PlaybackModeUpdated, self);
var_AddCallback(p_playlist, "loop", PlaybackModeUpdated, self);
var_AddCallback(p_playlist, "volume", VolumeUpdated, self);
var_AddCallback(p_playlist, "mute", VolumeUpdated, self);
/* load our Core Dialogs nib */ /* load our Core Dialogs nib */
nib_coredialogs_loaded = [NSBundle loadNibNamed:@"CoreDialogs" owner: NSApp]; nib_coredialogs_loaded = [NSBundle loadNibNamed:@"CoreDialogs" owner: NSApp];
...@@ -454,8 +558,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -454,8 +558,7 @@ static VLCMain *_o_sharedMainInstance = nil;
var_AddCallback( p_intf, "dialog-progress-bar", DialogCallback, self ); var_AddCallback( p_intf, "dialog-progress-bar", DialogCallback, self );
dialog_Register( p_intf ); dialog_Register( p_intf );
/* update the playmode stuff */ [self playbackModeUpdated];
p_intf->p_sys->b_playmode_update = true;
/* init Apple Remote support */ /* init Apple Remote support */
o_remote = [[AppleRemote alloc] init]; o_remote = [[AppleRemote alloc] init];
...@@ -466,19 +569,6 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -466,19 +569,6 @@ static VLCMain *_o_sharedMainInstance = nil;
nib_main_loaded = TRUE; nib_main_loaded = TRUE;
} }
- (void)applicationWillFinishLaunching:(NSNotification *)o_notification
{
if( !p_intf ) return;
/* FIXME: don't poll */
interfaceTimer = [[NSTimer scheduledTimerWithTimeInterval: 0.5
target: self selector: @selector(manageIntf:)
userInfo: nil repeats: FALSE] retain];
/* Note: we use the pthread API to support pre-10.5 */
pthread_create( &manage_thread, NULL, ManageThread, self );
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{ {
if( !p_intf ) return; if( !p_intf ) return;
...@@ -550,15 +640,9 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -550,15 +640,9 @@ static VLCMain *_o_sharedMainInstance = nil;
msg_Dbg( p_intf, "Terminating" ); msg_Dbg( p_intf, "Terminating" );
pthread_join( manage_thread, NULL );
/* Make sure the intf object is getting killed */ /* Make sure the intf object is getting killed */
vlc_object_kill( p_intf ); vlc_object_kill( p_intf );
p_playlist = pl_Get( p_intf );
/* Make sure the interfaceTimer is destroyed */
[interfaceTimer invalidate];
[interfaceTimer release];
interfaceTimer = nil;
/* unsubscribe from the interactive dialogues */ /* unsubscribe from the interactive dialogues */
dialog_Unregister( p_intf ); dialog_Unregister( p_intf );
...@@ -567,6 +651,17 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -567,6 +651,17 @@ static VLCMain *_o_sharedMainInstance = nil;
var_DelCallback( p_intf, "dialog-login", DialogCallback, self ); var_DelCallback( p_intf, "dialog-login", DialogCallback, self );
var_DelCallback( p_intf, "dialog-question", DialogCallback, self ); var_DelCallback( p_intf, "dialog-question", DialogCallback, self );
var_DelCallback( p_intf, "dialog-progress-bar", DialogCallback, self ); var_DelCallback( p_intf, "dialog-progress-bar", DialogCallback, self );
//var_DelCallback(p_playlist, "item-change", PLItemChanged, self);
var_DelCallback(p_playlist, "item-current", PLItemChanged, self);
var_DelCallback(p_playlist, "activity", PLItemChanged, self);
var_DelCallback(p_playlist, "leaf-to-parent", PlaylistUpdated, self);
var_DelCallback(p_playlist, "playlist-item-append", PlaylistUpdated, self);
var_DelCallback(p_playlist, "playlist-item-deleted", PlaylistUpdated, self);
var_DelCallback(p_playlist, "random", PlaybackModeUpdated, self);
var_DelCallback(p_playlist, "repeat", PlaybackModeUpdated, self);
var_DelCallback(p_playlist, "loop", PlaybackModeUpdated, self);
var_DelCallback(p_playlist, "volume", VolumeUpdated, self);
var_DelCallback(p_playlist, "mute", VolumeUpdated, self);
/* remove global observer watching for vout device changes correctly */ /* remove global observer watching for vout device changes correctly */
[[NSNotificationCenter defaultCenter] removeObserver: self]; [[NSNotificationCenter defaultCenter] removeObserver: self];
...@@ -582,10 +677,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -582,10 +677,7 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_open release]; [o_open release];
if( o_info ) if( o_info )
{
[o_info stopTimers];
[o_info release]; [o_info release];
}
if( o_wizard ) if( o_wizard )
[o_wizard release]; [o_wizard release];
...@@ -615,7 +707,6 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -615,7 +707,6 @@ static VLCMain *_o_sharedMainInstance = nil;
/* Kill the playlist, so that it doesn't accept new request /* Kill the playlist, so that it doesn't accept new request
* such as the play request from vlc.c (we are a blocking interface). */ * such as the play request from vlc.c (we are a blocking interface). */
p_playlist = pl_Get( p_intf );
vlc_object_kill( p_playlist ); vlc_object_kill( p_playlist );
libvlc_Quit( p_intf->p_libvlc ); libvlc_Quit( p_intf->p_libvlc );
...@@ -627,6 +718,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -627,6 +718,7 @@ static VLCMain *_o_sharedMainInstance = nil;
/* received directly before the update gets installed, so let's shut down a bit */ /* received directly before the update gets installed, so let's shut down a bit */
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update - (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update
{ {
[NSApp activateIgnoringOtherApps:YES];
[o_remote stopListening: self]; [o_remote stopListening: self];
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_STOP ); var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_STOP );
...@@ -702,10 +794,15 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -702,10 +794,15 @@ static VLCMain *_o_sharedMainInstance = nil;
/* Triggered when the computer goes to sleep */ /* Triggered when the computer goes to sleep */
- (void)computerWillSleep: (NSNotification *)notification - (void)computerWillSleep: (NSNotification *)notification
{ {
/* Pause */ input_thread_t * p_input;
if( p_intf && p_intf->p_sys->i_play_status == PLAYING_S )
p_input = pl_CurrentInput( p_intf );
if( p_input )
{ {
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE ); int state = var_GetInteger( p_input, "state" );
if( state == PLAYING_S )
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE );
vlc_object_release( p_input );
} }
} }
...@@ -752,16 +849,16 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -752,16 +849,16 @@ static VLCMain *_o_sharedMainInstance = nil;
switch([buttonIdentifierNumber intValue]) switch([buttonIdentifierNumber intValue])
{ {
case kRemoteButtonRight_Hold: case kRemoteButtonRight_Hold:
[o_controls forward: self]; [[VLCCoreInteraction sharedInstance] forward];
break; break;
case kRemoteButtonLeft_Hold: case kRemoteButtonLeft_Hold:
[o_controls backward: self]; [[VLCCoreInteraction sharedInstance] backward];
break; break;
case kRemoteButtonVolume_Plus_Hold: case kRemoteButtonVolume_Plus_Hold:
[o_controls volumeUp: self]; [[VLCCoreInteraction sharedInstance] volumeUp];
break; break;
case kRemoteButtonVolume_Minus_Hold: case kRemoteButtonVolume_Minus_Hold:
[o_controls volumeDown: self]; [[VLCCoreInteraction sharedInstance] volumeDown];
break; break;
} }
if(b_remote_button_hold) if(b_remote_button_hold)
...@@ -782,29 +879,29 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -782,29 +879,29 @@ static VLCMain *_o_sharedMainInstance = nil;
switch( buttonIdentifier ) switch( buttonIdentifier )
{ {
case k2009RemoteButtonFullscreen: case k2009RemoteButtonFullscreen:
[o_controls toogleFullscreen:self]; [[VLCCoreInteraction sharedInstance] toggleFullscreen];
break; break;
case k2009RemoteButtonPlay: case k2009RemoteButtonPlay:
[o_controls play:self]; [[VLCCoreInteraction sharedInstance] play];
break; break;
case kRemoteButtonPlay: case kRemoteButtonPlay:
if(count >= 2) { if(count >= 2) {
[o_controls toogleFullscreen:self]; [[VLCCoreInteraction sharedInstance] toggleFullscreen];
} else { } else {
[o_controls play: self]; [[VLCCoreInteraction sharedInstance] play];
} }
break; break;
case kRemoteButtonVolume_Plus: case kRemoteButtonVolume_Plus:
[o_controls volumeUp: self]; [[VLCCoreInteraction sharedInstance] volumeUp];
break; break;
case kRemoteButtonVolume_Minus: case kRemoteButtonVolume_Minus:
[o_controls volumeDown: self]; [[VLCCoreInteraction sharedInstance] volumeDown];
break; break;
case kRemoteButtonRight: case kRemoteButtonRight:
[o_controls next: self]; [[VLCCoreInteraction sharedInstance] next];
break; break;
case kRemoteButtonLeft: case kRemoteButtonLeft:
[o_controls prev: self]; [[VLCCoreInteraction sharedInstance] previous];
break; break;
case kRemoteButtonRight_Hold: case kRemoteButtonRight_Hold:
case kRemoteButtonLeft_Hold: case kRemoteButtonLeft_Hold:
...@@ -820,7 +917,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -820,7 +917,7 @@ static VLCMain *_o_sharedMainInstance = nil;
} }
break; break;
case kRemoteButtonMenu: case kRemoteButtonMenu:
[o_controls showPosition: self]; [o_controls showPosition: self]; //FIXME
break; break;
default: default:
/* Add here whatever you want other buttons to do */ /* Add here whatever you want other buttons to do */
...@@ -1108,6 +1205,105 @@ unsigned int CocoaKeyToVLC( unichar i_key ) ...@@ -1108,6 +1205,105 @@ unsigned int CocoaKeyToVLC( unichar i_key )
o_usedHotkeys = [[NSArray alloc] initWithArray: o_usedHotkeys copyItems: YES]; o_usedHotkeys = [[NSArray alloc] initWithArray: o_usedHotkeys copyItems: YES];
} }
#pragma mark -
#pragma mark Interface updaters
- (void)PlaylistItemChanged
{
input_thread_t * p_input;
p_input = playlist_CurrentInput( pl_Get(VLCIntf) );
if( p_input && !( p_input->b_dead || !vlc_object_alive(p_input) ) )
{
var_AddCallback( p_input, "intf-event", InputEvent, [VLCMain sharedInstance] );
[o_mainmenu setRateControlsEnabled: YES];
vlc_object_release( p_input );
}
else[o_mainmenu setRateControlsEnabled: NO];
[o_playlist updateRowSelection];
[o_mainwindow updateWindow];
[o_mainmenu setupMenus];
[o_mainmenu updatePlaybackRate];
}
- (void)updateMainWindow
{
[o_mainwindow updateWindow];
}
- (void)updateTitle
{
[o_mainwindow updateTitle];
}
- (void)updatePlaybackPosition
{
[o_mainwindow updateTimeSlider];
}
- (void)updateVolume
{
[o_mainwindow updateVolumeSlider];
}
- (void)playlistUpdated
{
[self playbackStatusUpdated];
[o_playlist playlistUpdated];
}
- (void)updateInfoandMetaPanel
{
[o_playlist outlineViewSelectionDidChange:nil];
}
- (void)playbackStatusUpdated
{
input_thread_t * p_input;
p_input = pl_CurrentInput( p_intf );
if( p_input )
{
int state = var_GetInteger( p_input, "state" );
if( state == PLAYING_S )
{
[[[self controls] fspanel] setPause];
[[self mainMenu] setPause];
[o_mainwindow setPause];
}
else
{
if (state == END_S)
[o_mainmenu setSubmenusEnabled: FALSE];
[[[self controls] fspanel] setPlay];
[[self mainMenu] setPlay];
[o_mainwindow setPlay];
}
vlc_object_release( p_input );
}
}
- (void)playbackModeUpdated
{
vlc_value_t looping,repeating;
playlist_t * p_playlist = pl_Get( VLCIntf );
bool loop = var_GetBool( p_playlist, "loop" );
bool repeat = var_GetBool( p_playlist, "repeat" );
if( repeat ) {
[o_mainwindow setRepeatOne];
[o_mainmenu setRepeatOne];
} else if( loop ) {
[o_mainwindow setRepeatAll];
[o_mainmenu setRepeatAll];
} else {
[o_mainwindow setRepeatOff];
[o_mainmenu setRepeatOff];
}
[o_mainwindow setShuffle];
[o_mainmenu setShuffle];
}
#pragma mark - #pragma mark -
#pragma mark Other objects getters #pragma mark Other objects getters
...@@ -1246,223 +1442,6 @@ unsigned int CocoaKeyToVLC( unichar i_key ) ...@@ -1246,223 +1442,6 @@ unsigned int CocoaKeyToVLC( unichar i_key )
return o_remote; return o_remote;
} }
#pragma mark -
#pragma mark Polling
/*****************************************************************************
* ManageThread: An ugly thread that polls
*****************************************************************************/
static void * ManageThread( void *user_data )
{
id self = user_data;
[self manage];
return NULL;
}
struct manage_cleanup_stack {
intf_thread_t * p_intf;
input_thread_t ** p_input;
playlist_t * p_playlist;
id self;
};
static void manage_cleanup( void * args )
{
struct manage_cleanup_stack * manage_cleanup_stack = args;
intf_thread_t * p_intf = manage_cleanup_stack->p_intf;
input_thread_t * p_input = *manage_cleanup_stack->p_input;
id self = manage_cleanup_stack->self;
playlist_t * p_playlist = manage_cleanup_stack->p_playlist;
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 );
if( p_input ) vlc_object_release( p_input );
}
- (void)manage
{
playlist_t * p_playlist;
input_thread_t * p_input = NULL;
/* new thread requires a new pool */
p_playlist = pl_Get( p_intf );
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 );
struct manage_cleanup_stack stack = { p_intf, &p_input, p_playlist, self };
pthread_cleanup_push(manage_cleanup, &stack);
bool exitLoop = false;
while( !exitLoop )
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
if( !p_input )
{
p_input = playlist_CurrentInput( p_playlist );
/* Refresh the interface */
if( p_input )
{
msg_Dbg( p_intf, "input has changed, refreshing interface" );
p_intf->p_sys->b_input_update = true;
}
}
else if( !vlc_object_alive (p_input) || p_input->b_dead )
{
/* input stopped */
p_intf->p_sys->b_intf_update = true;
p_intf->p_sys->i_play_status = END_S;
msg_Dbg( p_intf, "input has stopped, refreshing interface" );
vlc_object_release( p_input );
p_input = NULL;
}
else if( cachedInputState != input_GetState( p_input ) )
{
cachedInputState = input_GetState( p_input );
p_intf->p_sys->b_intf_update = true;
}
/* Manage volume status */
[o_mainwindow updateVolumeSlider];
msleep( INTF_IDLE_SLEEP );
[pool release];
[o_appLock lock];
exitLoop = (f_appExit != 0 ? true : false);
[o_appLock unlock];
}
pthread_cleanup_pop(1);
}
- (void)manageIntf:(NSTimer *)o_timer
{
vlc_value_t val;
playlist_t * p_playlist;
input_thread_t * p_input;
if( p_intf->p_sys->b_input_update )
{
/* Called when new input is opened */
p_intf->p_sys->b_current_title_update = true;
p_intf->p_sys->b_intf_update = true;
p_intf->p_sys->b_input_update = false;
[o_mainmenu setupMenus]; /* Make sure input menu is up to date */
}
if( p_intf->p_sys->b_intf_update )
{
[o_mainwindow updateWindow];
p_intf->p_sys->b_current_title_update = true;
p_intf->p_sys->b_intf_update = false;
}
if( p_intf->p_sys->b_playmode_update )
{
[o_playlist playModeUpdated];
p_intf->p_sys->b_playmode_update = false;
}
if( p_intf->p_sys->b_playlist_update )
{
[o_playlist playlistUpdated];
p_intf->p_sys->b_playlist_update = false;
}
p_input = pl_CurrentInput( p_intf );
if( p_input && vlc_object_alive (p_input) )
{
vlc_value_t val;
if( p_intf->p_sys->b_current_title_update )
{
NSString *aString;
input_item_t * p_item = input_GetItem( p_input );
char * name = input_item_GetNowPlaying( p_item );
if( !name )
name = input_item_GetName( p_item );
aString = [NSString stringWithUTF8String:name];
free(name);
[o_mainwindow setTitle: aString];
[[[self controls] fspanel] setStreamTitle: aString];
[[o_coreinteraction voutView] updateTitle];
[o_playlist updateRowSelection];
p_intf->p_sys->b_current_title_update = FALSE;
}
[o_mainwindow updateTimeSlider];
/* Manage Playing status */
var_Get( p_input, "state", &val );
if( p_intf->p_sys->i_play_status != val.i_int )
{
p_intf->p_sys->i_play_status = val.i_int;
[self playStatusUpdated: p_intf->p_sys->i_play_status];
}
vlc_object_release( p_input );
}
else if( p_input )
{
vlc_object_release( p_input );
}
else
{
p_intf->p_sys->i_play_status = END_S;
if (p_intf->p_sys->i_old_play_status != p_intf->p_sys->i_play_status)
{
[self playStatusUpdated: p_intf->p_sys->i_play_status];
[o_mainmenu setSubmenusEnabled: FALSE];
p_intf->p_sys->i_old_play_status = p_intf->p_sys->i_play_status;
}
}
end:
[self updateMessageDisplay];
[interfaceTimer autorelease];
interfaceTimer = [[NSTimer scheduledTimerWithTimeInterval: 0.3
target: self selector: @selector(manageIntf:)
userInfo: nil repeats: FALSE] retain];
}
#pragma mark -
#pragma mark Interface update
- (void)playStatusUpdated:(int)i_status
{
if( i_status == PLAYING_S )
{
[[[self controls] fspanel] setPause];
[[self mainMenu] setPause];
[o_mainwindow setPause];
}
else
{
[[[self controls] fspanel] setPlay];
[[self mainMenu] setPlay];
[o_mainwindow setPlay];
}
}
- (IBAction)showController:(id)sender - (IBAction)showController:(id)sender
{ {
//FIXME: why is this function here?! //FIXME: why is this function here?!
...@@ -1729,6 +1708,8 @@ end: ...@@ -1729,6 +1708,8 @@ end:
b_msg_arr_changed = YES; b_msg_arr_changed = YES;
[o_msg_lock unlock]; [o_msg_lock unlock];
[self updateMessageDisplay];
} }
- (IBAction)saveDebugLog:(id)sender - (IBAction)saveDebugLog:(id)sender
......
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
- (IBAction)searchItem:(id)sender; - (IBAction)searchItem:(id)sender;
- (void)playlistUpdated; - (void)playlistUpdated;
- (void)playModeUpdated; - (void)outlineViewSelectionDidChange:(NSNotification *)notification;
- (void)sortNode:(int)i_mode; - (void)sortNode:(int)i_mode;
- (void)updateRowSelection; - (void)updateRowSelection;
......
...@@ -521,25 +521,6 @@ ...@@ -521,25 +521,6 @@
[self outlineViewSelectionDidChange: nil]; [self outlineViewSelectionDidChange: nil];
} }
- (void)playModeUpdated
{
//FIXME this is broken, re-write with VLCMainWindow!
NSLog( @"playModeUpdated is broken, re-write with VLCMainWindow!" );
/*
playlist_t *p_playlist = pl_Get( VLCIntf );
bool loop = var_GetBool( p_playlist, "loop" );
bool repeat = var_GetBool( p_playlist, "repeat" );
if( repeat )
[[[VLCMain sharedInstance] controls] repeatOne];
else if( loop )
[[[VLCMain sharedInstance] controls] repeatAll];
else
[[[VLCMain sharedInstance] controls] repeatOff];
[[[VLCMain sharedInstance] controls] shuffle];*/
}
- (void)outlineViewSelectionDidChange:(NSNotification *)notification - (void)outlineViewSelectionDidChange:(NSNotification *)notification
{ {
// FIXME: unsafe // FIXME: unsafe
...@@ -1481,8 +1462,7 @@ ...@@ -1481,8 +1462,7 @@
id o_playing_item; id o_playing_item;
PL_LOCK; PL_LOCK;
o_playing_item = [o_outline_dict objectForKey: o_playing_item = [o_outline_dict objectForKey: [NSString stringWithFormat:@"%p", playlist_CurrentPlayingItem( p_playlist )]];
[NSString stringWithFormat:@"%p", playlist_CurrentPlayingItem( p_playlist )]];
PL_UNLOCK; PL_UNLOCK;
return o_playing_item; return o_playing_item;
......
...@@ -98,11 +98,9 @@ ...@@ -98,11 +98,9 @@
VLCInfoTreeItem * rootItem; VLCInfoTreeItem * rootItem;
input_item_t * p_item; input_item_t * p_item;
NSTimer * o_statUpdateTimer;
} }
- (void)initPanel; - (void)initPanel;
- (void)stopTimers;
- (IBAction)metaFieldChanged:(id)sender; - (IBAction)metaFieldChanged:(id)sender;
- (IBAction)saveMetaData:(id)sender; - (IBAction)saveMetaData:(id)sender;
...@@ -111,7 +109,7 @@ ...@@ -111,7 +109,7 @@
- (void)updatePanelWithItem:(input_item_t *)_p_item; - (void)updatePanelWithItem:(input_item_t *)_p_item;
- (input_item_t *)item; - (input_item_t *)item;
- (void)setMeta: (char *)meta forLabel: (id)theItem; - (void)setMeta: (char *)meta forLabel: (id)theItem;
- (void)updateStatistics: (NSTimer*)theTimer; - (void)updateStatistics;
+ (VLCInfo *)sharedInstance; + (VLCInfo *)sharedInstance;
@end @end
......
...@@ -57,7 +57,6 @@ static VLCInfo *_o_sharedInstance = nil; ...@@ -57,7 +57,6 @@ static VLCInfo *_o_sharedInstance = nil;
if( _o_sharedInstance != nil ) if( _o_sharedInstance != nil )
{ {
p_item = NULL; p_item = NULL;
o_statUpdateTimer = nil;
[self updatePanelWithItem: NULL]; [self updatePanelWithItem: NULL];
rootItem = [[VLCInfoTreeItem alloc] init]; rootItem = [[VLCInfoTreeItem alloc] init];
} }
...@@ -124,61 +123,16 @@ static VLCInfo *_o_sharedInstance = nil; ...@@ -124,61 +123,16 @@ static VLCInfo *_o_sharedInstance = nil;
[self updatePanelWithItem:p_item]; [self updatePanelWithItem:p_item];
} }
- (void)stopTimers
{
/* make sure that the timer is released in any case */
if( o_statUpdateTimer && [o_statUpdateTimer isValid] )
[o_statUpdateTimer invalidate];
[rootItem release];
[o_statUpdateTimer release];
o_statUpdateTimer = nil;
}
- (void)dealloc - (void)dealloc
{ {
/* make sure that the timer is released in any case */ [rootItem release];
if( o_statUpdateTimer && [o_statUpdateTimer isValid] )
[o_statUpdateTimer invalidate];
[o_statUpdateTimer release];
if( p_item ) vlc_gc_decref( p_item ); if( p_item ) vlc_gc_decref( p_item );
[super dealloc]; [super dealloc];
} }
- (void)windowDidBecomeKey:(NSNotification *)notification
{
BOOL b_stats = config_GetInt(VLCIntf, "stats");
if( b_stats )
{
if( o_statUpdateTimer )
{
[o_statUpdateTimer invalidate];
[o_statUpdateTimer release];
o_statUpdateTimer = nil;
}
o_statUpdateTimer = [NSTimer scheduledTimerWithTimeInterval: 1
target: self selector: @selector(updateStatistics:)
userInfo: nil repeats: YES];
[o_statUpdateTimer fire];
[o_statUpdateTimer retain];
}
}
- (BOOL)windowShouldClose:(id)sender
{
if( [o_statUpdateTimer isValid] )
[o_statUpdateTimer invalidate];
if( o_statUpdateTimer )
[o_statUpdateTimer release];
o_statUpdateTimer = nil;
return YES;
}
- (void)initPanel - (void)initPanel
{ {
BOOL b_stats = config_GetInt(VLCIntf, "stats"); BOOL b_stats = config_GetInt(VLCIntf, "stats");
...@@ -305,7 +259,7 @@ static VLCInfo *_o_sharedInstance = nil; ...@@ -305,7 +259,7 @@ static VLCInfo *_o_sharedInstance = nil;
[o_outline_view reloadData]; [o_outline_view reloadData];
/* update the stats once to display p_item change faster */ /* update the stats once to display p_item change faster */
[self updateStatistics: nil]; [self updateStatistics];
} }
- (void)setMeta: (char *)psz_meta forLabel: (id)theItem - (void)setMeta: (char *)psz_meta forLabel: (id)theItem
...@@ -316,47 +270,50 @@ static VLCInfo *_o_sharedInstance = nil; ...@@ -316,47 +270,50 @@ static VLCInfo *_o_sharedInstance = nil;
[theItem setStringValue: @""]; [theItem setStringValue: @""];
} }
- (void)updateStatistics:(NSTimer*)theTimer - (void)updateStatistics
{ {
if( !p_item || !p_item->p_stats ) if ([o_info_window isVisible])
{ {
[self initMediaPanelStats]; if( !p_item || !p_item->p_stats )
return; {
} [self initMediaPanelStats];
return;
}
vlc_mutex_lock( &p_item->p_stats->lock ); vlc_mutex_lock( &p_item->p_stats->lock );
/* input */ /* input */
[o_read_bytes_txt setStringValue: [NSString stringWithFormat: [o_read_bytes_txt setStringValue: [NSString stringWithFormat:
@"%8.0f KiB", (float)(p_item->p_stats->i_read_bytes)/1024]]; @"%8.0f KiB", (float)(p_item->p_stats->i_read_bytes)/1024]];
[o_input_bitrate_txt setStringValue: [NSString stringWithFormat: [o_input_bitrate_txt setStringValue: [NSString stringWithFormat:
@"%6.0f kb/s", (float)(p_item->p_stats->f_input_bitrate)*8000]]; @"%6.0f kb/s", (float)(p_item->p_stats->f_input_bitrate)*8000]];
[o_demux_bytes_txt setStringValue: [NSString stringWithFormat: [o_demux_bytes_txt setStringValue: [NSString stringWithFormat:
@"%8.0f KiB", (float)(p_item->p_stats->i_demux_read_bytes)/1024]]; @"%8.0f KiB", (float)(p_item->p_stats->i_demux_read_bytes)/1024]];
[o_demux_bitrate_txt setStringValue: [NSString stringWithFormat: [o_demux_bitrate_txt setStringValue: [NSString stringWithFormat:
@"%6.0f kb/s", (float)(p_item->p_stats->f_demux_bitrate)*8000]]; @"%6.0f kb/s", (float)(p_item->p_stats->f_demux_bitrate)*8000]];
/* Video */ /* Video */
[o_video_decoded_txt setIntValue: p_item->p_stats->i_decoded_video]; [o_video_decoded_txt setIntValue: p_item->p_stats->i_decoded_video];
[o_displayed_txt setIntValue: p_item->p_stats->i_displayed_pictures]; [o_displayed_txt setIntValue: p_item->p_stats->i_displayed_pictures];
[o_lost_frames_txt setIntValue: p_item->p_stats->i_lost_pictures]; [o_lost_frames_txt setIntValue: p_item->p_stats->i_lost_pictures];
float f_fps = 0; float f_fps = 0;
/* FIXME: input_Control( p_item, INPUT_GET_VIDEO_FPS, &f_fps ); */ /* FIXME: input_Control( p_item, INPUT_GET_VIDEO_FPS, &f_fps ); */
[o_fps_txt setFloatValue: f_fps]; [o_fps_txt setFloatValue: f_fps];
/* Sout */ /* Sout */
[o_sent_packets_txt setIntValue: p_item->p_stats->i_sent_packets]; [o_sent_packets_txt setIntValue: p_item->p_stats->i_sent_packets];
[o_sent_bytes_txt setStringValue: [NSString stringWithFormat: @"%8.0f KiB", [o_sent_bytes_txt setStringValue: [NSString stringWithFormat: @"%8.0f KiB",
(float)(p_item->p_stats->i_sent_bytes)/1024]]; (float)(p_item->p_stats->i_sent_bytes)/1024]];
[o_sent_bitrate_txt setStringValue: [NSString stringWithFormat: [o_sent_bitrate_txt setStringValue: [NSString stringWithFormat:
@"%6.0f kb/s", (float)(p_item->p_stats->f_send_bitrate*8)*1000]]; @"%6.0f kb/s", (float)(p_item->p_stats->f_send_bitrate*8)*1000]];
/* Audio */ /* Audio */
[o_audio_decoded_txt setIntValue: p_item->p_stats->i_decoded_audio]; [o_audio_decoded_txt setIntValue: p_item->p_stats->i_decoded_audio];
[o_played_abuffers_txt setIntValue: p_item->p_stats->i_played_abuffers]; [o_played_abuffers_txt setIntValue: p_item->p_stats->i_played_abuffers];
[o_lost_abuffers_txt setIntValue: p_item->p_stats->i_lost_abuffers]; [o_lost_abuffers_txt setIntValue: p_item->p_stats->i_lost_abuffers];
vlc_mutex_unlock( &p_item->p_stats->lock ); vlc_mutex_unlock( &p_item->p_stats->lock );
}
} }
- (IBAction)metaFieldChanged:(id)sender - (IBAction)metaFieldChanged:(id)sender
......
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