]> git.sesse.net Git - vlc/commitdiff
* AudioOutput.cpp: fixed a segfault
authorEric Petit <titer@videolan.org>
Wed, 27 Nov 2002 05:36:41 +0000 (05:36 +0000)
committerEric Petit <titer@videolan.org>
Wed, 27 Nov 2002 05:36:41 +0000 (05:36 +0000)
 * ALL: cleaned the VlcWrapper class, removed unused code

modules/gui/beos/AudioOutput.cpp
modules/gui/beos/Interface.cpp
modules/gui/beos/InterfaceWindow.cpp
modules/gui/beos/InterfaceWindow.h
modules/gui/beos/MediaControlView.cpp
modules/gui/beos/PlayListWindow.h
modules/gui/beos/VlcWrapper.cpp
modules/gui/beos/VlcWrapper.h

index e203561257b4e4619a4f66cea8dc96ef5a9dc921..3dd62861360e8edebb9d48d96b4fd5ae810cbe11 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
- * aout.cpp: BeOS audio output
+ * AudioOutput.cpp: BeOS audio output
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: AudioOutput.cpp,v 1.16 2002/11/22 19:37:25 titer Exp $
+ * $Id: AudioOutput.cpp,v 1.17 2002/11/27 05:36:41 titer Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -38,7 +38,8 @@
 #include <vlc/aout.h>
 #include <aout_internal.h>
 
-#define FRAME_SIZE 2048
+#define FRAME_SIZE  2048
+#define BUFFER_SIZE 16384
 
 /*****************************************************************************
  * aout_sys_t: BeOS audio output method descriptor
@@ -94,12 +95,12 @@ int E_(OpenAudio) ( vlc_object_t * p_this )
 #endif
     p_aout->output.output.i_format = VLC_FOURCC('f','l','3','2');
 
-    p_format->buffer_size = 16384;
+    p_format->buffer_size = BUFFER_SIZE;
     p_aout->output.i_nb_samples = FRAME_SIZE;
     p_aout->output.pf_play = DoNothing;
     
     p_sys->p_player = new BSoundPlayer( p_format, "player",
-                                        Play, NULL, p_this );
+                                        Play, NULL, p_aout );
     p_sys->p_player->Start();
     p_sys->p_player->SetHasData( true );
         
@@ -122,22 +123,25 @@ void E_(CloseAudio) ( vlc_object_t *p_this )
 /*****************************************************************************
  * Play
  *****************************************************************************/
-static void Play( void *aout, void *buffer, size_t size,
+static void Play( void *aout, void *p_buffer, size_t i_size,
                   const media_raw_audio_format &format )
 {
     aout_buffer_t * p_aout_buffer;
     aout_instance_t *p_aout = (aout_instance_t*) aout;
 
-    float *p_buffer = (float*) buffer;
-
     p_aout_buffer = aout_FifoPop( p_aout, &p_aout->output.fifo );
-    
+
     if( p_aout_buffer != NULL )
     {
-       memcpy( p_buffer,
-               p_aout_buffer->p_buffer,
-               MIN( size, p_aout_buffer->i_nb_bytes ) );
-       aout_BufferFree( p_aout_buffer );
+        /* sometimes p_aout_buffer is not NULL but still isn't valid.
+           we check i_nb_bytes so we are sure it is */
+        if( p_aout_buffer->i_nb_bytes == BUFFER_SIZE )
+        {
+           memcpy( (float*)p_buffer,
+                   p_aout_buffer->p_buffer,
+                   BUFFER_SIZE );
+           aout_BufferFree( p_aout_buffer );
+        }
     }
 }
 
index 31c501ce03392b8cd56936a3bbf00ff971f91598..b5247fa1d0a355480f5fed740bd860a790fe26c4 100644 (file)
@@ -2,7 +2,7 @@
  * intf_beos.cpp: beos interface
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: Interface.cpp,v 1.5 2002/11/26 01:06:08 titer Exp $
+ * $Id: Interface.cpp,v 1.6 2002/11/27 05:36:41 titer Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -72,7 +72,7 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
         return( 1 );
     }
     
-    p_intf->p_sys->p_wrapper = new Intf_VLCWrapper( p_intf );
+    p_intf->p_sys->p_wrapper = new VlcWrapper( p_intf );
 
     p_intf->pf_run = Run;
 
index 2f35c19dd56b971fbac7217b4bd42ec4bebd6e21..7710ef6f8ac30914b0504d977c35726101fc0f09 100644 (file)
@@ -2,7 +2,7 @@
  * InterfaceWindow.cpp: beos interface
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: InterfaceWindow.cpp,v 1.9 2002/11/26 01:06:08 titer Exp $
+ * $Id: InterfaceWindow.cpp,v 1.10 2002/11/27 05:36:41 titer Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -212,7 +212,7 @@ InterfaceWindow::FrameResized(float width, float height)
 void InterfaceWindow::MessageReceived( BMessage * p_message )
 {
        int playback_status;      // remember playback state
-       playback_status = p_wrapper->inputGetStatus();
+       playback_status = p_wrapper->InputStatus();
 
        switch( p_message->what )
        {
@@ -266,7 +266,7 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
                        {
                                p_wrapper->volume_mute();
                                snooze( 400000 );
-                               p_wrapper->playlistStop();
+                               p_wrapper->PlaylistStop();
                                p_mediaControl->SetStatus(NOT_STARTED_S, DEFAULT_RATE);
                        }
                        break;
@@ -283,18 +283,18 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
                                {
                                        p_wrapper->volume_mute();
                                        snooze( 400000 );
-                                       p_wrapper->playlistPause();
+                                       p_wrapper->PlaylistPause();
                                }
                                else
                                {
                                        p_wrapper->volume_restore();
-                                       p_wrapper->playlistPlay();
+                                       p_wrapper->PlaylistPlay();
                                }
                        }
                        else
                        {
                                /* Play a new file */
-                               p_wrapper->playlistPlay();
+                               p_wrapper->PlaylistPlay();
                        }       
                        break;
        
@@ -304,7 +304,7 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
                        {
                                p_wrapper->volume_mute();
                                snooze( 400000 );
-                               p_wrapper->playFaster();
+                               p_wrapper->InputFaster();
                        }
                        break;
        
@@ -314,7 +314,7 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
                        {
                                p_wrapper->volume_mute();
                                snooze( 400000 );
-                               p_wrapper->playSlower();
+                               p_wrapper->InputSlower();
                        }
                        break;
        
@@ -323,7 +323,7 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
                        if (playback_status > UNDEF_S)
                        {
                                p_wrapper->volume_restore();
-                               p_wrapper->playlistPlay();
+                               p_wrapper->PlaylistPlay();
                        }
                        break;
        
@@ -411,10 +411,10 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
                        }
                        break;
                case PREV_FILE:
-                       p_wrapper->playlistPrev();
+                       p_wrapper->PlaylistPrev();
                        break;
                case NEXT_FILE:
-                       p_wrapper->playlistNext();
+                       p_wrapper->PlaylistNext();
                        break;
                // general next/prev functionality (skips to whatever makes most sense)
                case NAVIGATE_PREV:
@@ -471,7 +471,7 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
  *****************************************************************************/
 bool InterfaceWindow::QuitRequested()
 {
-       p_wrapper->playlistStop();
+       p_wrapper->PlaylistStop();
        p_mediaControl->SetStatus(NOT_STARTED_S, DEFAULT_RATE);
        
        p_intf->b_die = 1;
index 70206213b32486c6142c1b8e90d4a3faaca8e9da..678119e729b31b256ccd5a92d99d3b881b51d1c9 100644 (file)
@@ -2,7 +2,7 @@
  * InterfaceWindow.h: BeOS interface window class prototype
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: InterfaceWindow.h,v 1.5 2002/11/26 01:06:08 titer Exp $
+ * $Id: InterfaceWindow.h,v 1.6 2002/11/27 05:36:41 titer Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Tony Castley <tcastley@mail.powerup.com.au>
@@ -152,7 +152,7 @@ class InterfaceWindow : public BWindow
        BMessage*                               fSettings;      // we keep the message arround
                                                                                // for forward compatibility
        
-       Intf_VLCWrapper *  p_wrapper;
+       VlcWrapper * p_wrapper;
 };
 
 #endif // BEOS_INTERFACE_WINDOW_H
index 9917f6235414b2f4fb4517973c7edd99e9ea0eca..b6708d2bdc22a1b5e6911852960659dfa1ea31c7 100644 (file)
@@ -2,7 +2,7 @@
  * MediaControlView.cpp: beos interface
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: MediaControlView.cpp,v 1.7 2002/11/26 01:06:08 titer Exp $
+ * $Id: MediaControlView.cpp,v 1.8 2002/11/27 05:36:41 titer Exp $
  *
  * Authors: Tony Castley <tony@castley.net>
  *          Stephan Aßmus <stippi@yellowbites.com>
@@ -1309,9 +1309,9 @@ PositionInfoView::Pulse()
                int32 index, size;
                p_intf->p_sys->p_wrapper->getPlaylistInfo( index, size );
                SetFile( index, size );
-               p_intf->p_sys->p_wrapper->getTitleInfo( index, size );
+               p_intf->p_sys->p_wrapper->TitleInfo( index, size );
                SetTitle( index, size );
-               p_intf->p_sys->p_wrapper->getChapterInfo( index, size );
+               p_intf->p_sys->p_wrapper->ChapterInfo( index, size );
                SetChapter( index, size );
                SetTime( p_intf->p_sys->p_wrapper->getTimeAsString() );
                fLastPulseUpdate = now;
index 9aa2d43b0b13a992c1b08990d7e4fcd3d4be533d..ee655c317477b8cd120489683b3f22badc7f9a85 100644 (file)
@@ -2,7 +2,7 @@
  * PlayListWindow.h: BeOS interface window class prototype
  *****************************************************************************
  * Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: PlayListWindow.h,v 1.4 2002/11/26 01:06:08 titer Exp $
+ * $Id: PlayListWindow.h,v 1.5 2002/11/27 05:36:41 titer Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Tony Castley <tcastley@mail.powerup.com.au>
@@ -59,7 +59,7 @@ class PlayListWindow : public BWindow
                        InterfaceWindow *   fMainWindow;
                        
                        intf_thread_t *     p_intf;
-                       Intf_VLCWrapper *   p_wrapper;
+                       VlcWrapper *   p_wrapper;
 };
 
 #endif // BEOS_PLAY_LIST_WINDOW_H
index 10db5197ae40e7ea1c113066a96f76c319baf087..fd22c494ceee78db514f8b03f744e26956571cc6 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
- * intf_vlc_wrapper.h: BeOS plugin for vlc (derived from MacOS X port )
+ * VlcWrapper.cpp: BeOS plugin for vlc (derived from MacOS X port)
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: VlcWrapper.cpp,v 1.11 2002/11/26 01:06:08 titer Exp $
+ * $Id: VlcWrapper.cpp,v 1.12 2002/11/27 05:36:41 titer Exp $
  *
  * Authors: Florian G. Pflug <fgp@phlo.org>
  *          Jon Lech Johansen <jon-vl@nanocrew.net>
@@ -24,7 +24,6 @@
  * along with this program{} if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
-/* VLC headers */
 #include <SupportKit.h>
 
 #include <vlc/vlc.h>
@@ -35,7 +34,7 @@
 #include "VlcWrapper.h"
 
 /* constructor */
-Intf_VLCWrapper::Intf_VLCWrapper(intf_thread_t *p_interface)
+VlcWrapper::VlcWrapper( intf_thread_t *p_interface )
 {
     p_intf = p_interface;
     p_input = NULL;
@@ -45,7 +44,7 @@ Intf_VLCWrapper::Intf_VLCWrapper(intf_thread_t *p_interface)
 }
 
 /* destructor */
-Intf_VLCWrapper::~Intf_VLCWrapper()
+VlcWrapper::~VlcWrapper()
 {
     if( p_input )
     {
@@ -63,7 +62,7 @@ Intf_VLCWrapper::~Intf_VLCWrapper()
 
 /* UpdateInputAndAOut: updates p_input and p_aout, returns true if the
    interface needs to be updated */
-bool Intf_VLCWrapper::UpdateInputAndAOut()
+bool VlcWrapper::UpdateInputAndAOut()
 {
     if( p_input == NULL )
     {
@@ -94,108 +93,252 @@ bool Intf_VLCWrapper::UpdateInputAndAOut()
     return false;
 }
 
-int Intf_VLCWrapper::InputStatus()
+
+/***************************
+ * input infos and control *
+ ***************************/
+
+/* status (UNDEF_S, PLAYING_S, PAUSE_S, FORWARD_S, BACKWARD_S,
+   REWIND_S, NOT_STARTED_S, START_S) */
+int VlcWrapper::InputStatus()
 {
+    if( !p_input )
+    {
+        return UNDEF_S;
+    }
     return p_input->stream.control.i_status;
 }
 
-int Intf_VLCWrapper::InputRate()
+int VlcWrapper::InputRate()
 {
+    if( !p_input )
+    {
+        return DEFAULT_RATE;
+    }
     return p_input->stream.control.i_rate;
 }
 
-int Intf_VLCWrapper::InputTell()
+/* tell: location in the current stream (in arbitrary units) */
+int VlcWrapper::InputTell()
 {
+    if( !p_input )
+    {
+        return -1;
+    }
     return p_input->stream.p_selected_area->i_tell;
 }
 
-int Intf_VLCWrapper::InputSize()
+/* size: total size of the current stream (in arbitrary units) */
+int VlcWrapper::InputSize()
 {
+    if( !p_input )
+    {
+        return -1;
+    }
     return p_input->stream.p_selected_area->i_size;
 }
 
-int Intf_VLCWrapper::PlaylistSize()
+void VlcWrapper::InputSlower()
 {
-    return p_playlist->i_size;
+    if( p_input != NULL )
+    {
+        input_SetStatus( p_input, INPUT_STATUS_SLOWER );
+    }
+    if( p_input->stream.control.i_rate == DEFAULT_RATE)
+    {
+        toggle_mute();
+    }
+    else
+    {
+        toggle_mute();
+    }
 }
 
-char *Intf_VLCWrapper::PlaylistItemName( int i )
+void VlcWrapper::InputFaster()
 {
-   return p_playlist->pp_items[i]->psz_name;
+    if( p_input != NULL )
+    {
+        input_SetStatus( p_input, INPUT_STATUS_FASTER );
+    }
+    if( p_input->stream.control.i_rate == DEFAULT_RATE)
+    {
+        toggle_mute();
+    }
+    else
+    {
+        toggle_mute();
+    }
 }
 
-int Intf_VLCWrapper::PlaylistCurrent()
+void VlcWrapper::openFiles( BList* o_files, bool replace )
 {
-    return p_playlist->i_index;
+    BString *o_file;
+
+    while( ( o_file = (BString *)o_files->LastItem() ) )
+    {
+        o_files->RemoveItem(o_files->CountItems() - 1);
+        playlist_Add( p_playlist, o_file->String(),
+                  PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+        delete o_file;
+    }
 }
 
-bool Intf_VLCWrapper::HasTitles()
+void VlcWrapper::openDisc(BString o_type, BString o_device, int i_title, int i_chapter)
 {
-    return ( p_input->stream.i_area_nb > 1 );
+    BString o_source("");
+    o_source << o_type << ":" << o_device ;
+
+    playlist_Add( p_playlist, o_source.String(),
+                  PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
 }
 
-void Intf_VLCWrapper::PrevTitle()
+
+
+void VlcWrapper::toggleLanguage(int i_language)
 {
-    int i_id;
-    i_id = p_input->stream.p_selected_area->i_id - 1;
-    if( i_id > 0 )
+
+    int32 i_old = -1;
+    int i_cat = AUDIO_ES;
+
+    vlc_mutex_lock( &p_input->stream.stream_lock );
+    for( int i = 0; i < p_input->stream.i_selected_es_number ; i++ )
     {
-        toggleTitle(i_id);
+        if( p_input->stream.pp_selected_es[i]->i_cat == i_cat )
+        {
+            i_old = i;
+            break;
+        }
+    }
+    vlc_mutex_unlock( &p_input->stream.stream_lock );
+
+    msg_Info( p_intf, "Old: %d,  New: %d", i_old, i_language);
+    if( i_language != -1 )
+    {
+        input_ToggleES( p_input, 
+                        p_input->stream.pp_selected_es[i_language],
+                        VLC_TRUE );
+    }
+
+    if( (i_old != -1) && (i_old != i_language) )
+    {
+        input_ToggleES( p_input, 
+                        p_input->stream.pp_selected_es[i_old],
+                        VLC_FALSE );
     }
 }
 
-void Intf_VLCWrapper::NextTitle()
+void VlcWrapper::toggleSubtitle(int i_subtitle)
 {
-    int i_id;
-    i_id = p_input->stream.p_selected_area->i_id + 1;
-    if( i_id < p_input->stream.i_area_nb )
+    int32 i_old = -1;
+    int i_cat = SPU_ES;
+
+    vlc_mutex_lock( &p_input->stream.stream_lock );
+    for( int i = 0; i < p_input->stream.i_selected_es_number ; i++ )
     {
-        toggleTitle(i_id);
+        if( p_input->stream.pp_selected_es[i]->i_cat == i_cat )
+        {
+            i_old = i;
+            break;
+        }
+    }
+    vlc_mutex_unlock( &p_input->stream.stream_lock );
+    
+    msg_Info( p_intf, "Old: %d,  New: %d", i_old, i_subtitle);
+    if( i_subtitle != -1 )
+    {
+        input_ToggleES( p_input, 
+                        p_input->stream.pp_selected_es[i_subtitle],
+                        VLC_TRUE );
+    }
+
+    if( (i_old != -1) && (i_old != i_subtitle) )
+    {
+        input_ToggleES( p_input, 
+                        p_input->stream.pp_selected_es[i_old],
+                        VLC_FALSE );
     }
 }
 
-bool Intf_VLCWrapper::HasChapters()
+const char*  VlcWrapper::getTimeAsString()
 {
-    return ( p_input->stream.p_selected_area->i_part_nb > 1 );
+    static char psz_currenttime[ OFFSETTOTIME_MAX_SIZE ];
+        
+    if( p_input == NULL )
+    {
+        return ("-:--:--");
+    }     
+   
+    input_OffsetToTime( p_input, 
+                        psz_currenttime, 
+                        p_input->stream.p_selected_area->i_tell );        
+
+    return(psz_currenttime);
 }
 
-void Intf_VLCWrapper::PrevChapter()
+float  VlcWrapper::getTimeAsFloat()
 {
-    int i_id;
-    i_id = p_input->stream.p_selected_area->i_part - 1;
-    if( i_id >= 0 )
+    float f_time = 0.0;
+
+    if( p_input != NULL )
     {
-        toggleChapter(i_id);
+        f_time = (float)p_input->stream.p_selected_area->i_tell / 
+                 (float)p_input->stream.p_selected_area->i_size;
+    }    
+    else
+    {
+        f_time = 0.0;
     }
+    return( f_time );
 }
 
-void Intf_VLCWrapper::NextChapter()
+void VlcWrapper::setTimeAsFloat(float f_position)
 {
-    int i_id;
-    i_id = p_input->stream.p_selected_area->i_part + 1;
-    if( i_id >= 0 )
+    if( p_input != NULL )
     {
-        toggleChapter(i_id);
+        input_Seek( p_input, 
+                   (long long int)(p_input->stream.p_selected_area->i_size
+                       * f_position / SEEKSLIDER_RANGE ), 
+                   INPUT_SEEK_SET);
     }
 }
 
-/* playlist control */
-bool Intf_VLCWrapper::playlistPlay()
+
+/******************************
+ * playlist infos and control *
+ ******************************/
+int VlcWrapper::PlaylistSize()
 {
     vlc_mutex_lock( &p_playlist->object_lock );
-    if( p_playlist->i_size )
+    int i_size = p_playlist->i_size;
+    vlc_mutex_unlock( &p_playlist->object_lock );
+    return i_size;
+}
+
+char *VlcWrapper::PlaylistItemName( int i )
+{
+   return p_playlist->pp_items[i]->psz_name;
+}
+
+int VlcWrapper::PlaylistCurrent()
+{
+    return p_playlist->i_index;
+}
+
+int  VlcWrapper::PlaylistStatus()
+{
+    return p_playlist->i_status;
+}
+
+bool VlcWrapper::PlaylistPlay()
+{
+    if( PlaylistSize() )
     {
-        vlc_mutex_unlock( &p_playlist->object_lock );
         playlist_Play( p_playlist );
     }
-    else
-    {
-        vlc_mutex_unlock( &p_playlist->object_lock );
-    }
     return( true );
 }
 
-void Intf_VLCWrapper::playlistPause()
+void VlcWrapper::PlaylistPause()
 {
     toggle_mute();
     if( p_input )
@@ -204,33 +347,79 @@ void Intf_VLCWrapper::playlistPause()
     }
 }
 
-void Intf_VLCWrapper::playlistStop()
+void VlcWrapper::PlaylistStop()
 {
     volume_mute();
     playlist_Stop( p_playlist );
 }
 
-void Intf_VLCWrapper::playlistNext()
+void VlcWrapper::PlaylistNext()
 {
     playlist_Next( p_playlist );
 }
 
-void Intf_VLCWrapper::playlistPrev()
+void VlcWrapper::PlaylistPrev()
 {
     playlist_Prev( p_playlist );
 }
 
-void Intf_VLCWrapper::playlistSkip(int i)
+void VlcWrapper::PlaylistSkip( int i )
 {
     playlist_Skip( p_playlist, i );
 }
 
-void Intf_VLCWrapper::playlistGoto(int i)
+void VlcWrapper::PlaylistGoto( int i )
 {
     playlist_Goto( p_playlist, i );
 }
 
-void Intf_VLCWrapper::playlistJumpTo( int pos )
+void VlcWrapper::PlaylistLoop()
+{
+    if ( p_intf->p_sys->b_loop )
+    {
+        playlist_Delete( p_playlist, p_playlist->i_size - 1 );
+    }
+    else
+    {
+        playlist_Add( p_playlist, "vlc:loop",
+                      PLAYLIST_APPEND | PLAYLIST_GO,
+                      PLAYLIST_END );
+    }
+    p_intf->p_sys->b_loop = !p_intf->p_sys->b_loop;
+}
+
+BList * VlcWrapper::PlaylistAsArray()
+{ 
+    int i;
+    BList* p_list = new BList(p_playlist->i_size);
+    
+    vlc_mutex_lock( &p_playlist->object_lock );
+
+    for( i = 0; i < p_playlist->i_size; i++ )
+    {
+        p_list->AddItem(new BString(p_playlist->pp_items[i]->psz_name));
+    }
+
+    vlc_mutex_unlock( &p_playlist->object_lock );
+    return( p_list );
+}
+
+void VlcWrapper::getPlaylistInfo( int32& currentIndex, int32& maxIndex )
+{
+       currentIndex = -1;
+       maxIndex = -1;
+       if ( p_playlist )
+       {
+               maxIndex = p_playlist->i_size;
+               if ( maxIndex > 0 )
+                       currentIndex = p_playlist->i_index + 1;
+               else
+                       maxIndex = -1;
+       }
+}
+
+
+void VlcWrapper::PlaylistJumpTo( int pos )
 {
 #if 0
        // sanity checks
@@ -253,34 +442,7 @@ void Intf_VLCWrapper::playlistJumpTo( int pos )
 #endif
 }
 
-int Intf_VLCWrapper::playlistCurrentPos()
-{
-       playlistLock();
-       int pos = p_playlist->i_index;
-       playlistUnlock();
-       return pos;
-}
-
-int Intf_VLCWrapper::playlistSize()
-{
-       playlistLock();
-       int size = p_playlist->i_size;
-       playlistUnlock();
-       return size;
-}
-
-void Intf_VLCWrapper::playlistLock()
-{
-       vlc_mutex_lock( &p_playlist->object_lock );
-}
-
-void Intf_VLCWrapper::playlistUnlock()
-{
-       vlc_mutex_unlock( &p_playlist->object_lock );
-}
-
-void Intf_VLCWrapper::getNavCapabilities( bool* canSkipPrev,
-                                                                                 bool* canSkipNext )
+void VlcWrapper::getNavCapabilities( bool *canSkipPrev, bool *canSkipNext )
 {
        if ( canSkipPrev && canSkipNext )
        {
@@ -288,10 +450,8 @@ void Intf_VLCWrapper::getNavCapabilities( bool* canSkipPrev,
                *canSkipPrev = false;
                *canSkipNext = false;
                // get playlist info
-               playlistLock();
-               int pos = p_playlist->i_index;
-               int size = p_playlist->i_size;
-               playlistUnlock();
+               int pos = PlaylistCurrent();
+               int size = PlaylistSize();
 
                // see if we have got a stream going            
                if ( p_input )
@@ -326,26 +486,24 @@ void Intf_VLCWrapper::getNavCapabilities( bool* canSkipPrev,
        }
 }
 
-void Intf_VLCWrapper::navigatePrev()
+void VlcWrapper::navigatePrev()
 {
-#if 0
        bool hasSkiped = false;
 
-       input_thread_t* input = p_input_bank->pp_input[0];
        // see if we have got a stream going            
-       if ( input )
+       if ( p_input )
        {
                // get information from stream (lock it while looking at it)
-               vlc_mutex_lock( &input->stream.stream_lock );
+               vlc_mutex_lock( &p_input->stream.stream_lock );
 
-               int currentTitle = input->stream.p_selected_area->i_id;
-               int currentChapter = input->stream.p_selected_area->i_part;
-               int numTitles = input->stream.i_area_nb;
+               int currentTitle = p_input->stream.p_selected_area->i_id;
+               int currentChapter = p_input->stream.p_selected_area->i_part;
+               int numTitles = p_input->stream.i_area_nb;
                bool hasTitles = numTitles > 1;
-               int numChapters = input->stream.p_selected_area->i_part_nb;
+               int numChapters = p_input->stream.p_selected_area->i_part_nb;
                bool hasChapters = numChapters > 1;
 
-               vlc_mutex_unlock( &input->stream.stream_lock );
+               vlc_mutex_unlock( &p_input->stream.stream_lock );
 
                // first, look for chapters
                if ( hasChapters )
@@ -375,30 +533,27 @@ void Intf_VLCWrapper::navigatePrev()
        }
        // last but not least, skip to previous file
        if ( !hasSkiped )
-               playlistPrev();
-#endif
+               PlaylistPrev();
 }
 
-void Intf_VLCWrapper::navigateNext()
+void VlcWrapper::navigateNext()
 {
-#if 0
        bool hasSkiped = false;
 
-       input_thread_t* input = p_input_bank->pp_input[0];
        // see if we have got a stream going            
-       if ( input )
+       if ( p_input )
        {
                // get information from stream (lock it while looking at it)
-               vlc_mutex_lock( &input->stream.stream_lock );
+               vlc_mutex_lock( &p_input->stream.stream_lock );
 
-               int currentTitle = input->stream.p_selected_area->i_id;
-               int currentChapter = input->stream.p_selected_area->i_part;
-               int numTitles = input->stream.i_area_nb;
+               int currentTitle = p_input->stream.p_selected_area->i_id;
+               int currentChapter = p_input->stream.p_selected_area->i_part;
+               int numTitles = p_input->stream.i_area_nb;
                bool hasTitles = numTitles > 1;
-               int numChapters = input->stream.p_selected_area->i_part_nb;
+               int numChapters = p_input->stream.p_selected_area->i_part_nb;
                bool hasChapters = numChapters > 1;
 
-               vlc_mutex_unlock( &input->stream.stream_lock );
+               vlc_mutex_unlock( &p_input->stream.stream_lock );
 
                // first, look for chapters
                if ( hasChapters )
@@ -427,97 +582,15 @@ void Intf_VLCWrapper::navigateNext()
        }
        // last but not least, skip to next file
        if ( !hasSkiped )
-               playlistNext();
-#endif
-}
-
-
-//void Intf_VLCWrapper::channelNext()
-//{
-//    intf_thread_t * p_intf = p_main->p_intf;
-//
-//    p_intf->p_sys->i_channel++;
-//
-//    intf_WarnMsg( 3, "intf info: joining channel %d", p_intf->p_sys->i_channel );
-//
-//    vlc_mutex_lock( &p_intf->change_lock );
-//
-//    network_ChannelJoin( p_intf->p_sys->i_channel );
-//    p_intf->pf_manage( p_intf );
-//
-//    vlc_mutex_unlock( &p_intf->change_lock );
-//}
-//
-//void Intf_VLCWrapper::channelPrev()
-//{
-//    intf_thread_t * p_intf = p_main->p_intf;
-//
-//    if ( p_intf->p_sys->i_channel )
-//    {
-//        p_intf->p_sys->i_channel--;
-//    }
-//
-//    intf_WarnMsg( 3, "intf info: joining channel %d", p_intf->p_sys->i_channel );
-//
-//    vlc_mutex_lock( &p_intf->change_lock );
-//
-//    network_ChannelJoin( p_intf->p_sys->i_channel );
-//    p_intf->pf_manage( p_intf );
-//
-//    vlc_mutex_unlock( &p_intf->change_lock );
-//
-//}
-
-void Intf_VLCWrapper::loop()
-{
-    if ( p_intf->p_sys->b_loop )
-    {
-        playlist_Delete( p_playlist, p_playlist->i_size - 1 );
-    }
-    else
-    {
-        playlist_Add( p_playlist, "vlc:loop",
-                      PLAYLIST_APPEND | PLAYLIST_GO,
-                      PLAYLIST_END );
-    }
-    p_intf->p_sys->b_loop = !p_intf->p_sys->b_loop;
+               PlaylistNext();
 }
 
 
-    /* playback control */
-void Intf_VLCWrapper::playSlower()
-{
-    if( p_input != NULL )
-    {
-        input_SetStatus( p_input, INPUT_STATUS_SLOWER );
-    }
-    if( p_input->stream.control.i_rate == DEFAULT_RATE)
-    {
-        toggle_mute(  );
-    }
-    else
-    {
-        toggle_mute ( );
-    }
-}
-
-void Intf_VLCWrapper::playFaster()
-{
-    if( p_input != NULL )
-    {
-        input_SetStatus( p_input, INPUT_STATUS_FASTER );
-    }
-    if( p_input->stream.control.i_rate == DEFAULT_RATE)
-    {
-        toggle_mute(  );
-    }
-    else
-    {
-        toggle_mute ( );
-    }
-}
+/***************************
+ * audio infos and control *
+ ***************************/
 
-void Intf_VLCWrapper::volume_mute()
+void VlcWrapper::volume_mute()
 {
     if( p_aout != NULL )
     {
@@ -531,7 +604,7 @@ void Intf_VLCWrapper::volume_mute()
 
 }
 
-void Intf_VLCWrapper::volume_restore()
+void VlcWrapper::volume_restore()
 {
     if( p_aout != NULL )
     {
@@ -542,7 +615,7 @@ void Intf_VLCWrapper::volume_restore()
 
 }
 
-void Intf_VLCWrapper::set_volume(int value)
+void VlcWrapper::set_volume(int value)
 {
     if( p_aout != NULL )
     {
@@ -562,7 +635,7 @@ void Intf_VLCWrapper::set_volume(int value)
     }
 }
 
-void Intf_VLCWrapper::toggle_mute()
+void VlcWrapper::toggle_mute()
 {
     if( p_aout != NULL )
        {
@@ -577,7 +650,7 @@ void Intf_VLCWrapper::toggle_mute()
        }
 }
 
-bool Intf_VLCWrapper::is_muted()
+bool VlcWrapper::is_muted()
 {
        bool muted = true;
        
@@ -595,7 +668,7 @@ bool Intf_VLCWrapper::is_muted()
        return muted;
 }
 
-bool Intf_VLCWrapper::is_playing()
+bool VlcWrapper::is_playing()
 {
 
        bool playing = false;
@@ -620,7 +693,7 @@ bool Intf_VLCWrapper::is_playing()
 
 }
 
-void Intf_VLCWrapper::maxvolume()
+void VlcWrapper::maxvolume()
 {
     if( p_aout != NULL )
     {
@@ -635,96 +708,73 @@ void Intf_VLCWrapper::maxvolume()
     }
 }
 
-bool Intf_VLCWrapper::has_audio()
+bool VlcWrapper::has_audio()
 {
     return( p_aout != NULL );
 }
 
-    /* playback info */
-
-const char*  Intf_VLCWrapper::getTimeAsString()
+/*******
+ * DVD *
+ *******/
+bool VlcWrapper::HasTitles()
 {
-    static char psz_currenttime[ OFFSETTOTIME_MAX_SIZE ];
-        
-    if( p_input == NULL )
+    if( !p_input )
     {
-        return ("-:--:--");
-    }     
-   
-    input_OffsetToTime( p_input, 
-                        psz_currenttime, 
-                        p_input->stream.p_selected_area->i_tell );        
-
-    return(psz_currenttime);
+        return false;
+    }
+    return ( p_input->stream.i_area_nb > 1 );
 }
 
-float  Intf_VLCWrapper::getTimeAsFloat()
+void VlcWrapper::PrevTitle()
 {
-    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
+    int i_id;
+    i_id = p_input->stream.p_selected_area->i_id - 1;
+    if( i_id > 0 )
     {
-        f_time = 0.0;
+        toggleTitle(i_id);
     }
-    return( f_time );
 }
 
-void   Intf_VLCWrapper::setTimeAsFloat(float f_position)
+void VlcWrapper::NextTitle()
 {
-    if( p_input != NULL )
+    int i_id;
+    i_id = p_input->stream.p_selected_area->i_id + 1;
+    if( i_id < p_input->stream.i_area_nb )
     {
-        input_Seek( p_input, 
-                   (long long int)(p_input->stream.p_selected_area->i_size
-                       * f_position / SEEKSLIDER_RANGE ), 
-                   INPUT_SEEK_SET);
+        toggleTitle(i_id);
     }
 }
 
-/* bool   Intf_VLCWrapper::playlistPlaying()
-{ 
-    return( !p_intf->p_sys->p_playlist->b_stopped );
-} */
-
-BList  *Intf_VLCWrapper::playlistAsArray()
-{ 
-    int i;
-    BList* p_list = new BList(p_playlist->i_size);
-    
-    vlc_mutex_lock( &p_playlist->object_lock );
-
-    for( i = 0; i < p_playlist->i_size; i++ )
+bool VlcWrapper::HasChapters()
+{
+    if( !p_input )
     {
-        p_list->AddItem(new BString(p_playlist->pp_items[i]->psz_name));
+        return false;
     }
+    return ( p_input->stream.p_selected_area->i_part_nb > 1 );
+}
 
-    vlc_mutex_unlock( &p_playlist->object_lock );
-    return( p_list );
+void VlcWrapper::PrevChapter()
+{
+    int i_id;
+    i_id = p_input->stream.p_selected_area->i_part - 1;
+    if( i_id >= 0 )
+    {
+        toggleChapter(i_id);
+    }
 }
 
-// getPlaylistInfo
-void
-Intf_VLCWrapper::getPlaylistInfo( int32& currentIndex, int32& maxIndex )
+void VlcWrapper::NextChapter()
 {
-       currentIndex = -1;
-       maxIndex = -1;
-       if ( p_playlist )
-       {
-               maxIndex = p_playlist->i_size;
-               if ( maxIndex > 0 )
-                       currentIndex = p_playlist->i_index + 1;
-               else
-                       maxIndex = -1;
-       }
+    int i_id;
+    i_id = p_input->stream.p_selected_area->i_part + 1;
+    if( i_id >= 0 )
+    {
+        toggleChapter(i_id);
+    }
 }
 
-// getTitleInfo
-void  
-Intf_VLCWrapper::getTitleInfo( int32& currentIndex, int32& maxIndex )
+void VlcWrapper::TitleInfo( int32 &currentIndex, int32 &maxIndex )
 {
        currentIndex = -1;
        maxIndex = -1;
@@ -742,9 +792,7 @@ Intf_VLCWrapper::getTitleInfo( int32& currentIndex, int32& maxIndex )
        }
 }
 
-// getChapterInfo
-void
-Intf_VLCWrapper::getChapterInfo( int32& currentIndex, int32& maxIndex )
+void VlcWrapper::ChapterInfo( int32 &currentIndex, int32 &maxIndex )
 {
        currentIndex = -1;
        maxIndex = -1;
@@ -762,46 +810,7 @@ Intf_VLCWrapper::getChapterInfo( int32& currentIndex, int32& maxIndex )
        }
 }
 
-    /* open file/disc/network */
-void Intf_VLCWrapper::openFiles( BList* o_files, bool replace )
-{
-    BString *o_file;
-
-    while( ( o_file = (BString *)o_files->LastItem() ) )
-    {
-        o_files->RemoveItem(o_files->CountItems() - 1);
-        playlist_Add( p_playlist, o_file->String(),
-                  PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
-        delete o_file;
-    }
-}
-
-void Intf_VLCWrapper::openDisc(BString o_type, BString o_device, int i_title, int i_chapter)
-{
-    BString o_source("");
-    o_source << o_type << ":" << o_device ;
-
-    playlist_Add( p_playlist, o_source.String(),
-                  PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
-}
-
-void Intf_VLCWrapper::openNet(BString o_addr, int i_port)
-{
-}
-
-void Intf_VLCWrapper::openNetChannel(BString o_addr, int i_port)
-{
-}
-
-void Intf_VLCWrapper::openNetHTTP(BString o_addr)
-{
-}
-
-
-    /* menus management */
-void Intf_VLCWrapper::toggleProgram(int i_program){}
-
-void Intf_VLCWrapper::toggleTitle(int i_title)
+void VlcWrapper::toggleTitle(int i_title)
 {
     if( p_input != NULL )
     {
@@ -814,7 +823,7 @@ void Intf_VLCWrapper::toggleTitle(int i_title)
     }
 }
 
-void Intf_VLCWrapper::toggleChapter(int i_chapter)
+void VlcWrapper::toggleChapter(int i_chapter)
 {
     if( p_input != NULL )
     {
@@ -826,73 +835,3 @@ void Intf_VLCWrapper::toggleChapter(int i_chapter)
         vlc_mutex_unlock( &p_input->stream.stream_lock );
     }
 }
-
-void Intf_VLCWrapper::toggleLanguage(int i_language)
-{
-
-    int32 i_old = -1;
-    int i_cat = AUDIO_ES;
-
-    vlc_mutex_lock( &p_input->stream.stream_lock );
-    for( int i = 0; i < p_input->stream.i_selected_es_number ; i++ )
-    {
-        if( p_input->stream.pp_selected_es[i]->i_cat == i_cat )
-        {
-            i_old = i;
-            break;
-        }
-    }
-    vlc_mutex_unlock( &p_input->stream.stream_lock );
-
-    msg_Info( p_intf, "Old: %d,  New: %d", i_old, i_language);
-    if( i_language != -1 )
-    {
-        input_ToggleES( p_input, 
-                        p_input->stream.pp_selected_es[i_language],
-                        VLC_TRUE );
-    }
-
-    if( (i_old != -1) && (i_old != i_language) )
-    {
-        input_ToggleES( p_input, 
-                        p_input->stream.pp_selected_es[i_old],
-                        VLC_FALSE );
-    }
-}
-
-void Intf_VLCWrapper::toggleSubtitle(int i_subtitle)
-{
-    int32 i_old = -1;
-    int i_cat = SPU_ES;
-
-    vlc_mutex_lock( &p_input->stream.stream_lock );
-    for( int i = 0; i < p_input->stream.i_selected_es_number ; i++ )
-    {
-        if( p_input->stream.pp_selected_es[i]->i_cat == i_cat )
-        {
-            i_old = i;
-            break;
-        }
-    }
-    vlc_mutex_unlock( &p_input->stream.stream_lock );
-    
-    msg_Info( p_intf, "Old: %d,  New: %d", i_old, i_subtitle);
-    if( i_subtitle != -1 )
-    {
-        input_ToggleES( p_input, 
-                        p_input->stream.pp_selected_es[i_subtitle],
-                        VLC_TRUE );
-    }
-
-    if( (i_old != -1) && (i_old != i_subtitle) )
-    {
-        input_ToggleES( p_input, 
-                        p_input->stream.pp_selected_es[i_old],
-                        VLC_FALSE );
-    }
-}
-
-int  Intf_VLCWrapper::inputGetStatus()
-{
-    return p_playlist->i_status;
-}
index cbd5933e587e21a539765c62d4cbd865f9b62366..16d0f26f8aa1c401f556ee308587448011d13151 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
- * intf_vlc_wrapper.h: BeOS plugin for vlc (derived from MacOS X port )
+ * VlcWrapper.h: BeOS plugin for vlc (derived from MacOS X port)
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: VlcWrapper.h,v 1.7 2002/11/26 01:06:08 titer Exp $
+ * $Id: VlcWrapper.h,v 1.8 2002/11/27 05:36:41 titer Exp $
  *
  * Authors: Florian G. Pflug <fgp@phlo.org>
  *          Jon Lech Johansen <jon-vl@nanocrew.net>
@@ -28,7 +28,7 @@
 #define SEEKSLIDER_RANGE 2048
 
 class InterfaceWindow;
-class Intf_VLCWrapper;
+class VlcWrapper;
 
 /*****************************************************************************
  * intf_sys_t: internal variables of the BeOS interface
@@ -37,7 +37,6 @@ struct intf_sys_t
 {
     InterfaceWindow * p_window;
     
-    /* DVD mode */
     vlc_bool_t        b_disabled_menus;
     vlc_bool_t        b_loop;
     vlc_bool_t        b_mute;
@@ -45,76 +44,65 @@ struct intf_sys_t
     int               i_saved_volume;
     int               i_channel;
     
-    Intf_VLCWrapper * p_wrapper;
+    VlcWrapper * p_wrapper;
 };
 
 /*****************************************************************************
- * Intf_VLCWrapper
+ * VlcWrapper
  *****************************************************************************
  * This class makes the link between the BeOS interface and the vlc core.
- * There is only one Intf_VLCWrapper instance at any time, which is stored
+ * There is only one VlcWrapper instance at any time, which is stored
  * in p_intf->p_sys->p_wrapper
  *****************************************************************************/
-class Intf_VLCWrapper
+class VlcWrapper
 {
 public:
-    Intf_VLCWrapper( intf_thread_t *p_intf );
-    ~Intf_VLCWrapper();
+    VlcWrapper( intf_thread_t *p_intf );
+    ~VlcWrapper();
     
     bool UpdateInputAndAOut();
     
-    int inputGetStatus();
+    /* input */
     int InputStatus();
     int InputRate();
     int InputTell();
     int InputSize();
-    void inputSeek();
-    
-    /* playlist control */
+    void InputSlower();
+    void InputFaster();
+    void openFiles( BList *o_files, bool replace = true );
+    void openDisc( BString o_type, BString o_device,
+                   int i_title, int i_chapter );
+    void toggleLanguage( int i_language );
+    void toggleSubtitle( int i_subtitle );
+    const char* getTimeAsString();
+    float getTimeAsFloat();
+    void setTimeAsFloat( float i_offset );
+
+        
+    /* Playlist */
     int PlaylistSize();
     char *PlaylistItemName( int );
     int PlaylistCurrent();
-    
-    bool playlistPlay();
-    void playlistPause();
-    void playlistStop();
-    void playlistNext();
-    void playlistPrev();
-    void playlistJumpTo( int );
-    int  playlistSize();
-    int  playlistCurrentPos();
-    void playlistLock();
-    void playlistUnlock();
-    void playlistSkip(int i);
-    void playlistGoto(int i);
-    void loop(); 
-
-    bool playlistPlaying();
-    BList* playlistAsArray();
-    void   getPlaylistInfo( int32& currentIndex,
+    int PlaylistStatus();
+    bool PlaylistPlay();
+    void PlaylistPause();
+    void PlaylistStop();
+    void PlaylistNext();
+    void PlaylistPrev();
+    void PlaylistSkip(int i);
+    void PlaylistGoto(int i);
+    void PlaylistLoop(); 
+    BList* PlaylistAsArray();
+    bool PlaylistPlaying();
+    void getPlaylistInfo( int32& currentIndex,
                             int32& maxIndex );
-    void   getTitleInfo( int32& currentIndex,
-                         int32& maxIndex );
-    void   getChapterInfo( int32& currentIndex,
-                           int32& maxIndex );
+    void PlaylistJumpTo( int );
     void getNavCapabilities( bool* canSkipPrev,
                              bool* canSkipNext );
        void navigatePrev();
        void navigateNext();
 
-    /* DVD */
-    bool HasTitles();
-    void PrevTitle();
-    void NextTitle();
-    bool HasChapters();
-    void PrevChapter();
-    void NextChapter();
-
-    /*  Stream Control */
-    void playSlower();
-    void playFaster();
-    
-    /* playback control */
+    /* audio */
     void volume_mute();
     void volume_restore();
     void set_volume(int value);
@@ -123,29 +111,19 @@ public:
     bool is_playing();
     void maxvolume();
     bool has_audio();
-    
-    /* playback info */
-    const char* getTimeAsString();
-    float  getTimeAsFloat();
-    void   setTimeAsFloat( float i_offset );
 
-    /* open file/disc/network */
-    void openFiles( BList *o_files, bool replace = true );
-    void openDisc( BString o_type, BString o_device,
-                   int i_title, int i_chapter );
-    void openNet( BString o_addr, int i_port );
-    void openNetChannel( BString o_addr, int i_port );
-    void openNetHTTP( BString o_addr );
-
-    /* menus management */
-    void toggleProgram( int i_program );
+    /* DVD */
+    bool HasTitles();
+    void PrevTitle();
+    void NextTitle();
+    bool HasChapters();
+    void PrevChapter();
+    void NextChapter();
+    void TitleInfo( int32& currentIndex, int32& maxIndex );
+    void ChapterInfo( int32& currentIndex, int32& maxIndex );
     void toggleTitle( int i_title );
     void toggleChapter( int i_chapter );
-    void toggleLanguage( int i_language );
-    void toggleSubtitle( int i_subtitle );
-    void channelNext();
-    void channelPrev();
-
+    
 private:
     intf_thread_t * p_intf;
     input_thread_t * p_input;