]> git.sesse.net Git - vlc/blobdiff - modules/gui/beos/VlcWrapper.cpp
* modules/gui/*: use MSTRTIME_MAX_SIZE instead of OFFSETTOTIME_MAX_SIZE.
[vlc] / modules / gui / beos / VlcWrapper.cpp
index e33cb386cb2c36c3362fb336e4bdb09eeb304c77..191048aed01202a70986383029c5a1d5b50f613b 100644 (file)
@@ -2,7 +2,7 @@
  * VlcWrapper.cpp: BeOS plugin for vlc (derived from MacOS X port)
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: VlcWrapper.cpp,v 1.32 2003/05/30 18:43:31 titer Exp $
+ * $Id: VlcWrapper.cpp,v 1.40 2003/12/04 10:25:47 gbazin Exp $
  *
  * Authors: Florian G. Pflug <fgp@phlo.org>
  *          Jon Lech Johansen <jon-vl@nanocrew.net>
@@ -96,15 +96,21 @@ bool VlcWrapper::HasInput()
 int VlcWrapper::InputStatus()
 {
     if( !p_input )
+    {
         return UNDEF_S;
+    }
     
-    return p_input->stream.control.i_status;
+    vlc_value_t state;
+    var_Get( p_input, "state", &state );
+    return state.i_int;
 }
 
 int VlcWrapper::InputRate()
 {
     if( !p_input )
+    {
         return DEFAULT_RATE;
+    }
     
     return p_input->stream.control.i_rate;
 }
@@ -112,49 +118,11 @@ int VlcWrapper::InputRate()
 void VlcWrapper::InputSetRate( int rate )
 {
     if( !p_input )
-        return;
-
-    int times = 0;
-    int oldrate = InputRate();
-    switch( ( rate > oldrate ) ? ( rate / oldrate ) : ( oldrate / rate ) )
     {
-        case 64:
-            times = 6;
-            break;
-        case 32:
-            times = 5;
-            break;
-        case 16:
-            times = 4;
-            break;
-        case 8:
-            times = 3;
-            break;
-        case 4:
-            times = 2;
-            break;
-        case 2:
-            times = 1;
-            break;
+        return;
     }
 
-    int newrate = oldrate;
-    for( int i = 0; i < times; i++ )
-    {
-        if( rate > oldrate )
-        {
-            input_SetStatus( p_input, INPUT_STATUS_SLOWER );
-            newrate *= 2;
-        }
-        else
-        {
-            input_SetStatus( p_input, INPUT_STATUS_FASTER );
-            newrate /= 2;
-        }
-        /* Wait it's actually done */
-        while( InputRate() != newrate )
-            msleep( 10000 );
-    }
+    input_SetRate( p_input, rate );
 }
 
 BList * VlcWrapper::GetChannels( int i_cat )
@@ -302,64 +270,63 @@ void VlcWrapper::ToggleSubtitle( int i_subtitle )
 
 const char * VlcWrapper::GetTimeAsString()
 {
-    static char psz_currenttime[ OFFSETTOTIME_MAX_SIZE ];
+    static char psz_time[ MSTRTIME_MAX_SIZE ];
         
-    if( p_input == NULL )
+    if( !p_input )
     {
         return ("-:--:--");
     }     
    
-    input_OffsetToTime( p_input, 
-                        psz_currenttime, 
-                        p_input->stream.p_selected_area->i_tell );        
+    vlc_value_t time;
+    var_Get( p_input, "time", &time );
+    
+    mtime_t seconds = time.i_time / 1000000;
+    sprintf( psz_time, "%d:%02d:%02d",
+             (int) ( seconds / (60 * 60 ) ),
+             (int) ( ( seconds / 60 ) % 60 ),
+             (int) ( seconds % 60 ) );
 
-    return(psz_currenttime);
+    return psz_time;
 }
 
 float VlcWrapper::GetTimeAsFloat()
 {
-    float f_time = 0.0;
-
-    if( p_input != NULL )
-    {
-        f_time = (float)p_input->stream.p_selected_area->i_tell / 
-                 (float)p_input->stream.p_selected_area->i_size;
-    }    
-    else
+    if( !p_input )
     {
-        f_time = 0.0;
+        return 0.0;
     }
-    return( f_time );
+    
+    vlc_value_t pos;
+    var_Get( p_input, "position", &pos );
+    return pos.f_float;
 }
 
 void VlcWrapper::SetTimeAsFloat( float f_position )
 {
-    if( p_input != NULL )
+    if( !p_input )
     {
-        input_Seek( p_input, 
-                   (long long)(p_input->stream.p_selected_area->i_size
-                       * f_position / SEEKSLIDER_RANGE ), 
-                   INPUT_SEEK_SET );
+        return;
     }
+    
+    vlc_value_t pos;
+    pos.f_float = f_position / SEEKSLIDER_RANGE;
+    var_Set( p_input, "position", pos );
 }
 
 bool VlcWrapper::IsPlaying()
 {
-
        bool playing = false;
-       if ( p_input )
+       if( p_input )
        {
-               switch ( p_input->stream.control.i_status )
+               switch( p_input->stream.control.i_status )
                {
                        case PLAYING_S:
                        case FORWARD_S:
                        case BACKWARD_S:
-                       case START_S:
                                playing = true;
                    break;
                        case PAUSE_S:
                        case UNDEF_S:
-                       case NOT_STARTED_S:
                        default:
                                break;
                }
@@ -398,7 +365,7 @@ void VlcWrapper::OpenFiles( BList* o_files, bool replace, int32 index )
                if ( BString* o_file = (BString *)o_files->RemoveItem( i ) )
                {
                        playlist_Add( p_playlist, o_file->String(),
-                                     mode, index );
+                                     0, 0, mode, index );
                        if ( mode == PLAYLIST_INSERT )
                                index++;
                        delete o_file;
@@ -421,7 +388,7 @@ void VlcWrapper::OpenDisc(BString o_type, BString o_device, int i_title, int i_c
         o_device.Prepend( "dvdplay:" );
     else
         o_device.Prepend( "dvdold:" );
-    playlist_Add( p_playlist, o_device.String(),
+    playlist_Add( p_playlist, o_device.String(), 0, 0,
                   PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
 }
 
@@ -789,14 +756,14 @@ void VlcWrapper::SetVolume( int value )
 
 void VlcWrapper::VolumeMute()
 {
-       aout_VolumeGet( p_intf, &p_intf->p_sys->i_saved_volume );
     aout_VolumeMute( p_intf, NULL );
     p_intf->p_sys->b_mute = 1;
 }
 
 void VlcWrapper::VolumeRestore()
 {
-    aout_VolumeSet( p_intf, p_intf->p_sys->i_saved_volume );
+    audio_volume_t dummy;
+    aout_VolumeMute( p_intf, &dummy );
     p_intf->p_sys->b_mute = 0;
 }
 
@@ -814,8 +781,20 @@ bool VlcWrapper::IsUsingMenus()
     if( !p_input )
         return false;
 
-    if( !strncmp( PlaylistItemName( PlaylistCurrent() ), "dvdplay:", 8 ) )
+    vlc_mutex_lock( &p_playlist->object_lock );
+    if( p_playlist->i_index < 0 )
+    {
+        vlc_mutex_unlock( &p_playlist->object_lock );
+        return false;
+    }
+    
+    char * psz_name = p_playlist->pp_items[p_playlist->i_index]->psz_name;
+    if( !strncmp( psz_name, "dvdplay:", 8 ) )
+    {
+        vlc_mutex_unlock( &p_playlist->object_lock );
         return true;
+    }
+    vlc_mutex_unlock( &p_playlist->object_lock );
 
     return false;
 }
@@ -1026,7 +1005,7 @@ void VlcWrapper::FilterChange()
     for( unsigned int i = 0; i < p_input->stream.i_es_number; i++ )
     {
         if( ( p_input->stream.pp_es[i]->i_cat == VIDEO_ES ) &&
-            ( p_input->stream.pp_es[i]->p_decoder_fifo != NULL ) )
+            ( p_input->stream.pp_es[i]->p_dec != NULL ) )
         {
             input_UnselectES( p_input, p_input->stream.pp_es[i] );
             input_SelectES( p_input, p_input->stream.pp_es[i] );