1 /*****************************************************************************
2 * ncurses.c : NCurses plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2001-2004 VideoLAN
5 * $Id: ncurses.c,v 1.8 2004/01/10 03:36:03 hartman Exp $
7 * Authors: Sam Hocevar <sam@zoy.org>
8 * Laurent Aimar <fenrir@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 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 General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
30 #include <errno.h> /* ENOMEM */
41 #define CDDA_MRL "cddax://"
43 #define CDDA_MRL "cdda://"
47 #define VCD_MRL "vcdx://"
49 #define VCD_MRL "vcdx://"
52 /*****************************************************************************
54 *****************************************************************************/
55 static int Open ( vlc_object_t * );
56 static void Close ( vlc_object_t * );
58 static void Run ( intf_thread_t * );
59 static void PlayPause ( intf_thread_t * );
60 static void Eject ( intf_thread_t * );
62 static int HandleKey ( intf_thread_t *, int );
63 static void Redraw ( intf_thread_t *, time_t * );
64 static void ManageSlider ( intf_thread_t * );
66 /*****************************************************************************
68 *****************************************************************************/
70 set_description( _("ncurses interface") );
71 set_capability( "interface", 10 );
72 set_callbacks( Open, Close );
73 add_shortcut( "curses" );
76 /*****************************************************************************
77 * intf_sys_t: description and status of ncurses interface
78 *****************************************************************************/
89 playlist_t *p_playlist;
90 input_thread_t *p_input;
100 int i_box_lines_total;
105 msg_subscription_t* p_sub; /* message bank subscription */
108 static void DrawBox( WINDOW *win, int y, int x, int h, int w, char *title );
109 static void DrawLine( WINDOW *win, int y, int x, int w );
110 static void DrawEmptyLine( WINDOW *win, int y, int x, int w );
112 /*****************************************************************************
113 * Open: initialize and create window
114 *****************************************************************************/
115 static int Open( vlc_object_t *p_this )
117 intf_thread_t *p_intf = (intf_thread_t *)p_this;
120 /* Allocate instance and initialize some members */
121 p_sys = p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
122 p_sys->p_playlist = NULL;
123 p_sys->p_input = NULL;
124 p_sys->f_slider = 0.0;
125 p_sys->f_slider_old = 0.0;
126 p_sys->i_box_type = BOX_PLAYLIST;
127 p_sys->i_box_lines = 0;
128 p_sys->i_box_start= 0;
129 p_sys->i_box_lines_total = 0;
130 p_sys->b_box_cleared = VLC_FALSE;
131 p_sys->p_sub = msg_Subscribe( p_intf );
133 /* Initialize the curses library */
134 p_sys->w = initscr();
135 keypad( p_sys->w, TRUE );
136 /* Don't do NL -> CR/NL */
138 /* Take input chars one at a time */
148 /* exported function */
149 p_intf->pf_run = Run;
154 /*****************************************************************************
155 * Close: destroy interface window
156 *****************************************************************************/
157 static void Close( vlc_object_t *p_this )
159 intf_thread_t *p_intf = (intf_thread_t *)p_this;
160 intf_sys_t *p_sys = p_intf->p_sys;
164 vlc_object_release( p_sys->p_input );
166 if( p_sys->p_playlist )
168 vlc_object_release( p_sys->p_playlist );
171 /* Close the ncurses interface */
174 msg_Unsubscribe( p_intf, p_sys->p_sub );
176 /* Destroy structure */
180 /*****************************************************************************
181 * Run: ncurses thread
182 *****************************************************************************/
183 static void Run( intf_thread_t *p_intf )
185 intf_sys_t *p_sys = p_intf->p_sys;
188 time_t t_last_refresh;
191 * force drawing the interface for the first time
193 t_last_refresh = ( time( 0 ) - 1);
195 while( !p_intf->b_die )
197 msleep( INTF_IDLE_SLEEP );
199 /* Update the input */
200 if( p_sys->p_playlist == NULL )
202 p_sys->p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
204 if( p_sys->p_input == NULL )
206 if( p_sys->p_playlist )
208 p_sys->p_input = vlc_object_find( p_sys->p_playlist,
209 VLC_OBJECT_INPUT,FIND_CHILD );
213 p_sys->p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,
216 p_sys->b_box_cleared = VLC_FALSE;
218 else if( p_sys->p_input->b_dead )
220 vlc_object_release( p_sys->p_input );
221 p_sys->p_input = NULL;
222 p_sys->f_slider = p_sys->f_slider_old = 0.0;
223 p_sys->b_box_cleared = VLC_FALSE;
226 while( ( i_key = getch()) != -1 )
229 * HandleKey returns 1 if the screen needs to be redrawn
231 if ( HandleKey( p_intf, i_key ) )
233 Redraw( p_intf, &t_last_refresh );
237 if( p_sys->f_slider > 0.0001 && !p_sys->b_box_cleared )
240 Redraw( p_intf, &t_last_refresh );
241 p_sys->b_box_cleared = VLC_TRUE;
245 * redraw the screen every second
247 if ( (time(0) - t_last_refresh) >= 1 )
249 ManageSlider ( p_intf );
250 Redraw( p_intf, &t_last_refresh );
255 /* following functions are local */
257 static int HandleKey( intf_thread_t *p_intf, int i_key )
259 intf_sys_t *p_sys = p_intf->p_sys;
262 if( p_sys->i_box_type == BOX_PLAYLIST && p_sys->p_playlist )
268 playlist_Sort( p_sys->p_playlist, SORT_RANDOM, ORDER_NORMAL );
271 playlist_Sort( p_sys->p_playlist, SORT_TITLE, ORDER_NORMAL );
274 playlist_Sort( p_sys->p_playlist, SORT_TITLE, ORDER_REVERSE );
277 /* Playlist navigation */
279 playlist_Goto( p_sys->p_playlist, 0 );
282 playlist_Goto( p_sys->p_playlist, p_sys->p_playlist->i_size - 1 );
285 playlist_Prev( p_sys->p_playlist );
288 playlist_Next( p_sys->p_playlist );
292 int i_item = p_sys->p_playlist->i_index - p_sys->i_box_lines;
293 if( i_item < 0 ) i_item = 0;
294 playlist_Goto( p_sys->p_playlist, i_item );
299 int i_item = p_sys->p_playlist->i_index + p_sys->i_box_lines;
300 if( i_item >= p_sys->p_playlist->i_size ) i_item = p_sys->p_playlist->i_size - 1;
303 playlist_Goto( p_sys->p_playlist, i_item );
308 playlist_Delete( p_sys->p_playlist, p_sys->p_playlist->i_index );
313 int i_item = p_sys->p_playlist->i_index;
314 playlist_Delete( p_sys->p_playlist, p_sys->p_playlist->i_index );
315 if( i_item < p_sys->p_playlist->i_size )
317 playlist_Goto( p_sys->p_playlist, i_item );
326 else if( p_sys->i_box_type == BOX_HELP || p_sys->i_box_type == BOX_INFO )
331 p_sys->i_box_start = 0;
334 p_sys->i_box_start = p_sys->i_box_lines_total - 1;
337 if( p_sys->i_box_start > 0 ) p_sys->i_box_start--;
340 if( p_sys->i_box_start < p_sys->i_box_lines_total - 1 )
342 p_sys->i_box_start++;
346 p_sys->i_box_start -= p_sys->i_box_lines;
347 if( p_sys->i_box_start < 0 ) p_sys->i_box_start = 0;
350 p_sys->i_box_start += p_sys->i_box_lines;
351 if( p_sys->i_box_start >= p_sys->i_box_lines_total )
353 p_sys->i_box_start = p_sys->i_box_lines_total - 1;
360 else if( p_sys->i_box_type == BOX_NONE )
366 ManageSlider ( p_intf );
369 p_sys->f_slider = 99.9;
370 ManageSlider ( p_intf );
373 p_sys->f_slider += 20.0;
374 if( p_sys->f_slider >= 99.0 ) p_sys->f_slider = 99.0;
375 ManageSlider ( p_intf );
378 p_sys->f_slider -= 20.0;
379 if( p_sys->f_slider < 0.0 ) p_sys->f_slider = 0.0;
380 ManageSlider ( p_intf );
399 if( p_sys->i_box_type == BOX_INFO )
400 p_sys->i_box_type = BOX_NONE;
402 p_sys->i_box_type = BOX_INFO;
403 p_sys->i_box_lines_total = 0;
406 if( p_sys->i_box_type == BOX_LOG )
407 p_sys->i_box_type = BOX_NONE;
409 p_sys->i_box_type = BOX_LOG;
412 if( p_sys->i_box_type == BOX_PLAYLIST )
413 p_sys->i_box_type = BOX_NONE;
415 p_sys->i_box_type = BOX_PLAYLIST;
419 if( p_sys->i_box_type == BOX_HELP )
420 p_sys->i_box_type = BOX_NONE;
422 p_sys->i_box_type = BOX_HELP;
423 p_sys->i_box_lines_total = 0;
428 p_sys->f_slider += 5.0;
429 if( p_sys->f_slider > 99.9 ) p_sys->f_slider = 99.9;
430 ManageSlider ( p_intf );
434 p_sys->f_slider -= 5.0;
435 if( p_sys->f_slider < 0.0 ) p_sys->f_slider = 0.0;
436 ManageSlider ( p_intf );
442 vout_thread_t *p_vout;
443 p_vout = vlc_object_find( p_intf->p_sys->p_input,
444 VLC_OBJECT_VOUT, FIND_CHILD );
447 p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
448 vlc_object_release( p_vout );
458 if( p_intf->p_sys->p_playlist )
460 playlist_Stop( p_intf->p_sys->p_playlist );
471 val.b_bool = VLC_TRUE;
472 var_Set( p_sys->p_input, "prev-title", val );
479 val.b_bool = VLC_TRUE;
480 var_Set( p_sys->p_input, "next-title", val );
487 val.b_bool = VLC_TRUE;
488 var_Set( p_sys->p_input, "prev-chapter", val );
495 val.b_bool = VLC_TRUE;
496 var_Set( p_sys->p_input, "next-chapter", val );
501 if( p_intf->p_sys->p_playlist )
503 playlist_Prev( p_intf->p_sys->p_playlist );
508 if( p_intf->p_sys->p_playlist )
510 playlist_Next( p_intf->p_sys->p_playlist );
516 * ^l should clear and redraw the screen
527 static void ManageSlider ( intf_thread_t *p_intf )
529 intf_sys_t *p_sys = p_intf->p_sys;
530 input_thread_t *p_input = p_sys->p_input;
533 if( p_input == NULL )
537 var_Get( p_input, "state", &val );
538 if( val.i_int != PLAYING_S )
543 var_Get( p_input, "position", &val );
544 if( p_sys->f_slider == p_sys->f_slider_old )
547 p_sys->f_slider_old = 100 * val.f_float;
551 p_sys->f_slider_old = p_sys->f_slider;
553 val.f_float = p_sys->f_slider / 100.0;
554 var_Set( p_input, "position", val );
558 static void mvnprintw( int y, int x, int w, const char *p_fmt, ... )
564 va_start ( vl_args, p_fmt );
565 vasprintf ( &p_buf, p_fmt, vl_args );
574 if( ( i_len = strlen( p_buf ) ) > w )
576 int i_cut = i_len - w;
577 int x1 = i_len/2 - i_cut/2;
582 memmove( &p_buf[x1], &p_buf[x2], i_len - x2 );
591 mvprintw( y, x, "%s", p_buf );
595 mvprintw( y, x, "%s", p_buf );
596 mvhline( y, x + i_len, ' ', w - i_len );
600 static void MainBoxWrite( intf_thread_t *p_intf, int l, int x, const char *p_fmt, ... )
602 intf_sys_t *p_sys = p_intf->p_sys;
607 if( l < p_sys->i_box_start || l - p_sys->i_box_start >= p_sys->i_box_lines )
612 va_start ( vl_args, p_fmt );
613 vasprintf ( &p_buf, p_fmt, vl_args );
621 mvnprintw( p_sys->i_box_y + l - p_sys->i_box_start, x, COLS - x - 1, "%s", p_buf );
624 static void Redraw ( intf_thread_t *p_intf, time_t *t_last_refresh )
626 intf_sys_t *p_sys = p_intf->p_sys;
627 input_thread_t *p_input = p_sys->p_input;
635 attrset ( A_REVERSE );
636 mvnprintw( y, 0, COLS, VOUT_TITLE " (ncurses interface) [ h for help ]" );
637 attroff ( A_REVERSE );
641 if( p_input && !p_input->b_dead )
643 char buf1[MSTRTIME_MAX_SIZE];
644 char buf2[MSTRTIME_MAX_SIZE];
646 vlc_value_t val_list;
649 mvnprintw( y++, 0, COLS, " Source : %s", p_input->psz_source );
652 var_Get( p_input, "state", &val );
653 if( val.i_int == PLAYING_S )
655 mvnprintw( y++, 0, COLS, " State : Playing" );
657 else if( val.i_int == PAUSE_S )
659 mvnprintw( y++, 0, COLS, " State : Paused" );
665 if( val.i_int != INIT_S && val.i_int != END_S )
668 var_Get( p_input, "time", &val );
669 msecstotimestr( buf1, val.i_time / 1000 );
671 var_Get( p_input, "length", &val );
672 msecstotimestr( buf2, val.i_time / 1000 );
674 mvnprintw( y++, 0, COLS, " Position : %s/%s (%.2f%%)", buf1, buf2, p_sys->f_slider );
677 if( !var_Get( p_input, "title", &val ) )
679 var_Change( p_input, "title", VLC_VAR_GETCHOICES, &val_list, NULL );
680 if( val_list.p_list->i_count > 0 )
682 mvnprintw( y++, 0, COLS, " Title : %d/%d", val.i_int, val_list.p_list->i_count );
684 var_Change( p_input, "title", VLC_VAR_FREELIST, &val_list, NULL );
688 if( !var_Get( p_input, "chapter", &val ) )
690 var_Change( p_input, "chapter", VLC_VAR_GETCHOICES, &val_list, NULL );
691 if( val_list.p_list->i_count > 0 )
693 mvnprintw( y++, 0, COLS, " Chapter : %d/%d", val.i_int, val_list.p_list->i_count );
695 var_Change( p_input, "chapter", VLC_VAR_FREELIST, &val_list, NULL );
705 mvnprintw( y++, 0, COLS, "Source: <no current item>" );
706 DrawEmptyLine( p_sys->w, y++, 0, COLS );
707 DrawEmptyLine( p_sys->w, y++, 0, COLS );
710 DrawBox( p_sys->w, y, 0, 3, COLS, "" );
711 DrawEmptyLine( p_sys->w, y+1, 1, COLS-2);
712 DrawLine( p_sys->w, y+1, 1, (int)(p_intf->p_sys->f_slider/100.0 * (COLS -2)) );
715 p_sys->i_box_y = y + 1;
716 p_sys->i_box_lines = LINES - y - 2;
721 if( p_sys->i_box_type == BOX_HELP )
725 DrawBox( p_sys->w, y++, 0, h, COLS, " Help " );
727 MainBoxWrite( p_intf, l++, 1, "[Display]" );
728 MainBoxWrite( p_intf, l++, 1, " h,H Show/Hide help box" );
729 MainBoxWrite( p_intf, l++, 1, " i Show/Hide informations box" );
730 MainBoxWrite( p_intf, l++, 1, " l Show/Hide logs box" );
731 MainBoxWrite( p_intf, l++, 1, " P Show/Hide playlist box" );
732 MainBoxWrite( p_intf, l++, 1, "" );
734 MainBoxWrite( p_intf, l++, 1, "[Global]" );
735 MainBoxWrite( p_intf, l++, 1, " q, Q Quit" );
736 MainBoxWrite( p_intf, l++, 1, " s Stop" );
737 MainBoxWrite( p_intf, l++, 1, " <space> Pause/Play" );
738 MainBoxWrite( p_intf, l++, 1, " n, p Next/Previous item" );
739 MainBoxWrite( p_intf, l++, 1, " [, ] Next/Previous title" );
740 MainBoxWrite( p_intf, l++, 1, " <, > Next/Previous title" );
741 MainBoxWrite( p_intf, l++, 1, " <right> Seek +5%%" );
742 MainBoxWrite( p_intf, l++, 1, " <left> Seek -5%%" );
743 MainBoxWrite( p_intf, l++, 1, "" );
745 MainBoxWrite( p_intf, l++, 1, "[Playlist]" );
746 MainBoxWrite( p_intf, l++, 1, " r Randomize playlist" );
747 MainBoxWrite( p_intf, l++, 1, " o Order Playlist" );
748 MainBoxWrite( p_intf, l++, 1, " O Reverse order Playlist" );
749 MainBoxWrite( p_intf, l++, 1, " <del> Delete an entry" );
750 MainBoxWrite( p_intf, l++, 1, " <backspace> Delete an entry" );
751 MainBoxWrite( p_intf, l++, 1, "" );
753 MainBoxWrite( p_intf, l++, 1, "[Boxes]" );
754 MainBoxWrite( p_intf, l++, 1, " <up>,<down> Navigate through the box line by line" );
755 MainBoxWrite( p_intf, l++, 1, " <pgup>,<pgdown> Navigate through the box page by page" );
756 MainBoxWrite( p_intf, l++, 1, "" );
758 MainBoxWrite( p_intf, l++, 1, "[Player]" );
759 MainBoxWrite( p_intf, l++, 1, " <up>,<down> Seek +/-20%%" );
760 MainBoxWrite( p_intf, l++, 1, "" );
762 MainBoxWrite( p_intf, l++, 1, "[Miscellaneous]" );
763 MainBoxWrite( p_intf, l++, 1, " Ctrl-L Refresh the screen" );
765 p_sys->i_box_lines_total = l;
766 if( p_sys->i_box_start >= p_sys->i_box_lines_total )
768 p_sys->i_box_start = p_sys->i_box_lines_total - 1;
771 if( l - p_sys->i_box_start < p_sys->i_box_lines )
773 y += l - p_sys->i_box_start;
777 y += p_sys->i_box_lines;
780 else if( p_sys->i_box_type == BOX_INFO )
784 DrawBox( p_sys->w, y++, 0, h, COLS, " Informations " );
788 input_info_category_t * p_category;
789 input_info_t * p_info;
791 vlc_mutex_lock( &p_input->stream.stream_lock );
792 p_category = p_input->stream.p_info;
795 if( y >= y_end ) break;
796 MainBoxWrite( p_intf, l++, 1, " [%s]", p_category->psz_name );
797 p_info = p_category->p_info;
800 if( y >= y_end ) break;
801 MainBoxWrite( p_intf, l++, 1, " %s: %s", p_info->psz_name, p_info->psz_value );
802 p_info = p_info->p_next;
804 p_category = p_category->p_next;
806 vlc_mutex_unlock( &p_input->stream.stream_lock );
810 MainBoxWrite( p_intf, l++, 1, "No item currently playing" );
812 p_sys->i_box_lines_total = l;
813 if( p_sys->i_box_start >= p_sys->i_box_lines_total )
815 p_sys->i_box_start = p_sys->i_box_lines_total - 1;
818 if( l - p_sys->i_box_start < p_sys->i_box_lines )
820 y += l - p_sys->i_box_start;
824 y += p_sys->i_box_lines;
827 else if( p_sys->i_box_type == BOX_LOG )
833 DrawBox( p_sys->w, y++, 0, h, COLS, " Logs " );
835 i_start = p_intf->p_sys->p_sub->i_start;
837 vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock );
838 i_stop = *p_intf->p_sys->p_sub->pi_stop;
839 vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );
843 static const char *ppsz_type[4] = { "", "error", "warning", "debug" };
844 if( i_line >= h - 2 )
850 if( i_stop < 0 ) i_stop += VLC_MSG_QSIZE;
851 if( i_stop == i_start )
855 mvnprintw( y + h-2-i_line, 1, COLS - 2, " [%s] %s",
856 ppsz_type[p_sys->p_sub->p_msg[i_stop].i_type],
857 p_sys->p_sub->p_msg[i_stop].psz_msg );
860 vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock );
861 p_intf->p_sys->p_sub->i_start = i_stop;
862 vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );
865 else if( p_sys->i_box_type == BOX_PLAYLIST && p_sys->p_playlist )
868 playlist_t *p_playlist = p_sys->p_playlist;
871 DrawBox( p_sys->w, y++, 0, h, COLS, " Playlist " );
873 if( p_playlist->i_index < (h - 2)/2 )
878 else if( p_playlist->i_size - p_playlist->i_index > (h - 2)/2 )
880 i_start = p_playlist->i_index - (h - 2)/2;
881 i_stop = i_start + h - 2;
885 i_stop = p_playlist->i_size;
886 i_start = p_playlist->i_size - (h - 2);
892 if( i_stop > p_playlist->i_size )
894 i_stop = p_playlist->i_size;
897 for( i_item = i_start; i_item < i_stop; i_item++ )
899 vlc_bool_t b_selected = ( p_playlist->i_index == i_item );
900 if( y >= y_end ) break;
903 attrset( A_REVERSE );
905 if( !strcmp( p_playlist->pp_items[i_item]->psz_name, p_playlist->pp_items[i_item]->psz_uri ) )
907 mvnprintw( y++, 1, COLS - 2, " %d - '%s'",
909 p_playlist->pp_items[i_item]->psz_uri );
913 mvnprintw( y++, 1, COLS - 2, " %d - '%s' (%s)",
915 p_playlist->pp_items[i_item]->psz_uri,
916 p_playlist->pp_items[i_item]->psz_name );
920 attroff ( A_REVERSE );
931 DrawEmptyLine( p_sys->w, y++, 1, COLS - 2 );
936 *t_last_refresh = time( 0 );
939 static void Eject ( intf_thread_t *p_intf )
941 char *psz_device = NULL, *psz_parser, *psz_name;
944 * Get the active input
945 * Determine whether we can eject a media, ie it's a DVD, VCD or CD-DA
946 * If it's neither of these, then return
949 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
952 if( p_playlist == NULL )
957 vlc_mutex_lock( &p_playlist->object_lock );
959 if( p_playlist->i_index < 0 )
961 vlc_mutex_unlock( &p_playlist->object_lock );
962 vlc_object_release( p_playlist );
966 psz_name = p_playlist->pp_items[ p_playlist->i_index ]->psz_name;
970 if( !strncmp(psz_name, "dvd://", 4) )
972 switch( psz_name[strlen("dvd://")] )
976 psz_device = config_GetPsz( p_intf, "dvd" );
979 /* Omit the first MRL-selector characters */
980 psz_device = strdup( psz_name + strlen("dvd://" ) );
984 else if( !strncmp(psz_name, VCD_MRL, strlen(VCD_MRL)) )
986 switch( psz_name[strlen(VCD_MRL)] )
990 psz_device = config_GetPsz( p_intf, VCD_MRL );
993 /* Omit the beginning MRL-selector characters */
994 psz_device = strdup( psz_name + strlen(VCD_MRL) );
998 else if( !strncmp(psz_name, CDDA_MRL, strlen(CDDA_MRL) ) )
1000 switch( psz_name[strlen(CDDA_MRL)] )
1004 psz_device = config_GetPsz( p_intf, "cd-audio" );
1007 /* Omit the beginning MRL-selector characters */
1008 psz_device = strdup( psz_name + strlen(CDDA_MRL) );
1014 psz_device = strdup( psz_name );
1018 vlc_mutex_unlock( &p_playlist->object_lock );
1019 vlc_object_release( p_playlist );
1021 if( psz_device == NULL )
1026 /* Remove what we have after @ */
1027 psz_parser = psz_device;
1028 for( psz_parser = psz_device ; *psz_parser ; psz_parser++ )
1030 if( *psz_parser == '@' )
1037 /* If there's a stream playing, we aren't allowed to eject ! */
1038 if( p_intf->p_sys->p_input == NULL )
1040 msg_Dbg( p_intf, "ejecting %s", psz_device );
1042 intf_Eject( p_intf, psz_device );
1049 static void PlayPause ( intf_thread_t *p_intf )
1051 input_thread_t *p_input = p_intf->p_sys->p_input;
1056 var_Get( p_input, "state", &val );
1057 if( val.i_int != PAUSE_S )
1059 val.i_int = PAUSE_S;
1063 val.i_int = PLAYING_S;
1065 var_Set( p_input, "state", val );
1067 else if( p_intf->p_sys->p_playlist )
1069 playlist_Play( p_intf->p_sys->p_playlist );
1073 /****************************************************************************
1075 ****************************************************************************/
1076 static void DrawBox( WINDOW *win, int y, int x, int h, int w, char *title )
1081 if( w > 3 && h > 2 )
1083 if( title == NULL ) title = "";
1084 i_len = strlen( title );
1086 if( i_len > w - 2 ) i_len = w - 2;
1088 mvwaddch( win, y, x, ACS_ULCORNER );
1089 mvwhline( win, y, x+1, ACS_HLINE, ( w-i_len-2)/2 );
1090 mvwprintw( win,y, x+1+(w-i_len-2)/2, "%s", title );
1091 mvwhline( win, y, x+(w-i_len)/2+i_len, ACS_HLINE, w - 1 - ((w-i_len)/2+i_len) );
1092 mvwaddch( win, y, x+w-1,ACS_URCORNER );
1094 for( i = 0; i < h-2; i++ )
1096 mvwaddch( win, y+i+1, x, ACS_VLINE );
1097 mvwaddch( win, y+i+1, x+w-1, ACS_VLINE );
1100 mvwaddch( win, y+h-1, x, ACS_LLCORNER );
1101 mvwhline( win, y+h-1, x+1, ACS_HLINE, w - 2 );
1102 mvwaddch( win, y+h-1, x+w-1, ACS_LRCORNER );
1106 static void DrawEmptyLine( WINDOW *win, int y, int x, int w )
1110 mvhline( y, x, ' ', w );
1114 static void DrawLine( WINDOW *win, int y, int x, int w )
1118 attrset( A_REVERSE );
1119 mvhline( y, x, ' ', w );
1120 attroff ( A_REVERSE );