Commit 7f8e2bc5 authored by Jon Lech Johansen's avatar Jon Lech Johansen

* ./modules/gui/macosx: Defeated some deadlocks.

                          World domination ... is at hand.
parent f3563dc1
......@@ -22,12 +22,12 @@
toggleTitle = id;
toggleVar = id;
volumeDown = id;
volumeSliderUpdate = id;
volumeSliderUpdated = id;
volumeUp = id;
};
CLASS = VLCControls;
LANGUAGE = ObjC;
OUTLETS = {"o_main" = id; "o_mi_mute" = id; "o_open" = id; "o_volumeslider" = id; };
OUTLETS = {"o_main" = id; "o_open" = id; "o_volumeslider" = id; };
SUPERCLASS = NSObject;
},
{
......@@ -45,13 +45,13 @@
CLASS = VLCMain;
LANGUAGE = ObjC;
OUTLETS = {
"o_btn_fastforward" = id;
"o_btn_faster" = id;
"o_btn_next" = id;
"o_btn_play" = id;
"o_btn_playlist" = id;
"o_btn_prefs" = id;
"o_btn_prev" = id;
"o_btn_slowmotion" = id;
"o_btn_slower" = id;
"o_btn_stop" = id;
"o_controls" = id;
"o_dmi_play" = id;
......
......@@ -7,7 +7,7 @@
<key>IBEditorPositions</key>
<dict>
<key>29</key>
<string>16 822 419 44 0 0 1280 1002 </string>
<string>22 973 419 44 0 0 1600 1178 </string>
<key>303</key>
<string>60 509 104 66 0 0 1280 1002 </string>
<key>909</key>
......@@ -23,8 +23,8 @@
</array>
<key>IBOpenObjects</key>
<array>
<integer>21</integer>
<integer>29</integer>
<integer>21</integer>
</array>
<key>IBSystem Version</key>
<string>6G30</string>
......
......@@ -2,7 +2,7 @@
* controls.m: MacOS X interface plugin
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: controls.m,v 1.18 2003/01/29 11:41:48 jlj Exp $
* $Id: controls.m,v 1.19 2003/01/31 02:53:52 jlj Exp $
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr>
......@@ -30,13 +30,6 @@
#include <sys/param.h> /* for MAXPATHLEN */
#include <string.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <vlc/aout.h>
#include <vlc/input.h>
#include <Cocoa/Cocoa.h>
#include "intf.h"
#include "vout.h"
......@@ -47,7 +40,7 @@
{
IBOutlet id o_open;
IBOutlet id o_main;
IBOutlet id o_mi_mute;
IBOutlet id o_volumeslider;
}
......@@ -63,7 +56,9 @@
- (IBAction)volumeUp:(id)sender;
- (IBAction)volumeDown:(id)sender;
- (IBAction)mute:(id)sender;
- (IBAction)volumeSliderUpdate:(id)sender;
- (IBAction)volumeSliderUpdated:(id)sender;
- (void)updateVolumeSlider;
- (IBAction)fullscreen:(id)sender;
- (IBAction)deinterlace:(id)sender;
......@@ -73,8 +68,6 @@
- (IBAction)toggleLanguage:(id)sender;
- (IBAction)toggleVar:(id)sender;
- (void)setVolumeSlider;
@end
/*****************************************************************************
......@@ -126,8 +119,6 @@
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
p_intf->p_sys->b_stopping = 1;
}
- (IBAction)faster:(id)sender
......@@ -284,87 +275,95 @@
- (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 )
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];
[self mute: nil];
}
aout_VolumeUp( p_aout, 1, NULL );
vlc_object_release( (vlc_object_t *)p_aout );
}
[self setVolumeSlider];
[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 )
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];
[self mute: nil];
}
aout_VolumeDown( p_aout, 1, NULL );
vlc_object_release( (vlc_object_t *)p_aout );
}
[self setVolumeSlider];
[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;
FIND_ANYWHERE );
if ( p_aout != NULL )
{
audio_volume_t i_volume;
aout_VolumeMute( p_aout, &i_volume );
vlc_object_release( (vlc_object_t *)p_aout );
p_intf->p_sys->b_mute = ( i_volume == 0 );
}
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];
[self updateVolumeSlider];
}
- (IBAction)volumeSliderUpdate:(id)sender
- (IBAction)volumeSliderUpdated:(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_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
if( p_aout != NULL )
{
i_volume = (int) [sender floatValue];
aout_VolumeSet( p_aout, i_volume * AOUT_VOLUME_STEP);
audio_volume_t i_volume;
i_volume = (audio_volume_t)[sender intValue];
aout_VolumeSet( p_aout, i_volume * AOUT_VOLUME_STEP );
vlc_object_release( (vlc_object_t *)p_aout );
}
}
- (void)setVolumeSlider
- (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;
FIND_ANYWHERE );
if ( p_aout != NULL )
{
audio_volume_t i_volume;
aout_VolumeGet( p_aout, &i_volume );
vlc_object_release( (vlc_object_t *)p_aout );
[o_volumeslider setFloatValue: (float) (i_volume / AOUT_VOLUME_STEP)];
}
else
{
[o_volumeslider setFloatValue: config_GetInt( p_intf, "volume" )];
[o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)];
}
}
......@@ -385,116 +384,75 @@
- (IBAction)deinterlace:(id)sender
{
intf_thread_t * p_intf = [NSApp getIntf];
NSMenuItem *o_mi = (NSMenuItem *)sender;
NSString *mode = [o_mi title];
char *psz_filter;
unsigned int i;
psz_filter = config_GetPsz( p_intf, "filter" );
}
if( [mode isEqualToString: @"none"] )
{
config_PutPsz( p_intf, "filter", "" );
}
else
- (IBAction)toggleProgram:(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( !psz_filter || !*psz_filter )
{
config_PutPsz( p_intf, "filter", "deinterlace" );
}
else
{
if( strstr( psz_filter, "deinterlace" ) == NULL )
{
psz_filter = realloc( psz_filter, strlen( psz_filter ) + 20 );
strcat( psz_filter, ",deinterlace" );
}
config_PutPsz( p_intf, "filter", psz_filter );
}
return;
}
if( psz_filter )
free( psz_filter );
vlc_mutex_lock( &p_playlist->object_lock );
/* now restart all video stream */
if( p_intf->p_sys->p_input )
if( p_playlist->p_input == NULL )
{
vout_thread_t *p_vout;
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
/* Warn the vout we are about to change the filter chain */
p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
if( p_vout )
{
p_vout->b_filter_change = VLC_TRUE;
vlc_object_release( p_vout );
}
#define ES p_intf->p_sys->p_input->stream.pp_es[i]
for( i = 0 ; i < p_intf->p_sys->p_input->stream.i_es_number ; i++ )
{
if( ( ES->i_cat == VIDEO_ES ) &&
ES->p_decoder_fifo != NULL )
{
input_UnselectES( p_intf->p_sys->p_input, ES );
input_SelectES( p_intf->p_sys->p_input, ES );
}
#undef ES
}
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist );
return;
}
if( ![mode isEqualToString: @"none"] )
if( [o_mi state] == NSOffState )
{
vout_thread_t *p_vout;
p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
if( p_vout )
{
vlc_value_t val;
val.psz_string = (char *)[mode cString];
if( var_Set( p_vout, "deinterlace-mode", val ) != VLC_SUCCESS )
config_PutPsz( p_intf, "deinterlace-mode", (char *)[mode cString] );
u16 i_program_id = [o_mi tag];
vlc_object_release( p_vout );
}
else {
config_PutPsz( p_intf, "deinterlace-mode", (char *)[mode cString] );
}
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)toggleProgram:(id)sender
- (IBAction)toggleTitle:(id)sender
{
NSMenuItem * o_mi = (NSMenuItem *)sender;
intf_thread_t * p_intf = [NSApp getIntf];
if( [o_mi state] == NSOffState )
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
{
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 );
return;
}
}
- (IBAction)toggleTitle:(id)sender
{
NSMenuItem * o_mi = (NSMenuItem *)sender;
intf_thread_t * p_intf = [NSApp getIntf];
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
......@@ -502,16 +460,35 @@
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
......@@ -519,6 +496,22 @@
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 0
/* We do not use this code, because you need to start stop .avi for
* it to work, so not very useful now --hartman */
......@@ -539,7 +532,7 @@
}
#endif
#define p_input p_intf->p_sys->p_input
#define p_input p_playlist->p_input
if( !p_intf->p_sys->b_audio_update )
{
......@@ -581,6 +574,9 @@
}
#undef p_input
vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist );
}
- (IBAction)toggleVar:(id)sender
......@@ -622,14 +618,16 @@
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_playlist != NULL && p_playlist->p_input != NULL )
if( p_playlist != NULL && p_input != NULL )
{
vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
bEnabled = p_playlist->p_input->stream.b_pace_control;
vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
vlc_mutex_lock( &p_input->stream.stream_lock );
bEnabled = p_input->stream.b_pace_control;
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
else
{
......@@ -638,7 +636,7 @@
}
else if( [[o_mi title] isEqualToString: _NS("Stop")] )
{
if( p_playlist == NULL || p_playlist->p_input == NULL )
if( p_playlist == NULL || p_input == NULL )
{
bEnabled = FALSE;
}
......@@ -653,6 +651,13 @@
else
{
bEnabled = p_playlist->i_size > 1;
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("Loop")] )
......@@ -662,6 +667,39 @@
[o_mi setState: i_state];
}
else if( [[o_mi title] isEqualToString: _NS("Volume Up")] ||
[[o_mi title] isEqualToString: _NS("Volume Down")] )
{
aout_instance_t * p_aout;
p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
if( p_aout != NULL )
{
vlc_object_release( (vlc_object_t *)p_aout );
}
else
{
bEnabled = FALSE;
}
}
else if( [[o_mi title] isEqualToString: _NS("Mute")] )
{
aout_instance_t * p_aout;
p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
if( p_aout != NULL )
{
vlc_object_release( (vlc_object_t *)p_aout );
}
else
{
bEnabled = FALSE;
}
[o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
}
else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] )
{
id o_window;
......@@ -681,32 +719,7 @@
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( psz_filter != NULL )
{
if( strcmp( psz_filter, [[o_mi title] lossyCString] ) == 0 )
{
[o_mi setState: NSOnState];
}
else
{
[o_mi setState: NSOffState];
}
free( psz_filter );
}
else
{
[o_mi setState: NSOffState];
}
}
if( p_playlist != NULL )
......
......@@ -2,7 +2,7 @@
* intf.h: MacOS X interface plugin
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: intf.h,v 1.19 2003/01/29 11:34:11 jlj Exp $
* $Id: intf.h,v 1.20 2003/01/31 02:53:52 jlj Exp $
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr>
......@@ -26,6 +26,7 @@
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <vlc/vout.h>
#include <vlc/aout.h>
#include <Cocoa/Cocoa.h>
......@@ -48,6 +49,8 @@
#define _NS(s) [NSApp localizedString: _(s)]
int ExecuteOnMainThread( id target, SEL sel, void * p_arg );
/*****************************************************************************
* intf_sys_t: description and status of the interface
*****************************************************************************/
......@@ -58,9 +61,12 @@ struct intf_sys_t
/* special actions */
vlc_bool_t b_playing;
vlc_bool_t b_stopping;
vlc_bool_t b_mute;
/* interface update */
vlc_bool_t b_intf_update;
vlc_bool_t b_play_status;
/* menus handlers */