* controls.m: MacOS X interface plugin
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: controls.m,v 1.13 2003/01/24 00:53:41 hartman Exp $
+ * $Id: controls.m,v 1.28 2003/02/12 14:22:23 hartman Exp $
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr>
#include <sys/param.h> /* for MAXPATHLEN */
#include <string.h>
-#include <vlc/vlc.h>
-#include <vlc/intf.h>
-#include <vlc/aout.h>
-
-#include <Cocoa/Cocoa.h>
-#include <CoreAudio/AudioHardware.h>
-
#include "intf.h"
#include "vout.h"
{
IBOutlet id o_open;
IBOutlet id o_main;
- IBOutlet id o_mi_mute;
+
IBOutlet id o_volumeslider;
- int i_ff;
}
- (IBAction)play:(id)sender;
- (IBAction)stop:(id)sender;
- (IBAction)faster:(id)sender;
- (IBAction)slower:(id)sender;
-- (IBAction)slowMotion:(id)sender;
-- (IBAction)fastForward:(id)sender;
- (IBAction)prev:(id)sender;
- (IBAction)next:(id)sender;
- (IBAction)loop:(id)sender;
+- (IBAction)forward:(id)sender;
+- (IBAction)backward:(id)sender;
+
- (IBAction)volumeUp:(id)sender;
- (IBAction)volumeDown:(id)sender;
- (IBAction)mute:(id)sender;
-- (IBAction)volumeSliderUpdate:(id)sender;
+- (IBAction)volumeSliderUpdated:(id)sender;
+- (void)updateVolumeSlider;
+
+- (IBAction)halfWindow:(id)sender;
+- (IBAction)normalWindow:(id)sender;
+- (IBAction)doubleWindow:(id)sender;
- (IBAction)fullscreen:(id)sender;
- (IBAction)deinterlace:(id)sender;
- (IBAction)toggleLanguage:(id)sender;
- (IBAction)toggleVar:(id)sender;
-- (void)setVolumeSlider;
-
@end
/*****************************************************************************
- (IBAction)play:(id)sender
{
intf_thread_t * p_intf = [NSApp getIntf];
+
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
return;
}
- if ( p_intf->p_sys->p_input != NULL && p_intf->p_sys->p_input->stream.control.i_status != PAUSE_S)
+ if( playlist_IsPlaying( p_playlist ) )
{
- input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE );
+ playlist_Pause( p_playlist );
vlc_object_release( p_playlist );
}
else
{
- /* If the playlist is empty, open a file requester instead */
- vlc_mutex_lock( &p_playlist->object_lock );
- if( p_playlist->i_size )
+ if( !playlist_IsEmpty( p_playlist ) )
{
- vlc_mutex_unlock( &p_playlist->object_lock );
playlist_Play( p_playlist );
vlc_object_release( p_playlist );
}
else
{
- vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist );
-
[o_open openFile: nil];
}
}
- (IBAction)stop:(id)sender
{
intf_thread_t * p_intf = [NSApp getIntf];
+
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
- p_intf->p_sys->b_stopping = 1;
}
- (IBAction)faster:(id)sender
{
intf_thread_t * p_intf = [NSApp getIntf];
- if( p_intf->p_sys->p_input == NULL )
+ playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist == NULL )
{
return;
}
- input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
+ vlc_mutex_lock( &p_playlist->object_lock );
+ if( p_playlist->p_input != NULL )
+ {
+ input_SetStatus( p_playlist->p_input, INPUT_STATUS_FASTER );
+ }
+ vlc_mutex_unlock( &p_playlist->object_lock );
+
+ vlc_object_release( p_playlist );
}
- (IBAction)slower:(id)sender
{
intf_thread_t * p_intf = [NSApp getIntf];
- if( p_intf->p_sys->p_input == NULL )
+ playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist == NULL )
{
return;
}
- input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER );
+ vlc_mutex_lock( &p_playlist->object_lock );
+ if( p_playlist->p_input != NULL )
+ {
+ input_SetStatus( p_playlist->p_input, INPUT_STATUS_SLOWER );
+ }
+ vlc_mutex_unlock( &p_playlist->object_lock );
+
+ vlc_object_release( p_playlist );
}
-- (IBAction)slowMotion:(id)sender
+- (IBAction)prev:(id)sender
{
- i_ff++;
- switch( [[NSApp currentEvent] type] )
+ intf_thread_t * p_intf = [NSApp getIntf];
+
+ playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist == NULL )
{
- case NSPeriodic:
- if ( i_ff == 1 )
- {
- [self slower:sender];
- }
- break;
-
- case NSLeftMouseUp:
- if ( i_ff > 1 )
- {
- intf_thread_t * p_intf = [NSApp getIntf];
-
- [self faster:sender];
- if ( p_intf->p_sys->p_input != NULL &&
- p_intf->p_sys->p_input->stream.control.i_status != PAUSE_S)
- {
- input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE );
- }
- }
- i_ff = 0;
- break;
+ return;
+ }
- default:
- break;
+ vlc_mutex_lock( &p_playlist->object_lock );
+
+ if( p_playlist->p_input == NULL )
+ {
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_release( p_playlist );
+ return;
}
-}
-- (IBAction)fastForward:(id)sender
-{
- playlist_t * p_playlist = vlc_object_find( [NSApp getIntf], VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
-
- i_ff++;
- switch( [[NSApp currentEvent] type] )
- {
- /* A button does not send a NSLeftMouseDown unfortunately.
- * Therefore we need to count. I know, it is ugly. We could have used
- * a bool as well, but now we can also accellerate after a certain period.
- * Currently this method is called every second if the button is pressed.
- * You can set this value in intf.m (hartman)
- */
- case NSPeriodic:
- if ( i_ff == 1 )
- {
- [self faster:self];
- }
- else if ( i_ff == 5 )
- {
- [self faster:self];
- }
- else if ( i_ff == 15 )
- {
- [self faster:self];
- }
- break;
+ vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
- case NSLeftMouseUp:
- i_ff = 0;
-
- vlc_mutex_lock( &p_playlist->object_lock );
- int i_playlist_size = p_playlist->i_size ;
- vlc_mutex_unlock( &p_playlist->object_lock );
- if( i_playlist_size )
- {
- playlist_Play( p_playlist );
- }
- break;
+#define p_area p_playlist->p_input->stream.p_selected_area
+
+ if( p_area->i_part_nb > 1 && p_area->i_part > 1 )
+ {
+ p_area->i_part--;
+
+ vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
+ input_ChangeArea( p_playlist->p_input, p_area );
+ vlc_mutex_unlock( &p_playlist->object_lock );
- default:
- break;
+ p_intf->p_sys->b_chapter_update = VLC_TRUE;
+ }
+ else
+ {
+ vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ playlist_Prev( p_playlist );
}
+
+#undef p_area
+
vlc_object_release( p_playlist );
}
-- (IBAction)prev:(id)sender
+- (IBAction)next:(id)sender
{
intf_thread_t * p_intf = [NSApp getIntf];
+
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
return;
}
- playlist_Prev( p_playlist );
+ vlc_mutex_lock( &p_playlist->object_lock );
+
+ if( p_playlist->p_input == NULL )
+ {
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_release( p_playlist );
+ return;
+ }
+
+ vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
+
+#define p_area p_playlist->p_input->stream.p_selected_area
+
+ if( p_area->i_part_nb > 1 && p_area->i_part + 1 < p_area->i_part_nb )
+ {
+ p_area->i_part++;
+
+ vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
+ input_ChangeArea( p_playlist->p_input, p_area );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+
+ p_intf->p_sys->b_chapter_update = VLC_TRUE;
+ }
+ else
+ {
+ vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ playlist_Next( p_playlist );
+ }
+
+#undef p_area
+
vlc_object_release( p_playlist );
}
-- (IBAction)next:(id)sender
+- (IBAction)loop:(id)sender
{
intf_thread_t * p_intf = [NSApp getIntf];
+
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
return;
}
- playlist_Next( p_playlist );
+ config_PutInt( p_playlist, "loop",
+ !config_GetInt( p_playlist, "loop" ) );
+
vlc_object_release( p_playlist );
}
-- (IBAction)loop:(id)sender
+- (IBAction)forward:(id)sender
{
- NSMenuItem * o_mi = (NSMenuItem *)sender;
intf_thread_t * p_intf = [NSApp getIntf];
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
- if( p_playlist == NULL )
+ if( p_playlist == NULL || p_playlist->p_input == NULL )
{
+ if ( p_playlist != NULL ) vlc_object_release( p_playlist );
return;
}
- if( p_intf->p_sys->b_loop )
- {
- [o_mi setState: NSOffState];
- config_PutInt( p_playlist, "loop", 0 );
- }
- else
+ input_Seek( p_playlist->p_input, 5, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
+ vlc_object_release( p_playlist );
+}
+
+- (IBAction)backward:(id)sender
+{
+ intf_thread_t * p_intf = [NSApp getIntf];
+ playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist == NULL || p_playlist->p_input == NULL )
{
- [o_mi setState: NSOnState];
- config_PutInt( p_playlist, "loop", 1 );
+ if ( p_playlist != NULL ) vlc_object_release( p_playlist );
+ return;
}
- p_intf->p_sys->b_loop = !p_intf->p_sys->b_loop;
-
+ input_Seek( p_playlist->p_input, -5, INPUT_SEEK_SECONDS | INPUT_SEEK_CUR );
vlc_object_release( p_playlist );
}
- (IBAction)volumeUp:(id)sender
{
intf_thread_t * p_intf = [NSApp getIntf];
- aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
- FIND_ANYWHERE );
- if ( p_aout != NULL )
+
+ if( p_intf->p_sys->b_mute )
{
- if (p_intf->p_sys->b_mute)
- {
- [self mute:o_mi_mute];
- }
- aout_VolumeUp( p_aout, 1, NULL );
- vlc_object_release( (vlc_object_t *)p_aout );
+ [self mute: nil];
}
- [self setVolumeSlider];
+
+ aout_VolumeUp( p_intf, 1, NULL );
+
+ [self updateVolumeSlider];
}
- (IBAction)volumeDown:(id)sender
{
intf_thread_t * p_intf = [NSApp getIntf];
- aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
- FIND_ANYWHERE );
- if ( p_aout != NULL )
+
+ if( p_intf->p_sys->b_mute )
{
- if (p_intf->p_sys->b_mute)
- {
- [self mute:o_mi_mute];
- }
- aout_VolumeDown( p_aout, 1, NULL );
- vlc_object_release( (vlc_object_t *)p_aout );
+ [self mute: nil];
}
- [self setVolumeSlider];
+
+ aout_VolumeDown( p_intf, 1, NULL );
+
+ [self updateVolumeSlider];
}
- (IBAction)mute:(id)sender
{
intf_thread_t * p_intf = [NSApp getIntf];
- aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
- FIND_ANYWHERE );
audio_volume_t i_volume;
- if ( p_aout != NULL )
- {
- aout_VolumeMute( p_aout, &i_volume );
- vlc_object_release( (vlc_object_t *)p_aout );
- }
+ aout_VolumeMute( p_intf, &i_volume );
+ p_intf->p_sys->b_mute = ( i_volume == 0 );
+
+ [self updateVolumeSlider];
+}
+
+- (IBAction)volumeSliderUpdated:(id)sender
+{
+ intf_thread_t * p_intf = [NSApp getIntf];
+ audio_volume_t i_volume = (audio_volume_t)[sender intValue];
- p_intf->p_sys->b_mute = (i_volume == 0);
- [o_mi_mute setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
- [o_volumeslider setEnabled: p_intf->p_sys->b_mute ? FALSE : TRUE];
- [self setVolumeSlider];
+ aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_STEP );
}
-- (IBAction)volumeSliderUpdate:(id)sender
+- (void)updateVolumeSlider
{
intf_thread_t * p_intf = [NSApp getIntf];
- aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
- FIND_ANYWHERE );
audio_volume_t i_volume;
- if ( p_aout != NULL )
+ aout_VolumeGet( p_intf, &i_volume );
+
+ [o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)];
+}
+
+- (IBAction)halfWindow:(id)sender
+{
+ id o_window = [NSApp keyWindow];
+ NSArray *o_windows = [NSApp windows];
+ NSEnumerator *o_enumerator = [o_windows objectEnumerator];
+
+ while ((o_window = [o_enumerator nextObject]))
{
- i_volume = (int) [sender floatValue];
- aout_VolumeSet( p_aout, i_volume * AOUT_VOLUME_STEP);
- vlc_object_release( (vlc_object_t *)p_aout );
+ if( [[o_window className] isEqualToString: @"VLCWindow"] )
+ {
+ [o_window scaleWindowWithFactor: 0.5];
+ }
}
}
-- (void)setVolumeSlider
+- (IBAction)normalWindow:(id)sender
{
- intf_thread_t * p_intf = [NSApp getIntf];
- aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
- FIND_ANYWHERE );
- audio_volume_t i_volume;
+ id o_window = [NSApp keyWindow];
+ NSArray *o_windows = [NSApp windows];
+ NSEnumerator *o_enumerator = [o_windows objectEnumerator];
- if ( p_aout != NULL )
+ while ((o_window = [o_enumerator nextObject]))
{
- aout_VolumeGet( p_aout, &i_volume );
- vlc_object_release( (vlc_object_t *)p_aout );
- [o_volumeslider setFloatValue: (float) (i_volume / AOUT_VOLUME_STEP)];
+ if( [[o_window className] isEqualToString: @"VLCWindow"] )
+ {
+ [o_window scaleWindowWithFactor: 1];
+ }
}
- else
+}
+
+- (IBAction)doubleWindow:(id)sender
+{
+ id o_window = [NSApp keyWindow];
+ NSArray *o_windows = [NSApp windows];
+ NSEnumerator *o_enumerator = [o_windows objectEnumerator];
+
+ while ((o_window = [o_enumerator nextObject]))
{
- [o_volumeslider setFloatValue: config_GetInt( p_intf, "volume" )];
+ if( [[o_window className] isEqualToString: @"VLCWindow"] )
+ {
+ [o_window scaleWindowWithFactor: 2];
+ }
}
}
+
- (IBAction)fullscreen:(id)sender
{
id o_window = [NSApp keyWindow];
{
intf_thread_t * p_intf = [NSApp getIntf];
BOOL bEnable = [sender state] == NSOffState;
-
+
if( bEnable )
{
config_PutPsz( p_intf, "filter", "deinterlace" );
- config_PutPsz( p_intf, "deinterlace-mode",
- [[sender title] lossyCString] );
+ config_PutPsz( p_intf, "deinterlace-mode",
+ [[sender title] lossyCString] );
}
else
{
NSMenuItem * o_mi = (NSMenuItem *)sender;
intf_thread_t * p_intf = [NSApp getIntf];
+ playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist == NULL )
+ {
+ return;
+ }
+
+ vlc_mutex_lock( &p_playlist->object_lock );
+
+ if( p_playlist->p_input == NULL )
+ {
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_release( p_playlist );
+ return;
+ }
+
if( [o_mi state] == NSOffState )
{
u16 i_program_id = [o_mi tag];
- input_ChangeProgram( p_intf->p_sys->p_input, i_program_id );
- input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
+ input_ChangeProgram( p_playlist->p_input, i_program_id );
+ input_SetStatus( p_playlist->p_input, INPUT_STATUS_PLAY );
}
+
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_release( p_playlist );
}
- (IBAction)toggleTitle:(id)sender
NSMenuItem * o_mi = (NSMenuItem *)sender;
intf_thread_t * p_intf = [NSApp getIntf];
+ playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist == NULL )
+ {
+ return;
+ }
+
+ vlc_mutex_lock( &p_playlist->object_lock );
+
+ if( p_playlist->p_input == NULL )
+ {
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_release( p_playlist );
+ return;
+ }
+
if( [o_mi state] == NSOffState )
{
int i_title = [o_mi tag];
-#define p_input p_intf->p_sys->p_input
+#define p_input p_playlist->p_input
input_ChangeArea( p_input, p_input->stream.pp_areas[i_title] );
input_SetStatus( p_input, INPUT_STATUS_PLAY );
#undef p_input
}
+
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_release( p_playlist );
}
- (IBAction)toggleChapter:(id)sender
NSMenuItem * o_mi = (NSMenuItem *)sender;
intf_thread_t * p_intf = [NSApp getIntf];
+ playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist == NULL )
+ {
+ return;
+ }
+
+ vlc_mutex_lock( &p_playlist->object_lock );
+
+ if( p_playlist->p_input == NULL )
+ {
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_release( p_playlist );
+ return;
+ }
+
if( [o_mi state] == NSOffState )
{
int i_chapter = [o_mi tag];
-#define p_input p_intf->p_sys->p_input
+#define p_input p_playlist->p_input
p_input->stream.p_selected_area->i_part = i_chapter;
input_ChangeArea( p_input, p_input->stream.p_selected_area );
input_SetStatus( p_input, INPUT_STATUS_PLAY );
#undef p_input
}
+
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_release( p_playlist );
}
- (IBAction)toggleLanguage:(id)sender
NSMenuItem * o_mi = (NSMenuItem *)sender;
intf_thread_t * p_intf = [NSApp getIntf];
-#define p_input p_intf->p_sys->p_input
+ playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist == NULL )
+ {
+ return;
+ }
+
+ vlc_mutex_lock( &p_playlist->object_lock );
+
+ if( p_playlist->p_input == NULL )
+ {
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_release( p_playlist );
+ return;
+ }
+
+#if 0
+ /* We do not use this code, because you need to start stop .avi for
+ * it to work, so not very useful now --hartman */
+ if ( [o_mi state] == NSOffState && [o_mi tag] == 2000 )
+ {
+ NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
+
+ [o_open_panel setAllowsMultipleSelection: NO];
+ [o_open_panel setTitle: _NS("Open subtitle file")];
+ [o_open_panel setPrompt: _NS("Open")];
+
+ if( [o_open_panel runModalForDirectory: nil
+ file: nil types: nil] == NSOKButton )
+ {
+ NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
+ config_PutPsz( p_intf, "sub-file", strdup( [o_filename cString] ));
+ }
+ }
+#endif
+
+#define p_input p_playlist->p_input
if( !p_intf->p_sys->b_audio_update )
{
}
#undef p_input
+
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_release( p_playlist );
}
- (IBAction)toggleVar:(id)sender
{
NSMenuItem * o_mi = (NSMenuItem *)sender;
-
+
if( [o_mi state] == NSOffState )
{
const char * psz_variable = (const char *)[o_mi tag];
- const char * psz_value = [[o_mi title] cString];
+ char * psz_value = [NSApp delocalizeString: [o_mi title]];
vlc_object_t * p_object = (vlc_object_t *)
[[o_mi representedObject] pointerValue];
vlc_value_t val;
{
msg_Warn( p_object, "cannot set variable (%s)", psz_value );
}
+
+ free( psz_value );
}
}
NSMenu * o_menu = [o_mi menu];
intf_thread_t * p_intf = [NSApp getIntf];
+ playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+
+ if( p_playlist != NULL )
+ {
+ vlc_mutex_lock( &p_playlist->object_lock );
+ }
+
+#define p_input p_playlist->p_input
+
if( [[o_mi title] isEqualToString: _NS("Faster")] ||
[[o_mi title] isEqualToString: _NS("Slower")] )
{
- if( p_intf->p_sys->p_input != NULL )
+ if( p_playlist != NULL && p_input != NULL )
{
-#define p_input p_intf->p_sys->p_input
vlc_mutex_lock( &p_input->stream.stream_lock );
bEnabled = p_input->stream.b_pace_control;
vlc_mutex_unlock( &p_input->stream.stream_lock );
-#undef p_input
}
else
{
}
else if( [[o_mi title] isEqualToString: _NS("Stop")] )
{
- bEnabled = p_intf->p_sys->p_input != NULL;
+ if( p_playlist == NULL || p_input == NULL )
+ {
+ bEnabled = FALSE;
+ }
}
else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
[[o_mi title] isEqualToString: _NS("Next")] )
{
- playlist_t * p_playlist = vlc_object_find( p_intf,
- VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
if( p_playlist == NULL )
{
bEnabled = FALSE;
}
else
{
- vlc_mutex_lock( &p_playlist->object_lock );
bEnabled = p_playlist->i_size > 1;
- vlc_mutex_unlock( &p_playlist->object_lock );
- vlc_object_release( p_playlist );
+
+ if( p_input != NULL )
+ {
+ vlc_mutex_lock( &p_input->stream.stream_lock );
+ bEnabled |= p_input->stream.p_selected_area->i_part_nb > 1;
+ vlc_mutex_unlock( &p_input->stream.stream_lock );
+ }
}
}
- else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] )
+ else if( [[o_mi title] isEqualToString: _NS("Loop")] )
+ {
+ int i_state = config_GetInt( p_playlist, "loop" ) ?
+ NSOnState : NSOffState;
+
+ [o_mi setState: i_state];
+ }
+ else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||
+ [[o_mi title] isEqualToString: _NS("Step Backward")] )
+ {
+ if( p_playlist != NULL && p_input != NULL )
+ {
+ vlc_mutex_lock( &p_input->stream.stream_lock );
+ bEnabled = p_input->stream.b_seekable;
+ vlc_mutex_unlock( &p_input->stream.stream_lock );
+ }
+ else
+ {
+ bEnabled = FALSE;
+ }
+ }
+ else if( [[o_mi title] isEqualToString: _NS("Mute")] )
+ {
+ [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
+ }
+ else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] ||
+ [[o_mi title] isEqualToString: _NS("Half Size")] ||
+ [[o_mi title] isEqualToString: _NS("Normal Size")] ||
+ [[o_mi title] isEqualToString: _NS("Double Size")])
{
id o_window;
NSArray *o_windows = [NSApp windows];
}
else if( o_menu != nil &&
[[o_menu title] isEqualToString: _NS("Deinterlace")] )
- {
+ {
char * psz_filter = config_GetPsz( p_intf, "filter" );
-
+
if( psz_filter != NULL )
{
free( psz_filter );
-
+
psz_filter = config_GetPsz( p_intf, "deinterlace-mode" );
}
{
if( strcmp( psz_filter, [[o_mi title] lossyCString] ) == 0 )
{
- [o_mi setState: NSOnState];
+ [o_mi setState: NSOnState];
}
else
{
}
free( psz_filter );
- }
+ }
else
{
[o_mi setState: NSOffState];
}
- }
+ }
+
+ if( p_playlist != NULL )
+ {
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_release( p_playlist );
+ }
return( bEnabled );
}