1 /*****************************************************************************
2 * intf_beos.cpp: beos interface
3 *****************************************************************************
4 * Copyright (C) 1999, 2000, 2001 VideoLAN
5 * $Id: intf_beos.cpp,v 1.31 2001/05/31 03:57:54 sam Exp $
7 * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
8 * Samuel Hocevar <sam@zoy.org>
9 * Tony Castley <tony@castley.net>
10 * Richard Shepherd <richard@rshepherd.demon.co.uk>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
25 *****************************************************************************/
27 #define MODULE_NAME beos
28 #include "modules_inner.h"
30 /*****************************************************************************
32 *****************************************************************************/
36 #include <stdlib.h> /* malloc(), free() */
38 #include <kernel/OS.h>
39 #include <storage/Path.h>
45 #include <StatusBar.h>
46 #include <Application.h>
50 #include <DirectWindow.h>
55 #include <FilePanel.h>
59 #include <Directory.h>
62 #include <StorageDefs.h>
64 #include <scsiprobe_driver.h>
74 #include "stream_control.h"
75 #include "input_ext-intf.h"
77 #include "interface.h"
78 #include "intf_playlist.h"
80 #include "audio_output.h"
86 #include "modules_export.h"
89 #include "InterfaceWindow.h"
91 #include "TransportButton.h"
93 /*****************************************************************************
94 * intf_sys_t: description and status of FB interface
95 *****************************************************************************/
96 typedef struct intf_sys_s
98 InterfaceWindow * p_window;
102 /*****************************************************************************
104 *****************************************************************************/
106 InterfaceWindow::InterfaceWindow( BRect frame, const char *name,
107 intf_thread_t *p_interface )
108 : BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
109 B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK
110 | B_ASYNCHRONOUS_CONTROLS )
113 p_intf = p_interface;
118 SetName( "interface" );
119 SetTitle(VOUT_TITLE " (BeOS interface)");
120 BRect rect(0, 0, 0, 0);
123 menu_bar = new BMenuBar(rect, "main menu");
124 AddChild( menu_bar );
132 menu_bar->AddItem( mFile = new BMenu( "File" ) );
133 menu_bar->ResizeToPreferred();
134 mFile->AddItem( mItem = new BMenuItem( "Open File" B_UTF8_ELLIPSIS,
135 new BMessage(OPEN_FILE), 'O') );
136 cd_menu = new CDMenu( "Open Disc" );
137 mFile->AddItem( cd_menu );
138 mFile->AddSeparatorItem();
139 mFile->AddItem( mItem = new BMenuItem( "About" B_UTF8_ELLIPSIS,
140 new BMessage(B_ABOUT_REQUESTED), 'A') );
141 mItem->SetTarget( be_app );
142 mFile->AddItem(mItem = new BMenuItem( "Quit",
143 new BMessage(B_QUIT_REQUESTED), 'Q') );
145 menu_bar->AddItem ( mAudio = new BMenu( "Audio" ) );
146 menu_bar->ResizeToPreferred();
147 mAudio->AddItem( new LanguageMenu( "Language", AUDIO_ES, p_intf ) );
148 mAudio->AddItem( new LanguageMenu( "Subtitles", SPU_ES, p_intf ) );
152 rect.top += menu_bar->Bounds().IntegerHeight() + 1;
155 p_view = new BBox( rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW, B_PLAIN_BORDER );
156 p_view->SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) );
160 ButtonRect.SetLeftTop(BPoint(xStart, yStart));
161 ButtonRect.SetRightBottom(ButtonRect.LeftTop() + kSkipButtonSize);
162 xStart += kRewindBitmapWidth;
163 TransportButton* p_slow = new TransportButton(ButtonRect, B_EMPTY_STRING,
165 kPressedSkipBackBitmapBits,
166 kDisabledSkipBackBitmapBits,
167 new BMessage(SLOWER_PLAY));
168 p_view->AddChild( p_slow );
171 ButtonRect.SetLeftTop(BPoint(xStart, yStart));
172 ButtonRect.SetRightBottom(ButtonRect.LeftTop() + kPlayButtonSize);
173 xStart += kPlayPauseBitmapWidth + 1.0;
174 PlayPauseButton* p_play = new PlayPauseButton(ButtonRect, B_EMPTY_STRING,
175 kPlayButtonBitmapBits,
176 kPressedPlayButtonBitmapBits,
177 kDisabledPlayButtonBitmapBits,
178 kPlayingPlayButtonBitmapBits,
179 kPressedPlayingPlayButtonBitmapBits,
180 kPausedPlayButtonBitmapBits,
181 kPressedPausedPlayButtonBitmapBits,
182 new BMessage(START_PLAYBACK));
184 p_view->AddChild( p_play );
185 /* p_play->SetPlaying(); */
188 ButtonRect.SetLeftTop(BPoint(xStart, yStart));
189 ButtonRect.SetRightBottom(ButtonRect.LeftTop() + kSkipButtonSize);
190 xStart += kRewindBitmapWidth;
191 TransportButton* p_fast = new TransportButton(ButtonRect, B_EMPTY_STRING,
192 kSkipForwardBitmapBits,
193 kPressedSkipForwardBitmapBits,
194 kDisabledSkipForwardBitmapBits,
195 new BMessage(FASTER_PLAY));
196 p_view->AddChild( p_fast );
199 ButtonRect.SetLeftTop(BPoint(xStart, yStart));
200 ButtonRect.SetRightBottom(ButtonRect.LeftTop() + kStopButtonSize);
201 xStart += kStopBitmapWidth;
202 TransportButton* p_stop = new TransportButton(ButtonRect, B_EMPTY_STRING,
203 kStopButtonBitmapBits,
204 kPressedStopButtonBitmapBits,
205 kDisabledStopButtonBitmapBits,
206 new BMessage(STOP_PLAYBACK));
207 p_view->AddChild( p_stop );
209 ButtonRect.SetLeftTop(BPoint(xStart + 5, yStart + 6));
210 ButtonRect.SetRightBottom(ButtonRect.LeftTop() + kSpeakerButtonSize);
211 xStart += kSpeakerIconBitmapWidth;
213 TransportButton* p_mute = new TransportButton(ButtonRect, B_EMPTY_STRING,
215 kPressedSpeakerIconBits,
217 new BMessage(VOLUME_MUTE));
219 p_view->AddChild( p_mute );
222 rgb_color fill_color = {0,255,0};
223 p_seek = new SeekSlider(BRect(5,2,255,15), this, 0, 100,
226 p_seek->UseFillColor(true, &fill_color);
227 p_view->AddChild( p_seek );
230 p_vol = new MediaSlider(BRect(xStart,20,255,30), new BMessage(VOLUME_CHG),
232 p_vol->SetValue(VOLUME_DEFAULT);
233 p_vol->UseFillColor(true, &fill_color);
234 p_view->AddChild( p_vol );
236 /* Set size and Show */
238 ResizeTo(260,50 + menu_bar->Bounds().IntegerHeight()+1);
242 InterfaceWindow::~InterfaceWindow()
246 /*****************************************************************************
247 * InterfaceWindow::MessageReceived
248 *****************************************************************************/
249 void InterfaceWindow::MessageReceived( BMessage * p_message )
251 int vol_val = p_vol->Value(); // remember the current volume
252 static int playback_status; // remember playback state
258 switch( p_message->what )
260 case B_ABOUT_REQUESTED:
261 alert = new BAlert(VOUT_TITLE, "BeOS " VOUT_TITLE "\n\n<www.videolan.org>", "Ok");
271 file_panel = new BFilePanel();
272 file_panel->SetTarget( this );
277 const char *psz_device;
278 char psz_source[ B_FILE_NAME_LENGTH + 4 ];
279 if( p_message->FindString("device", &psz_device) != B_ERROR )
281 snprintf( psz_source, B_FILE_NAME_LENGTH + 4,
282 "dvd:%s", psz_device );
283 psz_source[ strlen(psz_source) ] = '\0';
284 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, (char*)psz_source );
289 // this currently stops playback not nicely
290 if( p_intf->p_input != NULL )
292 // silence the sound, otherwise very horrible
293 vlc_mutex_lock( &p_aout_bank->lock );
294 for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
296 p_aout_bank->pp_aout[i_index]->i_savedvolume = p_aout_bank->pp_aout[i_index]->i_volume;
297 p_aout_bank->pp_aout[i_index]->i_volume = 0;
299 vlc_mutex_unlock( &p_aout_bank->lock );
302 /* end playing item */
303 p_intf->p_input->b_eof = 1;
305 /* update playlist */
306 vlc_mutex_lock( &p_main->p_playlist->change_lock );
307 p_main->p_playlist->i_index--;
308 p_main->p_playlist->b_stopped = 1;
309 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
314 /* starts playing in normal mode */
315 /* if (p_intf->p_input != NULL )
317 if (p_main->p_aout != NULL)
319 p_main->p_aout->i_vol = vol_val;
322 input_SetStatus(p_intf->p_input, INPUT_STATUS_PLAY);
323 playback_status = PLAYING;
329 /* toggle between pause and play */
330 if( p_intf->p_input != NULL )
332 /* pause if currently playing */
333 if( playback_status == PLAYING )
336 vlc_mutex_lock( &p_aout_bank->lock );
337 for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
339 p_aout_bank->pp_aout[i_index]->i_savedvolume =
340 p_aout_bank->pp_aout[i_index]->i_volume;
341 p_aout_bank->pp_aout[i_index]->i_volume = 0;
343 vlc_mutex_unlock( &p_aout_bank->lock );
345 /* pause the movie */
346 input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
347 vlc_mutex_lock( &p_main->p_playlist->change_lock );
348 p_main->p_playlist->b_stopped = 0;
349 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
350 playback_status = PAUSED;
354 /* Play after pausing */
355 /* Restore the volume */
356 vlc_mutex_lock( &p_aout_bank->lock );
357 for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
359 p_aout_bank->pp_aout[i_index]->i_volume =
360 p_aout_bank->pp_aout[i_index]->i_savedvolume;
361 p_aout_bank->pp_aout[i_index]->i_savedvolume = 0;
363 vlc_mutex_unlock( &p_aout_bank->lock );
367 input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
368 p_main->p_playlist->b_stopped = 0;
369 playback_status = PLAYING;
374 /* Play a new file */
375 vlc_mutex_lock( &p_main->p_playlist->change_lock );
376 if( p_main->p_playlist->b_stopped )
378 if( p_main->p_playlist->i_size )
380 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
381 intf_PlaylistJumpto( p_main->p_playlist,
382 p_main->p_playlist->i_index );
383 playback_status = PLAYING;
387 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
394 /* cycle the fast playback modes */
395 if( p_intf->p_input != NULL )
398 vlc_mutex_lock( &p_aout_bank->lock );
399 for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
401 p_aout_bank->pp_aout[i_index]->i_savedvolume =
402 p_aout_bank->pp_aout[i_index]->i_volume;
403 p_aout_bank->pp_aout[i_index]->i_volume = 0;
405 vlc_mutex_unlock( &p_aout_bank->lock );
408 /* change the fast play mode */
409 input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
410 vlc_mutex_lock( &p_main->p_playlist->change_lock );
411 p_main->p_playlist->b_stopped = 0;
412 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
417 /* cycle the slow playback modes */
418 if (p_intf->p_input != NULL )
421 vlc_mutex_lock( &p_aout_bank->lock );
422 for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
424 p_aout_bank->pp_aout[i_index]->i_savedvolume =
425 p_aout_bank->pp_aout[i_index]->i_volume;
426 p_aout_bank->pp_aout[i_index]->i_volume = 0;
428 vlc_mutex_unlock( &p_aout_bank->lock );
431 /* change the slower play */
432 input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
433 vlc_mutex_lock( &p_main->p_playlist->change_lock );
434 p_main->p_playlist->b_stopped = 0;
435 vlc_mutex_unlock( &p_main->p_playlist->change_lock );
440 /* handled by semaphores */
444 /* adjust the volume */
445 vlc_mutex_lock( &p_aout_bank->lock );
446 for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
448 if( p_aout_bank->pp_aout[i_index]->i_savedvolume )
450 p_aout_bank->pp_aout[i_index]->i_savedvolume = vol_val;
454 p_aout_bank->pp_aout[i_index]->i_volume = vol_val;
457 vlc_mutex_unlock( &p_aout_bank->lock );
462 vlc_mutex_lock( &p_aout_bank->lock );
463 for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
465 if( p_aout_bank->pp_aout[i_index]->i_savedvolume )
467 p_aout_bank->pp_aout[i_index]->i_volume =
468 p_aout_bank->pp_aout[i_index]->i_savedvolume;
469 p_aout_bank->pp_aout[i_index]->i_savedvolume = 0;
473 p_aout_bank->pp_aout[i_index]->i_savedvolume =
474 p_aout_bank->pp_aout[i_index]->i_volume;
475 p_aout_bank->pp_aout[i_index]->i_volume = 0;
478 vlc_mutex_unlock( &p_aout_bank->lock );
483 int32 i = p_message->FindInt32( "channel" );
486 input_ChangeES( p_intf->p_input, NULL, AUDIO_ES );
490 input_ChangeES( p_intf->p_input,
491 p_intf->p_input->stream.pp_es[i], AUDIO_ES );
496 case SELECT_SUBTITLE:
498 int32 i = p_message->FindInt32( "subtitle" );
501 input_ChangeES( p_intf->p_input, NULL, SPU_ES);
505 input_ChangeES( p_intf->p_input,
506 p_intf->p_input->stream.pp_es[i], SPU_ES );
511 case B_REFS_RECEIVED:
515 if( p_message->FindRef( "refs", &ref ) == B_OK )
518 intf_PlaylistAdd( p_main->p_playlist,
519 PLAYLIST_END, (char*)path.Path() );
525 BWindow::MessageReceived( p_message );
530 /*****************************************************************************
531 * InterfaceWindow::QuitRequested
532 *****************************************************************************/
533 bool InterfaceWindow::QuitRequested()
540 /*****************************************************************************
542 *****************************************************************************/
543 CDMenu::CDMenu(const char *name)
548 /*****************************************************************************
550 *****************************************************************************/
555 /*****************************************************************************
556 * CDMenu::AttachedToWindow
557 *****************************************************************************/
558 void CDMenu::AttachedToWindow(void)
560 while (RemoveItem((long int)0) != NULL); // remove all items
562 BMenu::AttachedToWindow();
565 /*****************************************************************************
567 *****************************************************************************/
568 int CDMenu::GetCD( const char *directory )
572 dir.SetTo( directory );
574 if( dir.InitCheck() != B_NO_ERROR )
582 while( dir.GetNextEntry(&entry) >= 0 )
588 if( entry.GetPath(&path) != B_NO_ERROR )
595 if( entry.GetRef(&e) != B_NO_ERROR )
600 if( entry.IsDirectory() )
602 if( strcmp(e.name, "floppy") == 0 )
604 continue; // ignore floppy (it is not silent)
607 i_dev = GetCD( name );
619 if( strcmp(e.name, "raw") != 0 )
621 continue; // ignore partitions
624 i_dev = open( name, O_RDONLY );
631 if( ioctl(i_dev, B_GET_GEOMETRY, &g, sizeof(g)) >= 0 )
633 if( g.device_type == B_CD ) //ensure the drive is a CD-ROM
635 if( ioctl(i_dev, B_GET_MEDIA_STATUS, &m, sizeof(m)) >= 0 )
637 if( m == B_NO_ERROR ) //ensure media is present
640 msg = new BMessage( OPEN_DVD );
641 msg->AddString( "device", name );
642 BMenuItem *menu_item;
643 menu_item = new BMenuItem( name, msg );
644 AddItem( menu_item );
656 /*****************************************************************************
657 * LanguageMenu::LanguageMenu
658 *****************************************************************************/
659 LanguageMenu::LanguageMenu(const char *name, int menu_kind, intf_thread_t *p_interface)
663 p_intf = p_interface;
666 /*****************************************************************************
667 * LanguageMenu::~LanguageMenu
668 *****************************************************************************/
669 LanguageMenu::~LanguageMenu()
673 /*****************************************************************************
674 * LanguageMenu::AttachedToWindow
675 *****************************************************************************/
676 void LanguageMenu::AttachedToWindow(void)
678 while( RemoveItem((long int)0) != NULL )
680 ; // remove all items
685 BMenu::AttachedToWindow();
688 /*****************************************************************************
689 * LanguageMenu::GetChannels
690 *****************************************************************************/
691 int LanguageMenu::GetChannels()
697 es_descriptor_t *p_es = NULL;
699 /* Insert the null */
700 if( kind == AUDIO_ES ) //audio
702 msg = new BMessage(SELECT_CHANNEL);
703 msg->AddInt32("channel", -1);
707 msg = new BMessage(SELECT_SUBTITLE);
708 msg->AddInt32("subtitle", -1);
710 BMenuItem *menu_item;
711 menu_item = new BMenuItem("None", msg);
713 menu_item->SetMarked(TRUE);
715 if( p_intf->p_input == NULL )
721 vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
722 for( i = 0; i < p_intf->p_input->stream.i_selected_es_number; i++ )
724 if( kind == p_intf->p_input->stream.pp_selected_es[i]->i_cat )
726 p_es = p_intf->p_input->stream.pp_selected_es[i];
730 for( i = 0; i < p_intf->p_input->stream.i_es_number; i++ )
732 if( kind == p_intf->p_input->stream.pp_es[i]->i_cat )
734 psz_name = p_intf->p_input->stream.pp_es[i]->psz_desc;
735 if( kind == AUDIO_ES ) //audio
737 msg = new BMessage(SELECT_CHANNEL);
738 msg->AddInt32("channel", i);
742 msg = new BMessage(SELECT_SUBTITLE);
743 msg->AddInt32("subtitle", i);
745 BMenuItem *menu_item;
746 menu_item = new BMenuItem(psz_name, msg);
748 b_active = (p_es == p_intf->p_input->stream.pp_es[i]);
749 menu_item->SetMarked(b_active);
752 vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
756 /*****************************************************************************
758 *****************************************************************************/
759 MediaSlider::MediaSlider( BRect frame, BMessage *p_message,
760 int32 i_min, int32 i_max )
761 :BSlider(frame, NULL, NULL, p_message, i_min, i_max )
766 MediaSlider::~MediaSlider()
771 void MediaSlider::DrawThumb(void)
776 rgb_color black = {0,0,0};
782 v->SetHighColor(black);
786 v->SetHighColor(tint_color(black, B_LIGHTEN_2_TINT));
789 r.InsetBy(r.IntegerWidth()/4, r.IntegerHeight()/(4 * r.IntegerWidth() / r.IntegerHeight()));
794 v->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
798 v->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_2_TINT));
805 /*****************************************************************************
807 *****************************************************************************/
808 SeekSlider::SeekSlider( BRect frame, InterfaceWindow *p_owner, int32 i_min,
809 int32 i_max, thumb_style thumbType = B_TRIANGLE_THUMB )
810 :MediaSlider( frame, NULL, i_min, i_max )
816 SeekSlider::~SeekSlider()
820 /*****************************************************************************
821 * SeekSlider::MouseDown
822 *****************************************************************************/
823 void SeekSlider::MouseDown(BPoint where)
825 BSlider::MouseDown(where);
826 fOwner->fScrubSem = create_sem(1, "Vlc::fScrubSem");
830 /*****************************************************************************
831 * SeekSlider::MouseUp
832 *****************************************************************************/
833 void SeekSlider::MouseMoved(BPoint where, uint32 code, const BMessage *message)
835 BSlider::MouseMoved(where, code, message);
838 release_sem(fOwner->fScrubSem);
841 /*****************************************************************************
842 * SeekSlider::MouseUp
843 *****************************************************************************/
844 void SeekSlider::MouseUp(BPoint where)
846 BSlider::MouseUp(where);
847 delete_sem(fOwner->fScrubSem);
848 fOwner->fScrubSem = B_ERROR;
856 /*****************************************************************************
858 *****************************************************************************/
859 static int intf_Probe ( probedata_t *p_data );
860 static int intf_Open ( intf_thread_t *p_intf );
861 static void intf_Close ( intf_thread_t *p_intf );
862 static void intf_Run ( intf_thread_t *p_intf );
864 /*****************************************************************************
865 * Functions exported as capabilities. They are declared as static so that
866 * we don't pollute the namespace too much.
867 *****************************************************************************/
868 void _M( intf_getfunctions )( function_list_t * p_function_list )
870 p_function_list->pf_probe = intf_Probe;
871 p_function_list->functions.intf.pf_open = intf_Open;
872 p_function_list->functions.intf.pf_close = intf_Close;
873 p_function_list->functions.intf.pf_run = intf_Run;
876 /*****************************************************************************
877 * intf_Probe: probe the interface and return a score
878 *****************************************************************************
879 * This function tries to initialize Gnome and returns a score to the
880 * plugin manager so that it can select the best plugin.
881 *****************************************************************************/
882 static int intf_Probe( probedata_t *p_data )
884 if( TestMethod( INTF_METHOD_VAR, "beos" ) )
892 /*****************************************************************************
893 * intf_Open: initialize interface
894 *****************************************************************************/
895 static int intf_Open( intf_thread_t *p_intf )
898 screen = new BScreen();
899 BRect rect = screen->Frame();
900 rect.top = rect.bottom-100;
903 rect.right = rect.left + 350;
906 /* Allocate instance and initialize some members */
907 p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) );
908 if( p_intf->p_sys == NULL )
910 intf_ErrMsg("error: %s", strerror(ENOMEM));
913 p_intf->p_sys->i_key = -1;
915 /* Create the interface window */
916 p_intf->p_sys->p_window =
917 new InterfaceWindow( rect,
918 VOUT_TITLE " (BeOS interface)", p_intf );
919 if( p_intf->p_sys->p_window == 0 )
921 free( p_intf->p_sys );
922 intf_ErrMsg( "error: cannot allocate memory for InterfaceWindow" );
929 /*****************************************************************************
930 * intf_Close: destroy dummy interface
931 *****************************************************************************/
932 static void intf_Close( intf_thread_t *p_intf )
934 /* Destroy the interface window */
935 p_intf->p_sys->p_window->Lock();
936 p_intf->p_sys->p_window->Quit();
938 /* Destroy structure */
939 free( p_intf->p_sys );
943 /*****************************************************************************
944 * intf_Run: event loop
945 *****************************************************************************/
946 static void intf_Run( intf_thread_t *p_intf )
949 bool seekNeeded = false;
951 while( !p_intf->b_die )
953 /* Manage core vlc functions through the callback */
954 p_intf->pf_manage( p_intf );
956 /* Manage the slider */
957 if( p_intf->p_input != NULL && p_intf->p_sys->p_window != NULL)
959 if( acquire_sem(p_intf->p_sys->p_window->fScrubSem) == B_OK )
966 uint32 seekTo = (p_intf->p_sys->p_window->p_seek->Value() *
967 p_intf->p_input->stream.p_selected_area->i_size) / 100;
968 input_Seek( p_intf->p_input, seekTo );
971 else if( p_intf->p_sys->p_window->Lock() )
973 progress = (100. * p_intf->p_input->stream.p_selected_area->i_tell) /
974 p_intf->p_input->stream.p_selected_area->i_size;
975 p_intf->p_sys->p_window->p_seek->SetValue(progress);
976 p_intf->p_sys->p_window->Unlock();
981 msleep( INTF_IDLE_SLEEP );