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

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;
//vout_OSDMessage( VLCIntf, SPU_DEFAULT_CHANNEL, "%s", _( "Random Off" ) );
config_PutInt( p_playlist, "random", 0 );
}
VLCIntf->p_sys->b_playmode_update = true;
VLCIntf->p_sys->b_intf_update = true;
}
- (void)repeatAll
......@@ -194,9 +191,6 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
config_PutInt( p_playlist, "loop", YES );
//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
......@@ -209,9 +203,6 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
config_PutInt( p_playlist, "loop", NO );
//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
......@@ -224,9 +215,6 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
config_PutInt( p_playlist, "loop", NO );
//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]
......
......@@ -207,6 +207,7 @@
- (IBAction)intfOpenCapture:(id)sender;
- (IBAction)setPlaybackRate:(id)sender;
- (void)updatePlaybackRate;
- (IBAction)showWizard:(id)sender;
- (IBAction)showVideoEffects:(id)sender;
......@@ -228,6 +229,10 @@
- (void)setPlay;
- (void)setPause;
- (void)setRepeatOne;
- (void)setRepeatAll;
- (void)setRepeatOff;
- (void)setShuffle;
- (IBAction)toggleVar:(id)sender;
- (int)toggleVarThread:(id)_o_data;
......
......@@ -549,6 +549,14 @@ static VLCMainMenu *_o_sharedInstance = nil;
[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 Panels
......@@ -721,6 +729,32 @@ static VLCMainMenu *_o_sharedInstance = nil;
[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 Dynamic menu creation and validation
......
......@@ -95,7 +95,12 @@
- (void)updateTimeSlider;
- (void)updateVolumeSlider;
- (void)updateWindow;
- (void)updateTitle;
- (void)setPause;
- (void)setPlay;
- (void)setRepeatOne;
- (void)setRepeatAll;
- (void)setRepeatOff;
- (void)setShuffle;
@end
\ No newline at end of file
......@@ -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
{
vlc_value_t looping,repeating;
......@@ -268,36 +286,28 @@ static VLCMainWindow *_o_sharedInstance = nil;
{
/* was: no repeating at all, switching to Repeat One */
[[VLCCoreInteraction sharedInstance] repeatOne];
[o_repeat_btn setImage: o_repeat_one_img];
[o_repeat_btn setAlternateImage: o_repeat_one_pressed_img];
[self setRepeatOne];
}
else if( repeating.b_bool && !looping.b_bool )
{
/* was: Repeat One, switching to Repeat All */
[[VLCCoreInteraction sharedInstance] repeatAll];
[o_repeat_btn setImage: o_repeat_all_img];
[o_repeat_btn setAlternateImage: o_repeat_all_pressed_img];
[self setRepeatAll];
}
else
{
/* was: Repeat All or bug in VLC, switching to Repeat Off */
[[VLCCoreInteraction sharedInstance] repeatOff];
[o_repeat_btn setImage: o_repeat_img];
[o_repeat_btn setAlternateImage: o_repeat_pressed_img];
[self setRepeatOff];
}
}
- (IBAction)shuffle:(id)sender
- (void)setShuffle
{
[[VLCCoreInteraction sharedInstance] shuffle];
vlc_value_t val;
bool b_value;
playlist_t *p_playlist = pl_Get( VLCIntf );
var_Get( p_playlist, "random", &val );
if(val.b_bool) {
b_value = var_GetBool( p_playlist, "random" );
if(b_value) {
[o_shuffle_btn setImage: o_shuffle_on_img];
[o_shuffle_btn setAlternateImage: o_shuffle_on_pressed_img];
}
......@@ -308,6 +318,12 @@ static VLCMainWindow *_o_sharedInstance = nil;
}
}
- (IBAction)shuffle:(id)sender
{
[[VLCCoreInteraction sharedInstance] shuffle];
[self setShuffle];
}
- (IBAction)timeSliderAction:(id)sender
{
float f_updated;
......@@ -383,35 +399,32 @@ static VLCMainWindow *_o_sharedInstance = nil;
#pragma mark Update interface and respond to foreign events
- (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;
p_input = pl_CurrentInput( VLCIntf );
if( p_input )
vlc_value_t time;
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 )
{
vlc_value_t time;
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];
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];
}
}
......@@ -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
{
bool b_input = false;
......@@ -483,10 +519,9 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_bwd_btn setEnabled: (b_seekable || b_plmul || b_chapters)];
[[VLCMainMenu sharedInstance] setRateControlsEnabled: b_control];
[o_time_sld setFloatValue: 0.0];
[o_time_sld setEnabled: b_seekable];
[o_time_fld setStringValue: @"0:00:00"];
[[[[VLCMain sharedInstance] controls] fspanel] setStreamPos: 0 andTime: @"0:00:00"];
[self updateTimeSlider];
[[[[VLCMain sharedInstance] controls] fspanel] setSeekable: b_seekable];
}
......
......@@ -33,11 +33,6 @@
{
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_enter_fld;
IBOutlet id o_specificTime_goTo_lbl;
......@@ -51,16 +46,12 @@
}
- (IBAction)play:(id)sender;
- (IBAction)stop:(id)sender;
- (IBAction)faster:(id)sender;
- (IBAction)slower:(id)sender;
- (IBAction)normalSpeed:(id)sender;
- (IBAction)prev:(id)sender;
- (IBAction)next:(id)sender;
- (IBAction)random:(id)sender;
- (IBAction)repeat:(id)sender;
- (IBAction)loop:(id)sender;
- (IBAction)repeatButtonAction:(id)sender;
- (IBAction)quitAfterPlayback:(id)sender;
- (IBAction)forward:(id)sender;
......
......@@ -80,21 +80,6 @@
[[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
{
[[VLCCoreInteraction sharedInstance] previous];
......@@ -108,57 +93,8 @@
- (IBAction)random:(id)sender
{
[[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
{
vlc_value_t val;
......@@ -202,7 +138,6 @@
[[VLCCoreInteraction sharedInstance] backward];
}
- (IBAction)volumeUp:(id)sender
{
[[VLCCoreInteraction sharedInstance] volumeUp];
......
......@@ -66,16 +66,6 @@ aout_instance_t *getAout(void);
*****************************************************************************/
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 */
bool b_input_update;
bool b_aout_update;
......@@ -141,12 +131,6 @@ struct intf_sys_t
input_state_e cachedInputState;
/* the manage thread */
pthread_t manage_thread;
/* The timer that update the interface */
NSTimer * interfaceTimer;
NSURLConnection * crashLogURLConnection;
AppleRemote * o_remote;
......@@ -187,15 +171,20 @@ struct intf_sys_t
- (NSString *)VLCKeyToString:(NSString *)theString;
- (unsigned int)VLCModifiersToCocoa:(NSString *)theString;
- (void)updateCurrentlyUsedHotkeys;
- (void)PlaylistItemChanged;
- (void)playbackStatusUpdated;
- (void)playbackModeUpdated;
- (void)updateVolume;
- (void)updatePlaybackPosition;
- (void)updateTitle;
- (void)playlistUpdated;
- (void)updateInfoandMetaPanel;
- (void)updateMainWindow;
- (void)initStrings;
- (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename;
- (void)manage;
- (void)manageIntf:(NSTimer *)o_timer;
- (void)updateMessageDisplay;
- (void)playStatusUpdated:(int) i_status;
- (IBAction)showController:(id)sender;
- (IBAction)crashReporterAction:(id)sender;
......
......@@ -66,14 +66,23 @@
*****************************************************************************/
static void Run ( intf_thread_t *p_intf );
static void * ManageThread( void *user_data );
static void updateProgressPanel (void *, const char *, float);
static bool checkProgressPanel (void *);
static void destroyProgressPanel (void *);
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 VLC Interface Object Callbacks
......@@ -175,7 +184,7 @@ static void Run( intf_thread_t *p_intf )
/* Make sure the "force quit" menu item does quit instantly.
* 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. */
sigemptyset( &set );
sigaddset( &set, SIGTERM );
......@@ -219,22 +228,106 @@ static void MsgCallback( msg_cb_data_t *data, const msg_item_t *item )
vlc_restorecancel( canc );
}
/*****************************************************************************
* playlistChanged: Callback triggered by the intf-change playlist
* 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 )
static int InputEvent( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param )
{
intf_thread_t * p_intf = VLCIntf;
if( p_intf && p_intf->p_sys )
{
NSLog( @"event from %s", psz_variable );
p_intf->p_sys->b_intf_update = true;
p_intf->p_sys->b_playlist_update = true;
p_intf->p_sys->b_playmode_update = true;
p_intf->p_sys->b_current_title_update = true;
switch (new_val.i_int) {
case INPUT_EVENT_STATE:
[[VLCMain sharedInstance] playbackStatusUpdated];
break;
case INPUT_EVENT_RATE:
[[VLCMainMenu sharedInstance] performSelectorOnMainThread:@selector(updatePlaybackRate) withObject: nil waitUntilDone:NO];
break;
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];