1 /*****************************************************************************
2 * ncurses.c : NCurses plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2001-2004 VideoLAN
5 * $Id: ncurses.c,v 1.15 2004/02/22 15:57:41 fenrir 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;
103 int i_box_plidx; /* Playlist index */
104 int b_box_plidx_follow;
108 msg_subscription_t* p_sub; /* message bank subscription */
111 static void DrawBox( WINDOW *win, int y, int x, int h, int w, char *title );
112 static void DrawLine( WINDOW *win, int y, int x, int w );
113 static void DrawEmptyLine( WINDOW *win, int y, int x, int w );
115 /*****************************************************************************
116 * Open: initialize and create window
117 *****************************************************************************/
118 static int Open( vlc_object_t *p_this )
120 intf_thread_t *p_intf = (intf_thread_t *)p_this;
124 /* Allocate instance and initialize some members */
125 p_sys = p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
126 p_sys->p_playlist = NULL;
127 p_sys->p_input = NULL;
128 p_sys->f_slider = 0.0;
129 p_sys->f_slider_old = 0.0;
130 p_sys->i_box_type = BOX_PLAYLIST;
131 p_sys->i_box_lines = 0;
132 p_sys->i_box_start= 0;
133 p_sys->i_box_lines_total = 0;
134 p_sys->b_box_plidx_follow = VLC_TRUE;
135 p_sys->b_box_cleared = VLC_FALSE;
136 p_sys->i_box_plidx = 0;
137 p_sys->p_sub = msg_Subscribe( p_intf );
139 /* Initialize the curses library */
140 p_sys->w = initscr();
141 keypad( p_sys->w, TRUE );
142 /* Don't do NL -> CR/NL */
144 /* Take input chars one at a time */
154 /* exported function */
155 p_intf->pf_run = Run;
159 var_Set( p_intf->p_vlc, "verbose", val );
164 /*****************************************************************************
165 * Close: destroy interface window
166 *****************************************************************************/
167 static void Close( vlc_object_t *p_this )
169 intf_thread_t *p_intf = (intf_thread_t *)p_this;
170 intf_sys_t *p_sys = p_intf->p_sys;
174 vlc_object_release( p_sys->p_input );
176 if( p_sys->p_playlist )
178 vlc_object_release( p_sys->p_playlist );
181 /* Close the ncurses interface */
184 msg_Unsubscribe( p_intf, p_sys->p_sub );
186 /* Destroy structure */
190 /*****************************************************************************
191 * Run: ncurses thread
192 *****************************************************************************/
193 static void Run( intf_thread_t *p_intf )
195 intf_sys_t *p_sys = p_intf->p_sys;
198 time_t t_last_refresh;
201 * force drawing the interface for the first time
203 t_last_refresh = ( time( 0 ) - 1);
205 while( !p_intf->b_die )
207 msleep( INTF_IDLE_SLEEP );
209 /* Update the input */
210 if( p_sys->p_playlist == NULL )
212 p_sys->p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
214 if( p_sys->p_playlist )
216 vlc_mutex_lock( &p_sys->p_playlist->object_lock );
217 if( p_sys->p_input == NULL )
219 p_sys->p_input = p_sys->p_playlist->p_input;
222 if( !p_sys->p_input->b_dead )
224 vlc_object_yield( p_sys->p_input );
228 else if( p_sys->p_input->b_dead )
230 vlc_object_release( p_sys->p_input );
231 p_sys->p_input = NULL;
232 p_sys->f_slider = p_sys->f_slider_old = 0.0;
233 p_sys->b_box_cleared = VLC_FALSE;
235 vlc_mutex_unlock( &p_sys->p_playlist->object_lock );
238 if( p_sys->b_box_plidx_follow )
240 p_sys->i_box_plidx = p_sys->p_playlist->i_index;
244 while( ( i_key = getch()) != -1 )
247 * HandleKey returns 1 if the screen needs to be redrawn
249 if ( HandleKey( p_intf, i_key ) )
251 Redraw( p_intf, &t_last_refresh );
255 if( p_sys->f_slider > 0.0001 && !p_sys->b_box_cleared )
258 Redraw( p_intf, &t_last_refresh );
259 p_sys->b_box_cleared = VLC_TRUE;
263 * redraw the screen every second
265 if ( (time(0) - t_last_refresh) >= 1 )
267 ManageSlider ( p_intf );
268 Redraw( p_intf, &t_last_refresh );
273 /* following functions are local */
275 static int HandleKey( intf_thread_t *p_intf, int i_key )
277 intf_sys_t *p_sys = p_intf->p_sys;
280 if( p_sys->i_box_type == BOX_PLAYLIST && p_sys->p_playlist )
282 int b_ret = VLC_TRUE;
288 playlist_Sort( p_sys->p_playlist, SORT_RANDOM, ORDER_NORMAL );
291 playlist_Sort( p_sys->p_playlist, SORT_TITLE, ORDER_NORMAL );
294 playlist_Sort( p_sys->p_playlist, SORT_TITLE, ORDER_REVERSE );
297 /* Playlist navigation */
299 p_sys->i_box_plidx = 0;
302 p_sys->i_box_plidx = p_sys->p_playlist->i_size - 1;
305 p_sys->i_box_plidx--;
308 p_sys->i_box_plidx++;
311 p_sys->i_box_plidx -= p_sys->i_box_lines;
314 p_sys->i_box_plidx += p_sys->i_box_lines;
319 int i_item = p_sys->p_playlist->i_index;
321 playlist_Delete( p_sys->p_playlist, p_sys->i_box_plidx );
322 if( i_item < p_sys->p_playlist->i_size && i_item != p_sys->p_playlist->i_index )
324 playlist_Goto( p_sys->p_playlist, i_item );
331 playlist_Goto( p_sys->p_playlist, p_sys->i_box_plidx );
340 if( p_sys->i_box_plidx >= p_sys->p_playlist->i_size ) p_sys->i_box_plidx = p_sys->p_playlist->i_size - 1;
341 if( p_sys->i_box_plidx < 0 ) p_sys->i_box_plidx = 0;
342 if( p_sys->i_box_plidx == p_sys->p_playlist->i_index )
343 p_sys->b_box_plidx_follow = VLC_TRUE;
345 p_sys->b_box_plidx_follow = VLC_FALSE;
349 else if( p_sys->i_box_type == BOX_HELP || p_sys->i_box_type == BOX_INFO )
354 p_sys->i_box_start = 0;
357 p_sys->i_box_start = p_sys->i_box_lines_total - 1;
360 if( p_sys->i_box_start > 0 ) p_sys->i_box_start--;
363 if( p_sys->i_box_start < p_sys->i_box_lines_total - 1 )
365 p_sys->i_box_start++;
369 p_sys->i_box_start -= p_sys->i_box_lines;
370 if( p_sys->i_box_start < 0 ) p_sys->i_box_start = 0;
373 p_sys->i_box_start += p_sys->i_box_lines;
374 if( p_sys->i_box_start >= p_sys->i_box_lines_total )
376 p_sys->i_box_start = p_sys->i_box_lines_total - 1;
383 else if( p_sys->i_box_type == BOX_NONE )
389 ManageSlider ( p_intf );
392 p_sys->f_slider = 99.9;
393 ManageSlider ( p_intf );
396 p_sys->f_slider += 5.0;
397 if( p_sys->f_slider >= 99.0 ) p_sys->f_slider = 99.0;
398 ManageSlider ( p_intf );
401 p_sys->f_slider -= 5.0;
402 if( p_sys->f_slider < 0.0 ) p_sys->f_slider = 0.0;
403 ManageSlider ( p_intf );
422 if( p_sys->i_box_type == BOX_INFO )
423 p_sys->i_box_type = BOX_NONE;
425 p_sys->i_box_type = BOX_INFO;
426 p_sys->i_box_lines_total = 0;
429 if( p_sys->i_box_type == BOX_LOG )
430 p_sys->i_box_type = BOX_NONE;
432 p_sys->i_box_type = BOX_LOG;
435 if( p_sys->i_box_type == BOX_PLAYLIST )
436 p_sys->i_box_type = BOX_NONE;
438 p_sys->i_box_type = BOX_PLAYLIST;
442 if( p_sys->i_box_type == BOX_HELP )
443 p_sys->i_box_type = BOX_NONE;
445 p_sys->i_box_type = BOX_HELP;
446 p_sys->i_box_lines_total = 0;
451 p_sys->f_slider += 1.0;
452 if( p_sys->f_slider > 99.9 ) p_sys->f_slider = 99.9;
453 ManageSlider ( p_intf );
457 p_sys->f_slider -= 1.0;
458 if( p_sys->f_slider < 0.0 ) p_sys->f_slider = 0.0;
459 ManageSlider ( p_intf );
465 vout_thread_t *p_vout;
466 if( p_intf->p_sys->p_input )
468 p_vout = vlc_object_find( p_intf->p_sys->p_input,
469 VLC_OBJECT_VOUT, FIND_CHILD );
472 p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
473 vlc_object_release( p_vout );
484 if( p_intf->p_sys->p_playlist )
486 playlist_Stop( p_intf->p_sys->p_playlist );
497 val.b_bool = VLC_TRUE;
498 var_Set( p_sys->p_input, "prev-title", val );
505 val.b_bool = VLC_TRUE;
506 var_Set( p_sys->p_input, "next-title", val );
513 val.b_bool = VLC_TRUE;
514 var_Set( p_sys->p_input, "prev-chapter", val );
521 val.b_bool = VLC_TRUE;
522 var_Set( p_sys->p_input, "next-chapter", val );
527 if( p_intf->p_sys->p_playlist )
529 playlist_Prev( p_intf->p_sys->p_playlist );
534 if( p_intf->p_sys->p_playlist )
536 playlist_Next( p_intf->p_sys->p_playlist );
542 * ^l should clear and redraw the screen
553 static void ManageSlider ( intf_thread_t *p_intf )
555 intf_sys_t *p_sys = p_intf->p_sys;
556 input_thread_t *p_input = p_sys->p_input;
559 if( p_input == NULL )
563 var_Get( p_input, "state", &val );
564 if( val.i_int != PLAYING_S )
569 var_Get( p_input, "position", &val );
570 if( p_sys->f_slider == p_sys->f_slider_old )
573 p_sys->f_slider_old = 100 * val.f_float;
577 p_sys->f_slider_old = p_sys->f_slider;
579 val.f_float = p_sys->f_slider / 100.0;
580 var_Set( p_input, "position", val );
584 static void mvnprintw( int y, int x, int w, const char *p_fmt, ... )
590 va_start ( vl_args, p_fmt );
591 vasprintf ( &p_buf, p_fmt, vl_args );
600 if( ( i_len = strlen( p_buf ) ) > w )
602 int i_cut = i_len - w;
603 int x1 = i_len/2 - i_cut/2;
608 memmove( &p_buf[x1], &p_buf[x2], i_len - x2 );
617 mvprintw( y, x, "%s", p_buf );
621 mvprintw( y, x, "%s", p_buf );
622 mvhline( y, x + i_len, ' ', w - i_len );
626 static void MainBoxWrite( intf_thread_t *p_intf, int l, int x, const char *p_fmt, ... )
628 intf_sys_t *p_sys = p_intf->p_sys;
633 if( l < p_sys->i_box_start || l - p_sys->i_box_start >= p_sys->i_box_lines )
638 va_start ( vl_args, p_fmt );
639 vasprintf ( &p_buf, p_fmt, vl_args );
647 mvnprintw( p_sys->i_box_y + l - p_sys->i_box_start, x, COLS - x - 1, "%s", p_buf );
650 static void Redraw ( intf_thread_t *p_intf, time_t *t_last_refresh )
652 intf_sys_t *p_sys = p_intf->p_sys;
653 input_thread_t *p_input = p_sys->p_input;
661 attrset ( A_REVERSE );
662 mvnprintw( y, 0, COLS, VOUT_TITLE " (ncurses interface) [ h for help ]" );
663 attroff ( A_REVERSE );
667 if( p_input && !p_input->b_dead )
669 char buf1[MSTRTIME_MAX_SIZE];
670 char buf2[MSTRTIME_MAX_SIZE];
672 vlc_value_t val_list;
675 mvnprintw( y++, 0, COLS, " Source : %s", p_input->psz_source );
678 var_Get( p_input, "state", &val );
679 if( val.i_int == PLAYING_S )
681 mvnprintw( y++, 0, COLS, " State : Playing" );
683 else if( val.i_int == PAUSE_S )
685 mvnprintw( y++, 0, COLS, " State : Paused" );
691 if( val.i_int != INIT_S && val.i_int != END_S )
694 var_Get( p_input, "time", &val );
695 msecstotimestr( buf1, val.i_time / 1000 );
697 var_Get( p_input, "length", &val );
698 msecstotimestr( buf2, val.i_time / 1000 );
700 mvnprintw( y++, 0, COLS, " Position : %s/%s (%.2f%%)", buf1, buf2, p_sys->f_slider );
703 if( !var_Get( p_input, "title", &val ) )
705 var_Change( p_input, "title", VLC_VAR_GETCHOICES, &val_list, NULL );
706 if( val_list.p_list->i_count > 0 )
708 mvnprintw( y++, 0, COLS, " Title : %d/%d", val.i_int, val_list.p_list->i_count );
710 var_Change( p_input, "title", VLC_VAR_FREELIST, &val_list, NULL );
714 if( !var_Get( p_input, "chapter", &val ) )
716 var_Change( p_input, "chapter", VLC_VAR_GETCHOICES, &val_list, NULL );
717 if( val_list.p_list->i_count > 0 )
719 mvnprintw( y++, 0, COLS, " Chapter : %d/%d", val.i_int, val_list.p_list->i_count );
721 var_Change( p_input, "chapter", VLC_VAR_FREELIST, &val_list, NULL );
731 mvnprintw( y++, 0, COLS, "Source: <no current item>" );
732 DrawEmptyLine( p_sys->w, y++, 0, COLS );
733 DrawEmptyLine( p_sys->w, y++, 0, COLS );
736 DrawBox( p_sys->w, y, 0, 3, COLS, "" );
737 DrawEmptyLine( p_sys->w, y+1, 1, COLS-2);
738 DrawLine( p_sys->w, y+1, 1, (int)(p_intf->p_sys->f_slider/100.0 * (COLS -2)) );
741 p_sys->i_box_y = y + 1;
742 p_sys->i_box_lines = LINES - y - 2;
747 if( p_sys->i_box_type == BOX_HELP )
751 DrawBox( p_sys->w, y++, 0, h, COLS, " Help " );
753 MainBoxWrite( p_intf, l++, 1, "[Display]" );
754 MainBoxWrite( p_intf, l++, 1, " h,H Show/Hide help box" );
755 MainBoxWrite( p_intf, l++, 1, " i Show/Hide informations box" );
756 MainBoxWrite( p_intf, l++, 1, " l Show/Hide logs box" );
757 MainBoxWrite( p_intf, l++, 1, " P Show/Hide playlist box" );
758 MainBoxWrite( p_intf, l++, 1, "" );
760 MainBoxWrite( p_intf, l++, 1, "[Global]" );
761 MainBoxWrite( p_intf, l++, 1, " q, Q Quit" );
762 MainBoxWrite( p_intf, l++, 1, " s Stop" );
763 MainBoxWrite( p_intf, l++, 1, " <space> Pause/Play" );
764 MainBoxWrite( p_intf, l++, 1, " n, p Next/Previous item" );
765 MainBoxWrite( p_intf, l++, 1, " [, ] Next/Previous title" );
766 MainBoxWrite( p_intf, l++, 1, " <, > Next/Previous title" );
767 MainBoxWrite( p_intf, l++, 1, " <right> Seek +1%%" );
768 MainBoxWrite( p_intf, l++, 1, " <left> Seek -1%%" );
769 MainBoxWrite( p_intf, l++, 1, "" );
771 MainBoxWrite( p_intf, l++, 1, "[Playlist]" );
772 MainBoxWrite( p_intf, l++, 1, " r Randomize playlist" );
773 MainBoxWrite( p_intf, l++, 1, " o Order Playlist" );
774 MainBoxWrite( p_intf, l++, 1, " O Reverse order Playlist" );
775 MainBoxWrite( p_intf, l++, 1, " <del> Delete an entry" );
776 MainBoxWrite( p_intf, l++, 1, " <backspace> Delete an entry" );
777 MainBoxWrite( p_intf, l++, 1, "" );
779 MainBoxWrite( p_intf, l++, 1, "[Boxes]" );
780 MainBoxWrite( p_intf, l++, 1, " <up>,<down> Navigate through the box line by line" );
781 MainBoxWrite( p_intf, l++, 1, " <pgup>,<pgdown> Navigate through the box page by page" );
782 MainBoxWrite( p_intf, l++, 1, "" );
784 MainBoxWrite( p_intf, l++, 1, "[Player]" );
785 MainBoxWrite( p_intf, l++, 1, " <up>,<down> Seek +/-5%%" );
786 MainBoxWrite( p_intf, l++, 1, "" );
788 MainBoxWrite( p_intf, l++, 1, "[Miscellaneous]" );
789 MainBoxWrite( p_intf, l++, 1, " Ctrl-L Refresh the screen" );
791 p_sys->i_box_lines_total = l;
792 if( p_sys->i_box_start >= p_sys->i_box_lines_total )
794 p_sys->i_box_start = p_sys->i_box_lines_total - 1;
797 if( l - p_sys->i_box_start < p_sys->i_box_lines )
799 y += l - p_sys->i_box_start;
803 y += p_sys->i_box_lines;
806 else if( p_sys->i_box_type == BOX_INFO )
810 DrawBox( p_sys->w, y++, 0, h, COLS, " Information " );
814 input_info_category_t * p_category;
815 input_info_t * p_info;
817 vlc_mutex_lock( &p_input->stream.stream_lock );
818 p_category = p_input->stream.p_info;
821 if( y >= y_end ) break;
822 MainBoxWrite( p_intf, l++, 1, " [%s]", p_category->psz_name );
823 p_info = p_category->p_info;
826 if( y >= y_end ) break;
827 MainBoxWrite( p_intf, l++, 1, " %s: %s", p_info->psz_name, p_info->psz_value );
828 p_info = p_info->p_next;
830 p_category = p_category->p_next;
832 vlc_mutex_unlock( &p_input->stream.stream_lock );
836 MainBoxWrite( p_intf, l++, 1, "No item currently playing" );
838 p_sys->i_box_lines_total = l;
839 if( p_sys->i_box_start >= p_sys->i_box_lines_total )
841 p_sys->i_box_start = p_sys->i_box_lines_total - 1;
844 if( l - p_sys->i_box_start < p_sys->i_box_lines )
846 y += l - p_sys->i_box_start;
850 y += p_sys->i_box_lines;
853 else if( p_sys->i_box_type == BOX_LOG )
859 DrawBox( p_sys->w, y++, 0, h, COLS, " Logs " );
861 i_start = p_intf->p_sys->p_sub->i_start;
863 vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock );
864 i_stop = *p_intf->p_sys->p_sub->pi_stop;
865 vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );
869 static const char *ppsz_type[4] = { "", "error", "warning", "debug" };
870 if( i_line >= h - 2 )
876 if( i_stop < 0 ) i_stop += VLC_MSG_QSIZE;
877 if( i_stop == i_start )
881 mvnprintw( y + h-2-i_line, 1, COLS - 2, " [%s] %s",
882 ppsz_type[p_sys->p_sub->p_msg[i_stop].i_type],
883 p_sys->p_sub->p_msg[i_stop].psz_msg );
886 vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock );
887 p_intf->p_sys->p_sub->i_start = i_stop;
888 vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );
891 else if( p_sys->i_box_type == BOX_PLAYLIST && p_sys->p_playlist )
894 playlist_t *p_playlist = p_sys->p_playlist;
897 DrawBox( p_sys->w, y++, 0, h, COLS, " Playlist " );
899 if( p_sys->i_box_plidx >= p_playlist->i_size ) p_sys->i_box_plidx = p_playlist->i_size - 1;
900 if( p_sys->i_box_plidx < 0 ) p_sys->i_box_plidx = 0;
902 if( p_sys->i_box_plidx < (h - 2)/2 )
907 else if( p_playlist->i_size - p_sys->i_box_plidx > (h - 2)/2 )
909 i_start = p_sys->i_box_plidx - (h - 2)/2;
910 i_stop = i_start + h - 2;
914 i_stop = p_playlist->i_size;
915 i_start = p_playlist->i_size - (h - 2);
921 if( i_stop > p_playlist->i_size )
923 i_stop = p_playlist->i_size;
926 for( i_item = i_start; i_item < i_stop; i_item++ )
928 vlc_bool_t b_selected = ( p_sys->i_box_plidx == i_item );
929 int c = p_playlist->i_index == i_item ? '>' : ' ';
931 if( y >= y_end ) break;
934 attrset( A_REVERSE );
936 if( !strcmp( p_playlist->pp_items[i_item]->psz_name, p_playlist->pp_items[i_item]->psz_uri ) )
938 mvnprintw( y++, 1, COLS - 2, "%c %d - '%s'",
941 p_playlist->pp_items[i_item]->psz_uri );
945 mvnprintw( y++, 1, COLS - 2, "%c %d - '%s' (%s)",
948 p_playlist->pp_items[i_item]->psz_uri,
949 p_playlist->pp_items[i_item]->psz_name );
953 attroff ( A_REVERSE );
964 DrawEmptyLine( p_sys->w, y++, 1, COLS - 2 );
969 *t_last_refresh = time( 0 );
972 static void Eject ( intf_thread_t *p_intf )
974 char *psz_device = NULL, *psz_parser, *psz_name;
977 * Get the active input
978 * Determine whether we can eject a media, ie it's a DVD, VCD or CD-DA
979 * If it's neither of these, then return
982 playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
985 if( p_playlist == NULL )
990 vlc_mutex_lock( &p_playlist->object_lock );
992 if( p_playlist->i_index < 0 )
994 vlc_mutex_unlock( &p_playlist->object_lock );
995 vlc_object_release( p_playlist );
999 psz_name = p_playlist->pp_items[ p_playlist->i_index ]->psz_name;
1003 if( !strncmp(psz_name, "dvd://", 4) )
1005 switch( psz_name[strlen("dvd://")] )
1009 psz_device = config_GetPsz( p_intf, "dvd" );
1012 /* Omit the first MRL-selector characters */
1013 psz_device = strdup( psz_name + strlen("dvd://" ) );
1017 else if( !strncmp(psz_name, VCD_MRL, strlen(VCD_MRL)) )
1019 switch( psz_name[strlen(VCD_MRL)] )
1023 psz_device = config_GetPsz( p_intf, VCD_MRL );
1026 /* Omit the beginning MRL-selector characters */
1027 psz_device = strdup( psz_name + strlen(VCD_MRL) );
1031 else if( !strncmp(psz_name, CDDA_MRL, strlen(CDDA_MRL) ) )
1033 switch( psz_name[strlen(CDDA_MRL)] )
1037 psz_device = config_GetPsz( p_intf, "cd-audio" );
1040 /* Omit the beginning MRL-selector characters */
1041 psz_device = strdup( psz_name + strlen(CDDA_MRL) );
1047 psz_device = strdup( psz_name );
1051 vlc_mutex_unlock( &p_playlist->object_lock );
1052 vlc_object_release( p_playlist );
1054 if( psz_device == NULL )
1059 /* Remove what we have after @ */
1060 psz_parser = psz_device;
1061 for( psz_parser = psz_device ; *psz_parser ; psz_parser++ )
1063 if( *psz_parser == '@' )
1070 /* If there's a stream playing, we aren't allowed to eject ! */
1071 if( p_intf->p_sys->p_input == NULL )
1073 msg_Dbg( p_intf, "ejecting %s", psz_device );
1075 intf_Eject( p_intf, psz_device );
1082 static void PlayPause ( intf_thread_t *p_intf )
1084 input_thread_t *p_input = p_intf->p_sys->p_input;
1089 var_Get( p_input, "state", &val );
1090 if( val.i_int != PAUSE_S )
1092 val.i_int = PAUSE_S;
1096 val.i_int = PLAYING_S;
1098 var_Set( p_input, "state", val );
1100 else if( p_intf->p_sys->p_playlist )
1102 playlist_Play( p_intf->p_sys->p_playlist );
1106 /****************************************************************************
1108 ****************************************************************************/
1109 static void DrawBox( WINDOW *win, int y, int x, int h, int w, char *title )
1114 if( w > 3 && h > 2 )
1116 if( title == NULL ) title = "";
1117 i_len = strlen( title );
1119 if( i_len > w - 2 ) i_len = w - 2;
1121 mvwaddch( win, y, x, ACS_ULCORNER );
1122 mvwhline( win, y, x+1, ACS_HLINE, ( w-i_len-2)/2 );
1123 mvwprintw( win,y, x+1+(w-i_len-2)/2, "%s", title );
1124 mvwhline( win, y, x+(w-i_len)/2+i_len, ACS_HLINE, w - 1 - ((w-i_len)/2+i_len) );
1125 mvwaddch( win, y, x+w-1,ACS_URCORNER );
1127 for( i = 0; i < h-2; i++ )
1129 mvwaddch( win, y+i+1, x, ACS_VLINE );
1130 mvwaddch( win, y+i+1, x+w-1, ACS_VLINE );
1133 mvwaddch( win, y+h-1, x, ACS_LLCORNER );
1134 mvwhline( win, y+h-1, x+1, ACS_HLINE, w - 2 );
1135 mvwaddch( win, y+h-1, x+w-1, ACS_LRCORNER );
1139 static void DrawEmptyLine( WINDOW *win, int y, int x, int w )
1143 mvhline( y, x, ' ', w );
1147 static void DrawLine( WINDOW *win, int y, int x, int w )
1151 attrset( A_REVERSE );
1152 mvhline( y, x, ' ', w );
1153 attroff ( A_REVERSE );