1
mirror of https://code.videolan.org/videolan/vlc synced 2024-09-04 09:11:33 +02:00

* core/playlist: PLAYLIST_PAUSE, playlist_IsPlaying, playlist_IsEmpty

* modules/gui/macosx: started getting rid of p_intf->p_sys->p_input
                       and using p_playlist->p_input instead.
This commit is contained in:
Jon Lech Johansen 2003-01-29 11:34:11 +00:00
parent 0e8bd13c90
commit 88f691d016
9 changed files with 215 additions and 238 deletions

View File

@ -5,7 +5,6 @@
{
ACTIONS = {
deinterlace = id;
fastForward = id;
faster = id;
fullscreen = id;
loop = id;
@ -14,7 +13,6 @@
pause = id;
play = id;
prev = id;
slowMotion = id;
slower = id;
stop = id;
toggleChapter = id;

View File

@ -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>

View File

@ -2,7 +2,7 @@
* vlc_playlist.h : Playlist functions
*****************************************************************************
* Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
* $Id: vlc_playlist.h,v 1.7 2002/12/13 16:26:34 babal Exp $
* $Id: vlc_playlist.h,v 1.8 2003/01/29 11:34:11 jlj Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
@ -53,6 +53,13 @@ struct playlist_t
input_thread_t * p_input;
};
/*****************************************************************************
* Playlist status
*****************************************************************************/
#define PLAYLIST_STOPPED 0
#define PLAYLIST_RUNNING 1
#define PLAYLIST_PAUSED 2
/*****************************************************************************
* Prototypes
*****************************************************************************/
@ -74,3 +81,25 @@ VLC_EXPORT( int, playlist_AddItem, ( playlist_t *, playlist_item_t *, int, int
VLC_EXPORT( int, playlist_Delete, ( playlist_t *, int ) );
VLC_EXPORT( int, playlist_LoadFile, ( playlist_t *, const char * ) );
VLC_EXPORT( int, playlist_SaveFile, ( playlist_t *, const char * ) );
static inline vlc_bool_t playlist_IsPlaying( playlist_t * p_playlist )
{
vlc_bool_t b_playing;
vlc_mutex_lock( &p_playlist->object_lock );
b_playing = p_playlist->i_status == PLAYLIST_RUNNING;
vlc_mutex_unlock( &p_playlist->object_lock );
return( b_playing );
}
static inline vlc_bool_t playlist_IsEmpty( playlist_t * p_playlist )
{
vlc_bool_t b_empty;
vlc_mutex_lock( &p_playlist->object_lock );
b_empty = p_playlist->i_size == 0;
vlc_mutex_unlock( &p_playlist->object_lock );
return( b_empty );
}

View File

@ -2,7 +2,7 @@
* controls.m: MacOS X interface plugin
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: controls.m,v 1.16 2003/01/28 16:47:46 hartman Exp $
* $Id: controls.m,v 1.17 2003/01/29 11:34:11 jlj Exp $
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr>
@ -36,7 +36,6 @@
#include <vlc/input.h>
#include <Cocoa/Cocoa.h>
#include <CoreAudio/AudioHardware.h>
#include "intf.h"
#include "vout.h"
@ -50,15 +49,12 @@
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;
@ -89,6 +85,7 @@
- (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 )
@ -96,26 +93,24 @@
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 )
vlc_bool_t b_empty;
b_empty = playlist_IsEmpty( p_playlist );
vlc_object_release( p_playlist );
if( !b_empty )
{
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];
}
}
@ -124,6 +119,7 @@
- (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 )
@ -133,6 +129,7 @@
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
p_intf->p_sys->b_stopping = 1;
}
@ -140,177 +137,6 @@
{
intf_thread_t * p_intf = [NSApp getIntf];
if( p_intf->p_sys->p_input == NULL )
{
return;
}
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
}
- (IBAction)slower:(id)sender
{
intf_thread_t * p_intf = [NSApp getIntf];
if( p_intf->p_sys->p_input == NULL )
{
return;
}
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER );
}
- (IBAction)slowMotion:(id)sender
{
i_ff++;
switch( [[NSApp currentEvent] type] )
{
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;
default:
break;
}
}
- (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;
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;
default:
break;
}
vlc_object_release( p_playlist );
}
- (IBAction)prev:(id)sender
{
intf_thread_t * p_intf = [NSApp getIntf];
input_area_t * p_area;
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
p_area = p_intf->p_sys->p_input->stream.p_selected_area;
/* check if this is the first chapter and whether there are any chapters at all */
if( p_area->i_part > 1 && p_area->i_part_nb > 1 )
{
p_area->i_part--;
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
input_ChangeArea( p_intf->p_sys->p_input, p_area );
p_intf->p_sys->b_chapter_update = VLC_TRUE;
}
else if( p_playlist != NULL )
{
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
playlist_Prev( p_playlist );
}
else
{
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
}
if ( p_playlist != NULL )
vlc_object_release( p_playlist );
}
- (IBAction)next:(id)sender
{
intf_thread_t * p_intf = [NSApp getIntf];
input_area_t * p_area;
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
p_area = p_intf->p_sys->p_input->stream.p_selected_area;
/* check if this is the last chapter and whether there are any chapters at all */
if( p_area->i_part_nb > 1 && p_area->i_part < p_area->i_part_nb )
{
p_area->i_part++;
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
input_ChangeArea( p_intf->p_sys->p_input, p_area );
p_intf->p_sys->b_chapter_update = VLC_TRUE;
}
else if( p_playlist != NULL )
{
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
playlist_Next( p_playlist );
}
else
{
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
}
if ( p_playlist != NULL )
vlc_object_release( p_playlist );
}
- (IBAction)loop:(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 )
@ -318,18 +144,142 @@
return;
}
if( p_intf->p_sys->b_loop )
vlc_mutex_lock( &p_playlist->object_lock );
if( p_playlist->p_input != NULL )
{
[o_mi setState: NSOffState];
config_PutInt( p_playlist, "loop", 0 );
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];
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 )
{
input_SetStatus( p_playlist->p_input, INPUT_STATUS_SLOWER );
}
vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist );
}
- (IBAction)prev:(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;
}
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--;
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
{
[o_mi setState: NSOnState];
config_PutInt( p_playlist, "loop", 1 );
vlc_mutex_unlock( &p_playlist->p_input->stream.stream_lock );
vlc_mutex_unlock( &p_playlist->object_lock );
playlist_Prev( p_playlist );
}
p_intf->p_sys->b_loop = !p_intf->p_sys->b_loop;
#undef p_area
vlc_object_release( p_playlist );
}
- (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;
}
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)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;
}
config_PutInt( p_playlist, "loop",
!config_GetInt( p_playlist, "loop" ) );
vlc_object_release( p_playlist );
}
@ -667,16 +617,22 @@
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 );
}
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_playlist->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
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 );
}
else
{
@ -685,26 +641,30 @@
}
else if( [[o_mi title] isEqualToString: _NS("Stop")] )
{
bEnabled = p_intf->p_sys->p_input != NULL;
if( p_playlist == NULL || p_playlist->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 );
}
}
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("Fullscreen")] )
{
id o_window;
@ -752,6 +712,12 @@
}
}
if( p_playlist != NULL )
{
vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist );
}
return( bEnabled );
}

View File

@ -2,7 +2,7 @@
* intf.h: MacOS X interface plugin
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: intf.h,v 1.18 2003/01/27 00:08:31 jlj Exp $
* $Id: intf.h,v 1.19 2003/01/29 11:34:11 jlj Exp $
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr>
@ -57,7 +57,6 @@ struct intf_sys_t
NSPort * o_sendport;
/* special actions */
vlc_bool_t b_loop;
vlc_bool_t b_playing;
vlc_bool_t b_stopping;
vlc_bool_t b_mute;

View File

@ -2,7 +2,7 @@
* intf.m: MacOS X interface plugin
*****************************************************************************
* Copyright (C) 2002-2003 VideoLAN
* $Id: intf.m,v 1.37 2003/01/28 01:50:52 hartman Exp $
* $Id: intf.m,v 1.38 2003/01/29 11:34:11 jlj Exp $
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr>
@ -663,15 +663,6 @@ static void Run( intf_thread_t *p_intf )
[o_controls setVolumeSlider];
[o_timeslider setEnabled: b_input];
if ( (p_intf->p_sys->b_loop = config_GetInt( p_intf, "loop" )) )
{
[o_mi_loop setState: NSOnState];
}
else
{
[o_mi_loop setState: NSOffState];
}
if ( p_intf->p_sys->p_input != NULL &&
p_intf->p_sys->p_input->stream.control.i_status != PAUSE_S)
{

View File

@ -2,7 +2,7 @@
* playlist.m: MacOS X interface plugin
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: playlist.m,v 1.5 2003/01/24 02:31:53 hartman Exp $
* $Id: playlist.m,v 1.6 2003/01/29 11:34:11 jlj Exp $
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
*
@ -232,11 +232,6 @@
return;
}
if( p_intf->p_sys->b_loop )
{
playlist_Delete( p_playlist, p_playlist->i_size - 1 );
}
i_items = 0;
o_enum = [o_array objectEnumerator];
while( ( o_value = [o_enum nextObject] ) )
@ -261,12 +256,6 @@
i_items++;
}
if( p_intf->p_sys->b_loop )
{
playlist_Add( p_playlist, "vlc:loop",
PLAYLIST_APPEND, PLAYLIST_END );
}
vlc_object_release( p_playlist );
[self playlistUpdated];

View File

@ -2,7 +2,7 @@
* playlist.c : Playlist management functions
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: playlist.c,v 1.30 2002/12/13 16:26:35 babal Exp $
* $Id: playlist.c,v 1.31 2003/01/29 11:34:11 jlj Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
@ -31,9 +31,6 @@
#include "vlc_playlist.h"
#define PLAYLIST_STOPPED 0
#define PLAYLIST_RUNNING 1
#define PLAYLIST_FILE_HEADER_0_5 "# vlc playlist file version 0.5"
#ifdef WIN32
# define PLAYLIST_FILE_EOL "\r\n"
@ -306,12 +303,20 @@ void playlist_Command( playlist_t * p_playlist, int i_command, int i_arg )
case PLAYLIST_PLAY:
p_playlist->i_status = PLAYLIST_RUNNING;
if ( p_playlist->p_input )
if( p_playlist->p_input )
{
input_SetStatus( p_playlist->p_input, INPUT_STATUS_PLAY );
}
break;
case PLAYLIST_PAUSE:
p_playlist->i_status = PLAYLIST_PAUSED;
if( p_playlist->p_input )
{
input_SetStatus( p_playlist->p_input, INPUT_STATUS_PAUSE );
}
break;
case PLAYLIST_SKIP:
p_playlist->i_status = PLAYLIST_STOPPED;
SkipItem( p_playlist, i_arg );