Commit 3b078b7b authored by Eric Petit's avatar Eric Petit

* AudioOutput.cpp: fixed a segfault

 * ALL: cleaned the VlcWrapper class, removed unused code
parent c19c673b
/*****************************************************************************
* 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 );
}
}
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
......@@ -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;
......
......@@ -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
......
/*****************************************************************************
* 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",