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 */
vlc_bool_t b_chapter_update;
vlc_bool_t b_program_update;
......@@ -70,9 +76,6 @@ struct intf_sys_t
vlc_bool_t b_aout_update;
vlc_bool_t b_vout_update;
/* The input thread */
input_thread_t * p_input;
/* The messages window */
msg_subscription_t * p_sub;
......@@ -96,13 +99,16 @@ struct intf_sys_t
IBOutlet id o_btn_playlist; /* btn playlist */
IBOutlet id o_btn_prev; /* btn previous */
IBOutlet id o_btn_slowmotion; /* btn slowmotion */
IBOutlet id o_btn_slower; /* btn slower */
IBOutlet id o_btn_play; /* btn play */
IBOutlet id o_btn_stop; /* btn stop */
IBOutlet id o_btn_fastforward; /* btn fastforward */
IBOutlet id o_btn_faster; /* btn faster */
IBOutlet id o_btn_next; /* btn next */
IBOutlet id o_btn_prefs; /* btn prefs */
NSImage * o_img_play; /* btn play img */
NSImage * o_img_pause; /* btn pause img */
IBOutlet id o_controls; /* VLCControls */
IBOutlet id o_playlist; /* VLCPlaylist */
......@@ -191,11 +197,18 @@ struct intf_sys_t
- (void)terminate;
- (void)manage;
- (void)manageMode;
- (void)setControlItems;
- (void)setupMenus;
- (void)setupLangMenu:(NSMenuItem *)o_mi
- (void)manage:(playlist_t *)p_playlist;
- (void)manageMode:(playlist_t *)p_playlist;
- (void)manageIntf:(NSTimer *)o_timer;
- (void)updateMessageArray;
- (void)playStatusUpdated:(BOOL)b_pause;
- (void)setSubmenusEnabled:(BOOL)b_enabled;
- (void)manageVolumeSlider;
- (void)setupMenus:(input_thread_t *)p_input;
- (void)setupLangMenu:(input_thread_t *)p_input
mi:(NSMenuItem *)o_mi
es:(es_descriptor_t *)p_es
category:(int)i_cat
selector:(SEL)pf_callback;
......@@ -210,7 +223,6 @@ struct intf_sys_t
- (IBAction)viewPreferences:(id)sender;
- (IBAction)timesliderUpdate:(id)sender;
- (void)displayTime;
- (IBAction)closeError:(id)sender;
......
......@@ -2,7 +2,7 @@
* intf.m: MacOS X interface plugin
*****************************************************************************
* Copyright (C) 2002-2003 VideoLAN
* $Id: intf.m,v 1.41 2003/01/30 15:46:29 hartman Exp $
* $Id: intf.m,v 1.42 2003/01/31 02:53:52 jlj Exp $
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr>
......@@ -30,8 +30,6 @@
#include <sys/param.h> /* for MAXPATHLEN */
#include <string.h>
#include <QuickTime/QuickTime.h>
#include "intf.h"
#include "vout.h"
#include "prefs.h"
......@@ -40,7 +38,7 @@
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
static void Run ( intf_thread_t *p_intf );
static void Run ( intf_thread_t *p_intf );
/*****************************************************************************
* OpenIntf: initialize interface
......@@ -143,12 +141,17 @@ static void Run( intf_thread_t *p_intf )
- (NSString *)localizedString:(char *)psz
{
if ( psz == NULL ) return NULL;
UInt32 uiLength = (UInt32)strlen( psz );
NSData * o_data = [NSData dataWithBytes: psz length: uiLength];
NSString *o_str = [[NSString alloc] initWithData: o_data
encoding: i_encoding];
return( [o_str autorelease] );
NSString * o_str = nil;
if( psz != NULL )
{
UInt32 uiLength = (UInt32)strlen( psz );
NSData * o_data = [NSData dataWithBytes: psz length: uiLength];
o_str = [[[NSString alloc] initWithData: o_data
encoding: i_encoding] autorelease];
}
return( o_str );
}
- (void)setIntf:(intf_thread_t *)_p_intf
......@@ -163,28 +166,80 @@ static void Run( intf_thread_t *p_intf )
- (void)terminate:(id)sender
{
[self getIntf]->p_vlc->b_die = VLC_TRUE;
p_intf->p_vlc->b_die = VLC_TRUE;
}
@end
/*****************************************************************************
* VLCMain implementation
*****************************************************************************/
@implementation VLCMain
- (id)init
int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
{
self = [super init];
int i_ret = 0;
if( self != nil )
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
if( [target respondsToSelector: @selector(performSelectorOnMainThread:
withObject:waitUntilDone:)] )
{
o_prefs = nil;
[target performSelectorOnMainThread: sel
withObject: [NSValue valueWithPointer: p_arg]
waitUntilDone: YES];
}
else if( NSApp != nil && [NSApp respondsToSelector: @selector(getIntf)] )
{
NSValue * o_v1;
NSValue * o_v2;
NSArray * o_array;
NSPort * o_recv_port;
NSInvocation * o_inv;
NSPortMessage * o_msg;
intf_thread_t * p_intf;
NSConditionLock * o_lock;
NSMethodSignature * o_sig;
id * val[] = { &o_lock, &o_v2 };
p_intf = (intf_thread_t *)[NSApp getIntf];
o_recv_port = [[NSPort port] retain];
o_v1 = [NSValue valueWithPointer: val];
o_v2 = [NSValue valueWithPointer: p_arg];
o_sig = [target methodSignatureForSelector: sel];
o_inv = [NSInvocation invocationWithMethodSignature: o_sig];
[o_inv setArgument: &o_v1 atIndex: 2];
[o_inv setTarget: target];
[o_inv setSelector: sel];
o_array = [NSArray arrayWithObject:
[NSData dataWithBytes: &o_inv length: sizeof(o_inv)]];
o_msg = [[NSPortMessage alloc]
initWithSendPort: p_intf->p_sys->o_sendport
receivePort: o_recv_port components: o_array];
o_lock = [[NSConditionLock alloc] initWithCondition: 0];
[o_msg sendBeforeDate: [NSDate distantPast]];
[o_lock lockWhenCondition: 1];
[o_lock unlock];
[o_lock release];
[o_msg release];
[o_recv_port release];
}
else
{
i_ret = 1;
}
[o_pool release];
return( self );
return( i_ret );
}
/*****************************************************************************
* VLCMain implementation
*****************************************************************************/
@implementation VLCMain
- (void)awakeFromNib
{
[o_window setTitle: _NS("VLC - Controller")];
......@@ -193,16 +248,15 @@ static void Run( intf_thread_t *p_intf )
/* button controls */
[o_btn_playlist setToolTip: _NS("Playlist")];
[o_btn_prev setToolTip: _NS("Previous")];
[o_btn_slowmotion setToolTip: _NS("Slowmotion")];
[o_btn_slower setToolTip: _NS("Slower")];
[o_btn_play setToolTip: _NS("Play")];
[o_btn_stop setToolTip: _NS("Stop")];
[o_btn_fastforward setToolTip: _NS("Fast Forward")];
[o_btn_fastforward setPeriodicDelay: 0.0 interval: 1];
[o_btn_faster setToolTip: _NS("Faster")];
[o_btn_next setToolTip: _NS("Next")];
[o_btn_prefs setToolTip: _NS("Preferences")];
[o_volumeslider setToolTip: _NS("Volume")];
[o_timeslider setToolTip: _NS("Position")];
/* messages panel */
[o_msgs_panel setDelegate: self];
[o_msgs_panel setTitle: _NS("Messages")];
......@@ -279,30 +333,36 @@ static void Run( intf_thread_t *p_intf )
/* error panel */
[o_error setTitle: _NS("Error")];
[o_err_lbl setStringValue: _NS("An error has occurred which probably prevented the execution of your request :")];
[o_err_bug_lbl setStringValue: _NS("If you believe that it is a bug, please follow the instructions at :")];
[o_err_lbl setStringValue: _NS("An error has occurred which probably prevented the execution of your request:")];
[o_err_bug_lbl setStringValue: _NS("If you believe that it is a bug, please follow the instructions at:")];
[o_err_btn_msgs setTitle: _NS("Open Messages Window")];
[o_err_btn_dismiss setTitle: _NS("Dismiss")];
[self manageMode];
[self setSubmenusEnabled: FALSE];
[self manageVolumeSlider];
}
- (void)applicationWillFinishLaunching:(NSNotification *)o_notification
{
intf_thread_t * p_intf = [NSApp getIntf];
f_slider_old = f_slider = 0.0;
o_msg_lock = [[NSLock alloc] init];
o_msg_arr = [[NSMutableArray arrayWithCapacity: 200] retain];
[NSThread detachNewThreadSelector: @selector(manage)
toTarget: self withObject: nil];
o_img_play = [[NSImage imageNamed: @"play"] retain];
o_img_pause = [[NSImage imageNamed: @"pause"] retain];
[p_intf->p_sys->o_sendport setDelegate: self];
[[NSRunLoop currentRunLoop]
addPort: p_intf->p_sys->o_sendport
forMode: NSDefaultRunLoopMode];
[NSTimer scheduledTimerWithTimeInterval: 0.1
target: self selector: @selector(manageIntf:)
userInfo: nil repeats: TRUE];
[NSThread detachNewThreadSelector: @selector(manage)
toTarget: self withObject: nil];
}
- (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename
......@@ -323,215 +383,455 @@ static void Run( intf_thread_t *p_intf )
while( !p_intf->b_die )
{
int i_start, i_stop;
playlist_t * p_playlist;
vlc_mutex_lock( &p_intf->change_lock );
/* update the input */
if( p_intf->p_sys->p_input == NULL )
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist != NULL )
{
p_intf->p_sys->p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
[self setControlItems];
vlc_mutex_lock( &p_playlist->object_lock );
[self manage: p_playlist];
vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist );
}
else if( p_intf->p_sys->p_input->b_dead )
{
vlc_object_release( p_intf->p_sys->p_input );
p_intf->p_sys->p_input = NULL;
if( p_intf->p_sys->b_stopping )
{
vout_thread_t * p_vout = vlc_object_find( p_intf,
VLC_OBJECT_VOUT,
FIND_ANYWHERE );
vlc_mutex_unlock( &p_intf->change_lock );
if( p_vout != NULL )
{
vlc_object_detach( p_vout );
vlc_object_release( p_vout );
vout_Destroy( p_vout );
}
p_intf->p_sys->b_stopping = 0;
[self setControlItems];
}
o_sleep_date = [NSDate dateWithTimeIntervalSinceNow: 0.1];
[NSThread sleepUntilDate: o_sleep_date];
}
[self displayTime];
[self manageMode];
}
[self terminate];
if( p_intf->p_sys->p_input != NULL && !p_intf->p_sys->p_input->b_die )
{
vlc_bool_t b_need_menus = 0;
input_thread_t * p_input = p_intf->p_sys->p_input;
aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
vout_thread_t * p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
[o_pool release];
}
- (void)manage:(playlist_t *)p_playlist
{
intf_thread_t * p_intf = [NSApp getIntf];
/* Disable screen saver. */
UpdateSystemActivity( UsrActivity );
#define p_input p_playlist->p_input
vlc_mutex_lock( &p_input->stream.stream_lock );
if( p_input )
{
vout_thread_t * p_vout = NULL;
aout_instance_t * p_aout = NULL;
vlc_bool_t b_need_menus = VLC_FALSE;
[self displayTime];
vlc_mutex_lock( &p_input->stream.stream_lock );
if( !p_input->b_die )
{
/* New input or stream map change */
if( p_input->stream.b_changed )
{
[self manageMode];
b_need_menus = 1;
p_intf->p_sys->b_playing = 1;
[self manageMode: p_playlist];
b_need_menus = VLC_TRUE;
}
if( p_intf->p_sys->i_part !=
p_input->stream.p_selected_area->i_part )
{
p_intf->p_sys->b_chapter_update = 1;
b_need_menus = 1;
b_need_menus = VLC_TRUE;
}
if ( p_aout != NULL )
p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
if( p_aout != NULL )
{
vlc_value_t val;
if ( var_Get( (vlc_object_t *)p_aout, "intf-change", &val )
>= 0 && val.b_bool )
audio_volume_t i_volume;
if( var_Get( (vlc_object_t *)p_aout, "intf-change", &val )
>= 0 && val.b_bool )
{
p_intf->p_sys->b_aout_update = 1;
b_need_menus = 1;
b_need_menus = VLC_TRUE;
}
aout_VolumeGet( p_aout, &i_volume );
vlc_object_release( (vlc_object_t *)p_aout );
p_intf->p_sys->b_mute = ( i_volume == 0 );
}
if ( p_vout != NULL )
p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
if( p_vout != NULL )
{
vlc_value_t val;
if ( var_Get( (vlc_object_t *)p_vout, "intf-change", &val )
>= 0 && val.b_bool )
if( var_Get( (vlc_object_t *)p_vout, "intf-change", &val )
>= 0 && val.b_bool )
{
p_intf->p_sys->b_vout_update = 1;
b_need_menus = 1;
b_need_menus = VLC_TRUE;
}
vlc_object_release( (vlc_object_t *)p_vout );
}
if( b_need_menus )
{
[self setupMenus: p_input];
}
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
else if( p_intf->p_sys->b_playing && !p_intf->b_die )
{
p_intf->p_sys->b_playing = 0;
[self manageMode: p_playlist];
}
#undef p_input
}
- (void)manageMode:(playlist_t *)p_playlist
{
intf_thread_t * p_intf = [NSApp getIntf];
if( p_playlist->p_input != NULL )
{
/* get ready for menu regeneration */
p_intf->p_sys->b_program_update = 1;
p_intf->p_sys->b_title_update = 1;
p_intf->p_sys->b_chapter_update = 1;
p_intf->p_sys->b_audio_update = 1;
p_intf->p_sys->b_spu_update = 1;
p_intf->p_sys->i_part = 0;
if ( b_need_menus )
[self setupMenus];
[self setControlItems];
vlc_mutex_unlock( &p_input->stream.stream_lock );
p_playlist->p_input->stream.b_changed = 0;
msg_Dbg( p_intf, "stream has changed, refreshing interface" );
}
else
{
vout_thread_t * p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
if( p_vout != NULL )
{
vlc_object_detach( p_vout );
vlc_object_release( p_vout );
vlc_mutex_unlock( &p_playlist->object_lock );
vout_Destroy( p_vout );
vlc_mutex_lock( &p_playlist->object_lock );
}
else if( p_intf->p_sys->b_playing && !p_intf->b_die )
aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
if( p_aout != NULL )
{
[self displayTime];
[self manageMode];
p_intf->p_sys->b_playing = 0;
p_intf->p_sys->b_stopping = 1;
vlc_object_detach( (vlc_object_t *)p_aout );
vlc_object_release( (vlc_object_t *)p_aout );
aout_Delete( p_aout );
}
}
/* update the log window */
vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock );
i_stop = *p_intf->p_sys->p_sub->pi_stop;
vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );
p_intf->p_sys->b_intf_update = VLC_TRUE;
}
- (void)manageIntf:(NSTimer *)o_timer
{
intf_thread_t * p_intf = [NSApp getIntf];
if( p_intf->p_vlc->b_die == VLC_TRUE )
{
[o_timer invalidate];
return;
}
if( p_intf->p_sys->p_sub->i_start != i_stop )
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 );
#define p_input p_playlist->p_input
if( p_input != NULL )
{
vlc_mutex_lock( &p_input->stream.stream_lock );
}
if( p_intf->p_sys->b_intf_update )
{
vlc_bool_t b_input = VLC_FALSE;
vlc_bool_t b_plmul = VLC_FALSE;
vlc_bool_t b_control = VLC_FALSE;
vlc_bool_t b_seekable = VLC_FALSE;
vlc_bool_t b_chapters = VLC_FALSE;
b_plmul = p_playlist->i_size > 1;
if( ( b_input = ( p_input != NULL ) ) )
{
NSColor *o_white = [NSColor whiteColor];
NSColor *o_red = [NSColor redColor];
NSColor *o_yellow = [NSColor yellowColor];
NSColor *o_gray = [NSColor grayColor];
NSColor * pp_color[4] = { o_white, o_red, o_yellow, o_gray };
static const char * ppsz_type[4] = { ": ", " error: ",
" warning: ", " debug: " };
for( i_start = p_intf->p_sys->p_sub->i_start;
i_start != i_stop;
i_start = (i_start+1) % VLC_MSG_QSIZE )
{
NSString *o_msg;
NSDictionary *o_attr;
NSAttributedString *o_msg_color;
/* seekable streams */
b_seekable = p_input->stream.b_seekable;
int i_type = p_intf->p_sys->p_sub->p_msg[i_start].i_type;
/* control buttons for free pace streams */
b_control = p_input->stream.b_pace_control;
[o_msg_lock lock];
/* chapters */
b_chapters = p_input->stream.p_selected_area->i_part_nb > 1;
if( [o_msg_arr count] + 2 > 200 )
{
unsigned rid[] = { 0, 1 };
[o_msg_arr removeObjectsFromIndices: (unsigned *)&rid
numIndices: sizeof(rid)/sizeof(rid[0])];
}
/* play status */
p_intf->p_sys->b_play_status =
p_input->stream.control.i_status != PAUSE_S;
}
else
{
/* play status */
p_intf->p_sys->b_play_status = VLC_FALSE;
o_attr = [NSDictionary dictionaryWithObject: o_gray
forKey: NSForegroundColorAttributeName];
o_msg = [NSString stringWithFormat: @"%s%s",
p_intf->p_sys->p_sub->p_msg[i_start].psz_module,
ppsz_type[i_type]];
o_msg_color = [[NSAttributedString alloc]
initWithString: o_msg attributes: o_attr];
[o_msg_arr addObject: [o_msg_color autorelease]];
o_attr = [NSDictionary dictionaryWithObject: pp_color[i_type]
forKey: NSForegroundColorAttributeName];
o_msg = [NSString stringWithFormat: @"%s\n",
p_intf->p_sys->p_sub->p_msg[i_start].psz_msg];
o_msg_color = [[NSAttributedString alloc]
initWithString: o_msg attributes: o_attr];
[o_msg_arr addObject: [o_msg_color autorelease]];
[self setSubmenusEnabled: FALSE];
}
[self playStatusUpdated: p_intf->p_sys->b_play_status];
[o_btn_stop setEnabled: b_input];
[o_btn_faster setEnabled: b_control];
[o_btn_slower setEnabled: b_control];
[o_btn_prev setEnabled: (b_plmul || b_chapters)];
[o_btn_next setEnabled: (b_plmul || b_chapters)];
[o_timeslider setFloatValue: 0.0];
[o_timeslider setEnabled: b_seekable];
[o_timefield setStringValue: @"0:00:00"];
[self manageVolumeSlider];
p_intf->p_sys->b_intf_update = VLC_FALSE;
}
#define p_area p_input->stream.p_selected_area
if( p_intf->p_sys->b_playing && p_input != NULL )
{
vlc_bool_t b_field_update = VLC_TRUE;
if( !p_input->b_die && ( p_intf->p_sys->b_play_status !=
( p_input->stream.control.i_status != PAUSE_S ) ) )
{
p_intf->p_sys->b_play_status =
!p_intf->p_sys->b_play_status;
[o_msg_lock unlock];
[self playStatusUpdated: p_intf->p_sys->b_play_status];
}
if( p_input->stream.b_seekable )
{
if( f_slider == f_slider_old )
{
float f_updated = ( 100. * p_area->i_tell ) /
p_area->i_size;
if ( i_type == 1 )
if( f_slider != f_updated )
{
/* Error panel */
NSString *o_my_msg =
[NSString stringWithFormat: @"%s: %s\n",
p_intf->p_sys->p_sub->p_msg[i_start].psz_module,
p_intf->p_sys->p_sub->p_msg[i_start].psz_msg];
[o_err_msg setEditable: YES];
[o_err_msg setSelectedRange:
NSMakeRange( [[o_err_msg string] length], 0 )];
[o_err_msg insertText: o_my_msg];
[o_error makeKeyAndOrderFront: self];
[o_err_msg setEditable: NO];
[o_timeslider setFloatValue: f_updated];
}
}
else
{
off_t i_seek = ( f_slider * p_area->i_size ) / 100;
vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock );
p_intf->p_sys->p_sub->i_start = i_start;
vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );
/* release the lock to be able to seek */
vlc_mutex_unlock( &p_input->stream.stream_lock );
input_Seek( p_input, i_seek, INPUT_SEEK_SET );
vlc_mutex_lock( &p_input->stream.stream_lock );
/* update the old value */
f_slider_old = f_slider;
b_field_update = VLC_FALSE;
}
}
vlc_mutex_unlock( &p_intf->change_lock );
if( b_field_update )
{
NSString * o_time;
char psz_time[ OFFSETTOTIME_MAX_SIZE ];
o_sleep_date = [NSDate dateWithTimeIntervalSinceNow: 0.1];
[NSThread sleepUntilDate: o_sleep_date];
input_OffsetToTime( p_input, psz_time, p_area->i_tell );
o_time = [NSString stringWithCString: psz_time];
[o_timefield setStringValue: o_time];
}
/* disable screen saver */
UpdateSystemActivity( UsrActivity );
}
[self terminate];
#undef p_area
[o_pool release];
if( p_input != NULL )
{
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
#undef p_input
vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist );
[self updateMessageArray];
}
- (void)terminate
- (void)updateMessageArray
{
NSEvent * pEvent;
vout_thread_t * p_vout;
playlist_t * p_playlist;
int i_start, i_stop;
intf_thread_t * p_intf = [NSApp getIntf];
vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock );
i_stop = *p_intf->p_sys->p_sub->pi_stop;
vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );
if( p_intf->p_sys->p_sub->i_start != i_stop )
{
NSColor *o_white = [NSColor whiteColor];
NSColor *o_red = [NSColor redColor];
NSColor *o_yellow = [NSColor yellowColor];
NSColor *o_gray = [NSColor grayColor];
NSColor * pp_color[4] = { o_white, o_red, o_yellow, o_gray };
static const char * ppsz_type[4] = { ": ", " error: ",
" warning: ", " debug: " };
for( i_start = p_intf->p_sys->p_sub->i_start;
i_start != i_stop;
i_start = (i_start+1) % VLC_MSG_QSIZE )
{
NSString *o_msg;
NSDictionary *o_attr;
NSAttributedString *o_msg_color;
int i_type = p_intf->p_sys->p_sub->p_msg[i_start].i_type;
[o_msg_lock lock];
if( [o_msg_arr count] + 2 > 200 )
{
unsigned rid[] = { 0, 1 };
[o_msg_arr removeObjectsFromIndices: (unsigned *)&rid
numIndices: sizeof(rid)/sizeof(rid[0])];
}
o_attr = [NSDictionary dictionaryWithObject: o_gray
forKey: NSForegroundColorAttributeName];
o_msg = [NSString stringWithFormat: @"%s%s",
p_intf->p_sys->p_sub->p_msg[i_start].psz_module,
ppsz_type[i_type]];
o_msg_color = [[NSAttributedString alloc]
initWithString: o_msg attributes: o_attr];
[o_msg_arr addObject: [o_msg_color autorelease]];
o_attr = [NSDictionary dictionaryWithObject: pp_color[i_type]
forKey: NSForegroundColorAttributeName];
o_msg = [NSString stringWithFormat: @"%s\n",
p_intf->p_sys->p_sub->p_msg[i_start].psz_msg];
o_msg_color = [[NSAttributedString alloc]
initWithString: o_msg attributes: o_attr];
[o_msg_arr addObject: [o_msg_color autorelease]];
[o_msg_lock unlock];
if( i_type == 1 )
{
NSString *o_my_msg = [NSString stringWithFormat: @"%s: %s\n",
p_intf->p_sys->p_sub->p_msg[i_start].psz_module,
p_intf->p_sys->p_sub->p_msg[i_start].psz_msg];
NSRange s_r = NSMakeRange( [[o_err_msg string] length], 0 );
[o_err_msg setEditable: YES];
[o_err_msg setSelectedRange: s_r];
[o_err_msg insertText: o_my_msg];
[o_error makeKeyAndOrderFront: self];
[o_err_msg setEditable: NO];
}
}
vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock );
p_intf->p_sys->p_sub->i_start = i_start;
vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );
}
}
- (void)playStatusUpdated:(BOOL)b_pause
{
if( b_pause )
{
[o_btn_play setImage: o_img_pause];
[o_btn_play setToolTip: _NS("Pause")];
[o_mi_play setTitle: _NS("Pause")];
[o_dmi_play setTitle: _NS("Pause")];
}
else
{
[o_btn_play setImage: o_img_play];
[o_btn_play setToolTip: _NS("Play")];
[o_mi_play setTitle: _NS("Play")];
[o_dmi_play setTitle: _NS("Play")];
}
}
- (void)setSubmenusEnabled:(BOOL)b_enabled
{
[o_mi_program setEnabled: b_enabled];
[o_mi_title setEnabled: b_enabled];
[o_mi_chapter setEnabled: b_enabled];
[o_mi_language setEnabled: b_enabled];
[o_mi_subtitle setEnabled: b_enabled];
[o_mi_channels setEnabled: b_enabled];
[o_mi_device setEnabled: b_enabled];
[o_mi_screen setEnabled: b_enabled];
}
- (void)manageVolumeSlider
{
audio_volume_t i_volume;
vlc_bool_t b_audio = VLC_FALSE;
intf_thread_t * p_intf = [NSApp getIntf];
/* release input */
if( p_intf->p_sys->p_input )
aout_instance_t * p_aout = vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
if( p_aout != NULL )
{
b_audio = VLC_TRUE;
aout_VolumeGet( p_aout, &i_volume );
vlc_object_release( (vlc_object_t *)p_aout );
}
else
{
vlc_object_release( p_intf->p_sys->p_input );
p_intf->p_sys->p_input = NULL;
i_volume = (audio_volume_t)config_GetInt( p_intf, "volume" );
}
[o_volumeslider setFloatValue: (float)i_volume / AOUT_VOLUME_STEP];
[o_volumeslider setEnabled: b_audio];
p_intf->p_sys->b_mute = ( i_volume == 0 );
}
- (void)terminate
{
NSEvent * o_event;
vout_thread_t * p_vout;
playlist_t * p_playlist;
intf_thread_t * p_intf = [NSApp getIntf];
/*
* Free playlists
*/
......@@ -556,6 +856,18 @@ static void Run( intf_thread_t *p_intf )
vout_Destroy( p_vout );
}
if( o_img_pause != nil )
{
[o_img_pause release];
o_img_pause = nil;
}
if( o_img_play != nil )
{
[o_img_play release];
o_img_play = nil;
}
if( o_msg_arr != nil )
{
[o_msg_arr removeAllObjects];
......@@ -581,109 +893,15 @@ static void Run( intf_thread_t *p_intf )
[[NSUserDefaults standardUserDefaults] synchronize];
/* send a dummy event to break out of the event loop */
pEvent = [NSEvent mouseEventWithType: NSLeftMouseDown
o_event = [NSEvent mouseEventWithType: NSLeftMouseDown
location: NSMakePoint( 1, 1 ) modifierFlags: 0
timestamp: 1 windowNumber: [[NSApp mainWindow] windowNumber]
context: [NSGraphicsContext currentContext] eventNumber: 1
clickCount: 1 pressure: 0.0];
[NSApp postEvent: pEvent atStart: YES];
}
- (void)manageMode
{
vlc_bool_t b_input;
vlc_bool_t b_control = 0;
intf_thread_t * p_intf = [NSApp getIntf];
if( ( b_input = ( p_intf->p_sys->p_input != NULL ) ) )
{
/* control buttons for free pace streams */
b_control = p_intf->p_sys->p_input->stream.b_pace_control;
/* get ready for menu regeneration */
p_intf->p_sys->b_program_update = 1;
p_intf->p_sys->b_title_update = 1;
p_intf->p_sys->b_chapter_update = 1;
p_intf->p_sys->b_audio_update = 1;
p_intf->p_sys->b_spu_update = 1;
p_intf->p_sys->i_part = 0;
p_intf->p_sys->p_input->stream.b_changed = 0;
msg_Dbg( p_intf, "stream has changed, refreshing interface" );
}
else
{
/* unsensitize menus */
[o_mi_program setEnabled: FALSE];
[o_mi_title setEnabled: FALSE];
[o_mi_chapter setEnabled: FALSE];
[o_mi_language setEnabled: FALSE];
[o_mi_subtitle setEnabled: FALSE];
[o_mi_channels setEnabled: FALSE];
[o_mi_device setEnabled: FALSE];
[o_mi_screen setEnabled: FALSE];
[o_mi_close_window setEnabled: FALSE];
}
[self setControlItems];
[NSApp postEvent: o_event atStart: YES];
}
- (void)setControlItems {
intf_thread_t * p_intf = [NSApp getIntf];
vlc_bool_t b_input;
vlc_bool_t b_plmul = NO;
vlc_bool_t b_control = NO;
vlc_bool_t b_chapters = NO;
input_area_t * p_area;
playlist_t * p_playlist = NULL;
NSImage *playImage = [NSImage imageNamed:@"play"];
NSImage *pauseImage = [NSImage imageNamed:@"pause"];
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist != NULL )
{
vlc_mutex_lock( &p_playlist->object_lock );
b_plmul = p_playlist->i_size > 1;
vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist );
}
if ( ( b_input = ( p_intf->p_sys->p_input != NULL ) ) )
{
/* control buttons for free pace streams */
b_control = p_intf->p_sys->p_input->stream.b_pace_control;
p_area = p_intf->p_sys->p_input->stream.p_selected_area;
if ( p_area->i_part_nb > 1 )
b_chapters = YES;
}
/* set control items */
[o_btn_stop setEnabled: b_input];
[o_btn_fastforward setEnabled: b_control];
[o_btn_slowmotion setEnabled: b_control];
[o_btn_prev setEnabled: (b_plmul || b_chapters) ];
[o_btn_next setEnabled: (b_plmul || b_chapters) ];
[o_controls setVolumeSlider];
[o_timeslider setEnabled: b_input];
if ( p_intf->p_sys->p_input != NULL &&
p_intf->p_sys->p_input->stream.control.i_status != PAUSE_S)
{
[o_btn_play setImage: pauseImage];
[o_btn_play setToolTip: _NS("Pause")];
[o_mi_play setTitle: _NS("Pause")];
[o_dmi_play setTitle: _NS("Pause")];
}
else
{
[o_btn_play setImage: playImage];
[o_btn_play setToolTip: _NS("Play")];
[o_mi_play setTitle: _NS("Play")];
[o_dmi_play setTitle: _NS("Play")];
}
}
- (void)setupMenus
- (void)setupMenus:(input_thread_t *)p_input
{
unsigned int i, i_nb_items;
NSMenuItem * o_item;
......@@ -701,8 +919,6 @@ static void Run( intf_thread_t *p_intf )
p_intf->p_sys->b_spu_update |= p_intf->p_sys->b_title_update |
p_intf->p_sys->b_program_update;
#define p_input (p_intf->p_sys->p_input)
if( p_intf->p_sys->b_program_update )
{
NSMenu * o_program;
......@@ -854,11 +1070,9 @@ static void Run( intf_thread_t *p_intf )
}
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
if( p_intf->p_sys->b_audio_update )
{
[self setupLangMenu: o_mi_language es: p_audio_es
[self setupLangMenu: p_input mi: o_mi_language es: p_audio_es
category: AUDIO_ES selector: @selector(toggleLanguage:)];
p_intf->p_sys->b_audio_update = 0;
......@@ -866,7 +1080,7 @@ static void Run( intf_thread_t *p_intf )
if( p_intf->p_sys->b_spu_update )
{
[self setupLangMenu: o_mi_subtitle es: p_spu_es
[self setupLangMenu: p_input mi: o_mi_subtitle es: p_spu_es
category: SPU_ES selector: @selector(toggleLanguage:)];
p_intf->p_sys->b_spu_update = 0;
......@@ -896,10 +1110,10 @@ static void Run( intf_thread_t *p_intf )
p_intf->p_sys->b_aout_update = 0;
}
if ( p_intf->p_sys->b_vout_update )
if( p_intf->p_sys->b_vout_update )
{
vout_thread_t * p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
FIND_ANYWHERE );
if ( p_vout != NULL )
{
......@@ -919,19 +1133,17 @@ static void Run( intf_thread_t *p_intf )
p_intf->p_sys->b_vout_update = 0;
}
vlc_mutex_lock( &p_input->stream.stream_lock );
#undef p_input
}
- (void)setupLangMenu:(NSMenuItem *)o_mi
- (void)setupLangMenu:(input_thread_t *)p_input
mi:(NSMenuItem *)o_mi
es:(es_descriptor_t *)p_es
category:(int)i_cat
selector:(SEL)pf_callback
{
unsigned int i, i_nb_items;
NSMenu * o_menu = [o_mi submenu];
intf_thread_t * p_intf = [NSApp getIntf];
/* remove previous language items */
i_nb_items = [o_menu numberOfItems];
......@@ -961,15 +1173,13 @@ static void Run( intf_thread_t *p_intf )
}
#endif
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
#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++ )
#define ES p_input->stream.pp_es[i]
for( i = 0 ; i < p_input->stream.i_es_number ; i++ )
{
if( ( ES->i_cat == i_cat ) &&
( !ES->p_pgrm ||
ES->p_pgrm ==
p_intf->p_sys->p_input->stream.p_selected_program ) )
p_input->stream.p_selected_program ) )
{
NSMenuItem * o_lmi;
NSString * o_title;
......@@ -1003,8 +1213,6 @@ static void Run( intf_thread_t *p_intf )
}
}
#undef ES
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
}
- (void)setupVarMenu:(NSMenuItem *)o_mi
......@@ -1045,7 +1253,8 @@ static void Run( intf_thread_t *p_intf )
NSMenuItem * o_lmi;
NSString * o_title;
o_title = [NSString stringWithCString: val.p_list->p_values[i].psz_string];
o_title = [NSString stringWithCString:
val.p_list->p_values[i].psz_string];
o_lmi = [o_menu addItemWithTitle: o_title
action: pf_callback keyEquivalent: @""];
/* FIXME: this isn't 64-bit clean ! */
......@@ -1087,93 +1296,58 @@ static void Run( intf_thread_t *p_intf )
- (IBAction)timesliderUpdate:(id)sender
{
float f_updated;
switch( [[NSApp currentEvent] type] )
{
case NSLeftMouseUp:
case NSLeftMouseDown:
f_slider = [sender floatValue];
[self displayTime];
break;
case NSLeftMouseDragged:
f_slider = [sender floatValue];
[self displayTime];
break;
return;
case NSLeftMouseUp:
f_slider = [sender floatValue];
[self displayTime];
intf_thread_t * p_intf = [NSApp getIntf];
input_thread_t * p_input = p_intf->p_sys->p_input;
vlc_mutex_unlock( &p_input->stream.stream_lock );
case NSLeftMouseDragged:
f_updated = [sender floatValue];
break;
default:
break;
return;
}
}
- (void)displayTime
{
intf_thread_t * p_intf = [NSApp getIntf];
input_thread_t * p_input = p_intf->p_sys->p_input;
if( p_input == NULL )
{
[o_timeslider setEnabled: FALSE];
[o_timeslider setFloatValue: 0.0];
[o_timefield setStringValue: @"0:00:00"];
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
{
return;
}
#define p_area p_input->stream.p_selected_area
vlc_mutex_lock( &p_playlist->object_lock );
if( p_input->stream.b_changed )
{
[o_timeslider setEnabled: p_input->stream.b_seekable];
}
else if( p_intf->p_sys->b_playing )
if( p_playlist->p_input != NULL )
{
off_t i_tell;
NSString * o_time;
char psz_time[ OFFSETTOTIME_MAX_SIZE ];
input_OffsetToTime( p_input, psz_time, p_area->i_tell );
#define p_area p_playlist->p_input->stream.p_selected_area
vlc_mutex_lock( &p_playlist->p_input->stream.stream_lock );
i_tell = f_updated / 100. * p_area->i_size;
input_OffsetToTime( p_playlist->p_input, psz_time, i_tell );
vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
#undef p_area
o_time = [NSString stringWithCString: psz_time];
[o_timefield setStringValue: o_time];
if( p_input->stream.b_seekable )
{
if( f_slider == f_slider_old )
{
float f_updated = ( 100. * p_area->i_tell ) /
p_area->i_size;
if( f_slider != f_updated )
{
[o_timeslider setFloatValue: f_updated];
}
}
else
{
off_t i_seek = ( f_slider * p_area->i_size ) / 100;
/* release the lock to be able to seek */
vlc_mutex_unlock( &p_input->stream.stream_lock );
input_Seek( p_input, i_seek, INPUT_SEEK_SET );
vlc_mutex_lock( &p_input->stream.stream_lock );
/* Update the old value */
f_slider_old = f_slider;
}
}
[o_timefield setStringValue: o_time];
}
#undef p_area
vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist );
}
- (IBAction)closeError:(id)sender
{
/* Error panel */
[o_err_msg setString: @""];
[o_error performClose: self];
}
......@@ -1182,7 +1356,7 @@ static void Run( intf_thread_t *p_intf )
{
NSString * o_path = [[NSBundle mainBundle]
pathForResource: @"README.MacOSX" ofType: @"rtf"];
[[NSWorkspace sharedWorkspace] openFile: o_path
withApplication: @"TextEdit"];
}
......@@ -1191,14 +1365,14 @@ static void Run( intf_thread_t *p_intf )
{
NSURL * o_url = [NSURL URLWithString:
@"http://www.videolan.org/support/bug-reporting.html"];
[[NSWorkspace sharedWorkspace] openURL: o_url];
}
- (IBAction)openWebsite:(id)sender
{
NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org"];
[[NSWorkspace sharedWorkspace] openURL: o_url];
}
......@@ -1206,7 +1380,7 @@ static void Run( intf_thread_t *p_intf )
{
NSString * o_path = [[NSBundle mainBundle]
pathForResource: @"COPYING" ofType: nil];
[[NSWorkspace sharedWorkspace] openFile: o_path
withApplication: @"TextEdit"];
}
......@@ -1306,19 +1480,22 @@ static void Run( intf_thread_t *p_intf )
- (void)handlePortMessage:(NSPortMessage *)o_msg
{
id ** val;
NSData * o_data;
NSValue * o_value;
NSInvocation * o_inv;
vout_thread_t * p_vout;
NSConditionLock * o_lock;
o_data = [[o_msg components] lastObject];
o_inv = *((NSInvocation **)[o_data bytes]);
[o_inv getArgument: &o_value atIndex: 2];
p_vout = (vout_thread_t *)[o_value pointerValue];
val = (id **)[o_value pointerValue];
[o_inv setArgument: val[1] atIndex: 2];
o_lock = *(val[0]);
[p_vout->p_sys->o_lock lock];
[o_lock lock];
[o_inv invoke];
[p_vout->p_sys->o_lock unlockWithCondition: 1];
[o_lock unlockWithCondition: 1];
}
@end
......@@ -2,7 +2,7 @@
* open.m: MacOS X plugin for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: open.m,v 1.16 2003/01/26 14:53:08 hartman Exp $
* $Id: open.m,v 1.17 2003/01/31 02:53:52 jlj Exp $
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr>
......@@ -37,17 +37,12 @@
#include <IOKit/storage/IOCDMedia.h>
#include <IOKit/storage/IODVDMedia.h>
#import <Cocoa/Cocoa.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include "intf.h"
#include "playlist.h"
#include "open.h"
#include "netutils.h"
#import "intf.h"
#import "playlist.h"
#import "open.h"
/*****************************************************************************
* GetEjectableMediaOfClass
*****************************************************************************/
......
......@@ -2,7 +2,7 @@
* playlist.m: MacOS X interface plugin
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: playlist.m,v 1.6 2003/01/29 11:34:11 jlj Exp $
* $Id: playlist.m,v 1.7 2003/01/31 02:53:52 jlj Exp $
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
*
......@@ -28,11 +28,6 @@
#include <sys/param.h> /* for MAXPATHLEN */
#include <string.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <Cocoa/Cocoa.h>
#include "intf.h"
#include "playlist.h"
......@@ -48,24 +43,41 @@
- (void)keyDown:(NSEvent *)o_event
{
intf_thread_t * p_intf = [NSApp getIntf];
unichar key = 0;
playlist_t * p_playlist;
intf_thread_t * p_intf = [NSApp getIntf];
if( [[o_event characters] length] )
{
key = [[o_event characters] characterAtIndex: 0];
}
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist != NULL )
{
vlc_mutex_lock( &p_playlist->object_lock );
}
switch( key )
{
case ' ':
input_SetStatus( p_intf->p_sys->p_input , INPUT_STATUS_PAUSE );
if( p_playlist != NULL && p_playlist->p_input != NULL )
{
input_SetStatus( p_playlist->p_input, INPUT_STATUS_PAUSE );
}
break;
default:
[super keyDown: o_event];
break;
}
if( p_playlist != NULL )
{
vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist );
}
}
@end
......
......@@ -2,7 +2,7 @@
* prefs.m: MacOS X plugin for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: prefs.m,v 1.9 2003/01/27 17:41:01 ipkiss Exp $
* $Id: prefs.m,v 1.10 2003/01/31 02:53:52 jlj Exp $
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
*
......@@ -28,13 +28,8 @@
#include <sys/param.h> /* for MAXPATHLEN */
#include <string.h>
#import <Cocoa/Cocoa.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#import "intf.h"
#import "prefs.h"
#include "intf.h"
#include "prefs.h"
/*****************************************************************************
* VLCPrefs implementation
......
......@@ -2,7 +2,7 @@
* vout.h: MacOS X interface plugin
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: vout.h,v 1.4 2003/01/05 01:55:07 massiot Exp $
* $Id: vout.h,v 1.5 2003/01/31 02:53:52 jlj Exp $
*
* Authors: Colin Delacroix <colin@zoy.org>
* Florian G. Pflug <fgp@phlo.org>
......@@ -67,8 +67,6 @@
*****************************************************************************/
struct vout_sys_t
{
NSConditionLock * o_lock;
NSRect s_rect;
int b_pos_saved;
VLCWindow * o_window;
......
......@@ -2,7 +2,7 @@
* vout.m: MacOS X video output plugin
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
* $Id: vout.m,v 1.20 2003/01/28 15:59:38 hartman Exp $
* $Id: vout.m,v 1.21 2003/01/31 02:53:52 jlj Exp $
*
* Authors: Colin Delacroix <colin@zoy.org>
* Florian G. Pflug <fgp@phlo.org>
......@@ -31,12 +31,6 @@
#include <stdlib.h> /* free() */
#include <string.h> /* strerror() */
#include <vlc/vlc.h>
#include <vlc/vout.h>
#include <vlc/aout.h>
#include <vlc/intf.h>
#include <Cocoa/Cocoa.h>
#include <QuickTime/QuickTime.h>
#include "intf.h"
......@@ -424,61 +418,14 @@ static int CoSendRequest( vout_thread_t *p_vout, SEL sel )
{
int i_ret = 0;
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
VLCVout * o_vlv = [[[VLCVout alloc] init] autorelease];
VLCVout * o_vlv = [[VLCVout alloc] init];
if( [o_vlv respondsToSelector: @selector(performSelectorOnMainThread:
withObject:waitUntilDone:)] )
{
[o_vlv performSelectorOnMainThread: sel
withObject: [NSValue valueWithPointer: p_vout]
waitUntilDone: YES];
}
else if( [NSApp respondsToSelector: @selector(getIntf)] )
{
NSArray * o_array;
NSValue * o_value;
NSPort * o_recv_port;
NSInvocation * o_inv;
NSPortMessage * o_msg;
intf_thread_t * p_intf;
NSMethodSignature * o_sig;
p_intf = (intf_thread_t *)[NSApp getIntf];
o_recv_port = [[NSPort port] retain];
o_value = [NSValue valueWithPointer: p_vout];
o_sig = [VLCVout instanceMethodSignatureForSelector: sel];
o_inv = [NSInvocation invocationWithMethodSignature: o_sig];
[o_inv setArgument: &o_value atIndex: 2];
[o_inv setTarget: o_vlv];
[o_inv setSelector: sel];
o_array = [NSArray arrayWithObject:
[NSData dataWithBytes: &o_inv length: sizeof(o_inv)]];
o_msg = [[NSPortMessage alloc]
initWithSendPort: p_intf->p_sys->o_sendport
receivePort: o_recv_port components: o_array];
p_vout->p_sys->o_lock =
[[NSConditionLock alloc] initWithCondition: 0];
[o_msg sendBeforeDate: [NSDate distantPast]];
[p_vout->p_sys->o_lock lockWhenCondition: 1];
[p_vout->p_sys->o_lock unlock];
[p_vout->p_sys->o_lock release];
p_vout->p_sys->o_lock = nil;
[o_msg release];
[o_recv_port release];
}
else
if( ( i_ret = ExecuteOnMainThread( o_vlv, sel, (void *)p_vout ) ) )
{
msg_Err( p_vout, "SendRequest: no way to communicate with mt" );
i_ret = 1;
}
[o_pool release];
[o_vlv release];
return( i_ret );
}
......@@ -842,7 +789,6 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
p_intf->p_sys->b_stopping = 1;
/* The window will be closed by the intf later. */
return NO;
......
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