X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fbeos%2FVlcWrapper.cpp;h=f4304e4bcd345d67c9eeee0ef78ab07b3bb0314a;hb=d79a68397146126b899966f9e7816e063ec270c1;hp=73115e6935ba71343b31339e900a8204548b77b4;hpb=d9ddadd06b6caeea58d2e26a2ad5d56289a16d6f;p=vlc diff --git a/modules/gui/beos/VlcWrapper.cpp b/modules/gui/beos/VlcWrapper.cpp index 73115e6935..f4304e4bcd 100644 --- a/modules/gui/beos/VlcWrapper.cpp +++ b/modules/gui/beos/VlcWrapper.cpp @@ -2,7 +2,7 @@ * VlcWrapper.cpp: BeOS plugin for vlc (derived from MacOS X port) ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: VlcWrapper.cpp,v 1.27 2003/04/22 16:36:16 titer Exp $ + * $Id: VlcWrapper.cpp,v 1.42 2004/01/17 12:28:57 gbazin Exp $ * * Authors: Florian G. Pflug * Jon Lech Johansen @@ -33,7 +33,7 @@ #include extern "C" { - #include // needed here when compiling without plugins + #include // needed here when compiling without plugins #include #include } @@ -43,9 +43,10 @@ extern "C" const char * _AddEllipsis( char * string ) { - BString newString( string ); - newString << B_UTF8_ELLIPSIS; - return newString.String(); + char * temp; + temp = (char*) calloc( strlen( string ) + 4, 1 ); + sprintf( temp, "%s%s", string, B_UTF8_ELLIPSIS ); + return temp; } /* constructor */ @@ -61,35 +62,25 @@ VlcWrapper::VlcWrapper( intf_thread_t *p_interface ) VlcWrapper::~VlcWrapper() { if( p_input ) - { vlc_object_release( p_input ); - } + if( p_playlist ) - { vlc_object_release( p_playlist ); - } } -/* UpdateInput: updates p_input, returns true if the interface needs to - be updated */ -bool VlcWrapper::UpdateInput() +/* UpdateInput: updates p_input */ +void VlcWrapper::UpdateInput() { - if( p_input == NULL ) - { + if( !p_input ) p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); - } - if( p_input != NULL ) - { + if( p_input ) if( p_input->b_dead ) { vlc_object_release( p_input ); p_input = NULL; } - return true; - } - return false; } @@ -108,7 +99,10 @@ int VlcWrapper::InputStatus() { 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() @@ -117,23 +111,18 @@ int VlcWrapper::InputRate() { return DEFAULT_RATE; } + return p_input->stream.control.i_rate; } -void VlcWrapper::InputSlower() +void VlcWrapper::InputSetRate( int rate ) { - if( p_input != NULL ) + if( !p_input ) { - input_SetStatus( p_input, INPUT_STATUS_SLOWER ); + return; } -} -void VlcWrapper::InputFaster() -{ - if( p_input != NULL ) - { - input_SetStatus( p_input, INPUT_STATUS_FASTER ); - } + input_SetRate( p_input, rate ); } BList * VlcWrapper::GetChannels( int i_cat ) @@ -192,10 +181,11 @@ BList * VlcWrapper::GetChannels( int i_cat ) { message = new BMessage( what ); message->AddInt32( fieldName, i ); - if( strlen( p_input->stream.pp_es[i]->psz_desc ) ) - trackName = strdup( p_input->stream.pp_es[i]->psz_desc ); - else + if( !p_input->stream.pp_es[i]->psz_desc || + !*p_input->stream.pp_es[i]->psz_desc ) trackName = _(""); + else + trackName = strdup( p_input->stream.pp_es[i]->psz_desc ); menuItem = new BMenuItem( trackName, message ); if( p_input->stream.pp_es[i] == p_es ) menuItem->SetMarked( true ); @@ -280,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 int)(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; } @@ -376,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 ); + o_file->String(), mode, index ); if ( mode == PLAYLIST_INSERT ) index++; delete o_file; @@ -395,11 +384,11 @@ void VlcWrapper::OpenFiles( BList* o_files, bool replace, int32 index ) void VlcWrapper::OpenDisc(BString o_type, BString o_device, int i_title, int i_chapter) { - if( p_intf->p_sys->b_dvdmenus ) - o_device.Prepend( "dvd:" ); + if( config_GetInt( p_intf, "beos-dvdmenus" ) ) + o_device.Prepend( "dvdplay:" ); else o_device.Prepend( "dvdold:" ); - playlist_Add( p_playlist, o_device.String(), + playlist_Add( p_playlist, o_device.String(), o_device.String(), PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END ); } @@ -717,11 +706,9 @@ VlcWrapper::PlaylistCloneItem( void* castToItem ) const if ( copy ) { // make a copy of the item at index + *copy = *item; copy->psz_name = strdup( item->psz_name ); copy->psz_uri = strdup( item->psz_uri ); - copy->i_type = item->i_type; - copy->i_status = item->i_status; - copy->b_autodeletion = item->b_autodeletion; } } return (void*)copy; @@ -767,14 +754,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; } @@ -787,12 +774,34 @@ bool VlcWrapper::IsMuted() * DVD * *******/ -bool VlcWrapper::HasTitles() +bool VlcWrapper::IsUsingMenus() { if( !p_input ) + return false; + + 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; +} + +bool VlcWrapper::HasTitles() +{ + if( !p_input ) + return false; + return ( p_input->stream.i_area_nb > 1 ); } @@ -994,7 +1003,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] );