direct3d11: set the texture size after we know we use a staging one
[vlc.git] / src / playlist / control.c
blob60d9bae356eedc458f20548e3792a53f099f8294
1 /*****************************************************************************
2 * control.c : Handle control of the playlist & running through it
3 *****************************************************************************
4 * Copyright (C) 1999-2004 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Samuel Hocevar <sam@zoy.org>
8 * Clément Stenac <zorglub@videolan.org>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
24 #ifdef HAVE_CONFIG_H
25 # include "config.h"
26 #endif
28 #include <vlc_common.h>
29 #include "vlc_playlist.h"
30 #include "playlist_internal.h"
31 #include <assert.h>
33 /*****************************************************************************
34 * Playlist control
35 *****************************************************************************/
37 void playlist_Lock( playlist_t *pl )
39 vlc_mutex_lock( &pl_priv(pl)->lock );
42 void playlist_Unlock( playlist_t *pl )
44 vlc_mutex_unlock( &pl_priv(pl)->lock );
47 void playlist_AssertLocked( playlist_t *pl )
49 vlc_assert_locked( &pl_priv(pl)->lock );
52 static void playlist_vaControl( playlist_t *p_playlist, int i_query,
53 bool locked, va_list args )
55 PL_LOCK_IF( !locked );
57 if( pl_priv(p_playlist)->killed )
59 else
60 switch( i_query )
62 case PLAYLIST_STOP:
63 pl_priv(p_playlist)->request.b_request = true;
64 pl_priv(p_playlist)->request.p_item = NULL;
65 pl_priv(p_playlist)->request.p_node = NULL;
66 break;
68 // Node can be null, it will keep the same. Use with care ...
69 // Item null = take the first child of node
70 case PLAYLIST_VIEWPLAY:
72 playlist_item_t *p_node = va_arg( args, playlist_item_t * );
73 playlist_item_t *p_item = va_arg( args, playlist_item_t * );
75 assert( locked || (p_item == NULL && p_node == NULL) );
77 if ( p_node == NULL )
79 p_node = get_current_status_node( p_playlist );
80 assert( p_node );
82 pl_priv(p_playlist)->request.i_skip = 0;
83 pl_priv(p_playlist)->request.b_request = true;
84 pl_priv(p_playlist)->request.p_node = p_node;
85 pl_priv(p_playlist)->request.p_item = p_item;
86 if( p_item && var_GetBool( p_playlist, "random" ) )
87 pl_priv(p_playlist)->b_reset_currently_playing = true;
88 break;
91 case PLAYLIST_PLAY:
92 if( pl_priv(p_playlist)->p_input == NULL )
94 pl_priv(p_playlist)->request.b_request = true;
95 pl_priv(p_playlist)->request.p_node = get_current_status_node( p_playlist );
96 pl_priv(p_playlist)->request.p_item = get_current_status_item( p_playlist );
97 pl_priv(p_playlist)->request.i_skip = 0;
99 else
100 var_SetInteger( pl_priv(p_playlist)->p_input, "state", PLAYING_S );
101 break;
103 case PLAYLIST_TOGGLE_PAUSE:
104 if( pl_priv(p_playlist)->p_input == NULL )
106 pl_priv(p_playlist)->request.b_request = true;
107 pl_priv(p_playlist)->request.p_node = get_current_status_node( p_playlist );
108 pl_priv(p_playlist)->request.p_item = get_current_status_item( p_playlist );
109 pl_priv(p_playlist)->request.i_skip = 0;
111 else
112 if( var_GetInteger( pl_priv(p_playlist)->p_input, "state" ) == PAUSE_S )
113 var_SetInteger( pl_priv(p_playlist)->p_input, "state", PLAYING_S );
114 else
115 var_SetInteger( pl_priv(p_playlist)->p_input, "state", PAUSE_S );
116 break;
118 case PLAYLIST_SKIP:
119 pl_priv(p_playlist)->request.p_node = get_current_status_node( p_playlist );
120 pl_priv(p_playlist)->request.p_item = get_current_status_item( p_playlist );
121 pl_priv(p_playlist)->request.i_skip = (int) va_arg( args, int );
122 pl_priv(p_playlist)->request.b_request = true;
123 break;
125 case PLAYLIST_PAUSE:
126 if( pl_priv(p_playlist)->p_input == NULL )
127 break;
128 var_SetInteger( pl_priv(p_playlist)->p_input, "state", PAUSE_S );
129 break;
131 case PLAYLIST_RESUME:
132 if( pl_priv(p_playlist)->p_input == NULL )
133 break;
134 var_SetInteger( pl_priv(p_playlist)->p_input, "state", PLAYING_S );
135 break;
137 vlc_cond_signal( &pl_priv(p_playlist)->signal );
138 PL_UNLOCK_IF( !locked );
141 void playlist_Control( playlist_t *p_playlist, int query, int locked, ... )
143 va_list args;
145 va_start( args, locked );
146 playlist_vaControl( p_playlist, query, (bool)locked, args );
147 va_end( args );