Commit 2d8e1a61 authored by Eric Petit's avatar Eric Petit
Browse files

Fixed language and subtitle selection.

parent 5361fc7d
......@@ -2,7 +2,7 @@
* InterfaceWindow.cpp: beos interface
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: InterfaceWindow.cpp,v 1.12 2002/12/09 07:57:04 titer Exp $
* $Id: InterfaceWindow.cpp,v 1.13 2003/01/08 02:09:15 titer Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -135,8 +135,8 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char *name,
fileMenu->AddItem( item );
fileMenu->AddItem( new BMenuItem( "Quit", new BMessage( B_QUIT_REQUESTED ), 'Q') );
fLanguageMenu = new LanguageMenu("Language", AUDIO_ES, p_intf);
fSubtitlesMenu = new LanguageMenu("Subtitles", SPU_ES, p_intf);
fLanguageMenu = new LanguageMenu("Language", AUDIO_ES, p_wrapper);
fSubtitlesMenu = new LanguageMenu("Subtitles", SPU_ES, p_wrapper);
/* Add the Audio menu */
fAudioMenu = new BMenu( "Audio" );
......@@ -346,7 +346,7 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
int32 channel;
if ( p_message->FindInt32( "channel", &channel ) == B_OK )
{
p_wrapper->toggleLanguage( channel );
p_wrapper->ToggleLanguage( channel );
}
}
break;
......@@ -356,7 +356,7 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
{
int32 subtitle;
if ( p_message->FindInt32( "subtitle", &subtitle ) == B_OK )
p_wrapper->toggleSubtitle( subtitle );
p_wrapper->ToggleSubtitle( subtitle );
}
break;
......@@ -473,7 +473,7 @@ bool InterfaceWindow::QuitRequested()
*****************************************************************************/
void InterfaceWindow::updateInterface()
{
if( /* has_input */ true )
if( p_wrapper->HasInput() )
{
if ( acquire_sem( p_mediaControl->fScrubSem ) == B_OK )
{
......@@ -523,6 +523,13 @@ void InterfaceWindow::updateInterface()
Unlock();
}
/* always force the user-specified volume */
/* FIXME : I'm quite sure there is a cleaner way to do this */
if( p_wrapper->GetVolume() != p_mediaControl->GetVolume() )
{
p_wrapper->SetVolume( p_mediaControl->GetVolume() );
}
fLastUpdateTime = system_time();
}
......@@ -890,12 +897,12 @@ int CDMenu::GetCD( const char *directory )
/*****************************************************************************
* LanguageMenu::LanguageMenu
*****************************************************************************/
LanguageMenu::LanguageMenu(const char *name, int menu_kind,
intf_thread_t *p_interface)
LanguageMenu::LanguageMenu( const char *name, int menu_kind,
VlcWrapper *p_wrapper )
:BMenu(name)
{
kind = menu_kind;
p_intf = p_interface;
this->p_wrapper = p_wrapper;
}
/*****************************************************************************
......@@ -924,84 +931,23 @@ void LanguageMenu::AttachedToWindow()
*****************************************************************************/
void LanguageMenu::_GetChannels()
{
#if 0 // must be ported to 0.5.0
char *psz_name;
bool b_active;
BMessage *msg;
BMenuItem *menu_item;
int i;
es_descriptor_t *p_es = NULL;
// Insert the "None" item if in subtitle mode
if( kind != AUDIO_ES ) //subtitle
{
msg = new BMessage( SELECT_SUBTITLE );
msg->AddInt32( "subtitle", -1 );
menu_item = new BMenuItem( "None", msg );
AddItem( menu_item );
menu_item->SetMarked( true );
}
input_thread_t* input = p_intf->p_sys->p_input;
if ( input )
{
vlc_mutex_lock( &input->stream.stream_lock );
for( i = 0; i < input->stream.i_selected_es_number; i++ )
{
if( kind == input->stream.pp_selected_es[i]->i_cat )
p_es = input->stream.pp_selected_es[i];
}
int32 addedItems = 0;
bool emptyItemAdded = false;
uint32 what = kind == AUDIO_ES ? SELECT_CHANNEL : SELECT_SUBTITLE;
const char* fieldName = kind == AUDIO_ES ? "channel" : "subtitle";
for ( i = 0; i < input->stream.i_es_number; i++ )
{
if ( kind == input->stream.pp_es[i]->i_cat )
{
bool addItem = true;
psz_name = input->stream.pp_es[i]->psz_desc;
// workarround for irritating empty strings
if ( strcmp(psz_name, "") == 0 )
{
// if ( kind != AUDIO_ES ) // don't add empty subtitle items, they don't work anyways
// addItem = false;
// else
// {
if (!emptyItemAdded)
{
psz_name = "<default>";
emptyItemAdded = true;
}
else
psz_name = "<unkown>";
// }
}
if ( addItem )
{
addedItems++;
msg = new BMessage( what );
msg->AddInt32( fieldName, i );
menu_item = new BMenuItem( psz_name, msg );
AddItem( menu_item );
b_active = ( p_es == input->stream.pp_es[i] );
menu_item->SetMarked( b_active );
}
}
}
vlc_mutex_unlock( &input->stream.stream_lock );
// enhance readability and separate first item from rest
if ( ( emptyItemAdded || kind != AUDIO_ES ) && addedItems > 1 )
AddItem( new BSeparatorItem(), 1 );
}
#endif
BMenuItem *item;
BList *list;
if( ( list = p_wrapper->InputGetChannels( kind ) ) == NULL )
return;
for( int i = 0; i < list->CountItems(); i++ )
{
item = (BMenuItem*)list->ItemAt( i );
AddItem( item );
}
if( list->CountItems() > 1 )
AddItem( new BSeparatorItem(), 1 );
}
/*****************************************************************************
* TitleMenu::TitleMenu
*****************************************************************************/
......
......@@ -2,7 +2,7 @@
* InterfaceWindow.h: BeOS interface window class prototype
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: InterfaceWindow.h,v 1.6 2002/11/27 05:36:41 titer Exp $
* $Id: InterfaceWindow.h,v 1.7 2003/01/08 02:09:15 titer Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Tony Castley <tcastley@mail.powerup.com.au>
......@@ -53,7 +53,7 @@ class LanguageMenu : public BMenu
public:
LanguageMenu( const char* name,
int menu_kind,
intf_thread_t* p_interface );
VlcWrapper *p_wrapper );
virtual ~LanguageMenu();
virtual void AttachedToWindow();
......@@ -61,7 +61,7 @@ class LanguageMenu : public BMenu
private:
void _GetChannels();
intf_thread_t* p_intf;
VlcWrapper * p_wrapper;
int kind;
};
......
......@@ -2,7 +2,7 @@
* VlcWrapper.cpp: BeOS plugin for vlc (derived from MacOS X port)
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: VlcWrapper.cpp,v 1.14 2002/12/26 18:17:38 stippi Exp $
* $Id: VlcWrapper.cpp,v 1.15 2003/01/08 02:09:15 titer Exp $
*
* Authors: Florian G. Pflug <fgp@phlo.org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -24,6 +24,8 @@
* along with this program{} if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include <AppKit.h>
#include <InterfaceKit.h>
#include <SupportKit.h>
#include <vlc/vlc.h>
......@@ -34,6 +36,7 @@ extern "C" {
}
#include "VlcWrapper.h"
#include "MsgVals.h"
/* constructor */
VlcWrapper::VlcWrapper( intf_thread_t *p_interface )
......@@ -100,6 +103,11 @@ bool VlcWrapper::UpdateInputAndAOut()
* input infos and control *
***************************/
bool VlcWrapper::HasInput()
{
return( p_input != NULL );
}
/* status (UNDEF_S, PLAYING_S, PAUSE_S, FORWARD_S, BACKWARD_S,
REWIND_S, NOT_STARTED_S, START_S) */
int VlcWrapper::InputStatus()
......@@ -146,7 +154,6 @@ void VlcWrapper::InputSlower()
{
input_SetStatus( p_input, INPUT_STATUS_SLOWER );
}
//VolumeMute();
}
void VlcWrapper::InputFaster()
......@@ -155,7 +162,80 @@ void VlcWrapper::InputFaster()
{
input_SetStatus( p_input, INPUT_STATUS_FASTER );
}
//VolumeMute();
}
BList * VlcWrapper::InputGetChannels( int i_cat )
{
if( p_input )
{
unsigned int i;
uint32 what;
const char* fieldName;
switch( i_cat )
{
case AUDIO_ES:
{
what = SELECT_CHANNEL;
fieldName = "channel";
break;
}
case SPU_ES:
{
what = SELECT_SUBTITLE;
fieldName = "subtitle";
break;
}
default:
return NULL;
}
vlc_mutex_lock( &p_input->stream.stream_lock );
/* find which track is currently playing */
es_descriptor_t *p_es = NULL;
for( i = 0; i < p_input->stream.i_selected_es_number; i++ )
{
if( p_input->stream.pp_selected_es[i]->i_cat == i_cat )
p_es = p_input->stream.pp_selected_es[i];
}
/* build a list of all tracks */
BList *list = new BList( p_input->stream.i_es_number );
BMenuItem *menuItem;
BMessage *message;
char *trackName;
/* "None" */
message = new BMessage( what );
message->AddInt32( fieldName, -1 );
menuItem = new BMenuItem( "None", message );
if( !p_es )
menuItem->SetMarked( true );
list->AddItem( menuItem );
for( i = 0; i < p_input->stream.i_es_number; i++ )
{
if( p_input->stream.pp_es[i]->i_cat == 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
trackName = "<unknown>";
menuItem = new BMenuItem( trackName, message );
if( p_input->stream.pp_es[i] == p_es )
menuItem->SetMarked( true );
list->AddItem( menuItem );
}
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
return list;
}
return NULL;
}
void VlcWrapper::openFiles( BList* o_files, bool replace )
......@@ -182,68 +262,71 @@ void VlcWrapper::openDisc(BString o_type, BString o_device, int i_title, int i_c
void VlcWrapper::toggleLanguage(int i_language)
void VlcWrapper::ToggleLanguage( int i_language )
{
int32 i_old = -1;
int i_cat = AUDIO_ES;
es_descriptor_t * p_es = NULL;
es_descriptor_t * p_es_old = NULL;
vlc_mutex_lock( &p_input->stream.stream_lock );
for( unsigned int i = 0; i < p_input->stream.i_selected_es_number ; i++ )
{
if( p_input->stream.pp_selected_es[i]->i_cat == i_cat )
if( p_input->stream.pp_selected_es[i]->i_cat == AUDIO_ES )
{
i_old = i;
p_es_old = p_input->stream.pp_selected_es[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 );
p_es = p_input->stream.pp_es[i_language];
}
if( (i_old != -1) && (i_old != i_language) )
if( p_es == p_es_old )
{
return;
}
if( p_es_old )
{
input_ToggleES( p_input, p_es_old, VLC_FALSE );
}
if( p_es )
{
input_ToggleES( p_input,
p_input->stream.pp_selected_es[i_old],
VLC_FALSE );
input_ToggleES( p_input, p_es, VLC_TRUE );
}
}
void VlcWrapper::toggleSubtitle(int i_subtitle)
void VlcWrapper::ToggleSubtitle( int i_subtitle )
{
int32 i_old = -1;
int i_cat = SPU_ES;
es_descriptor_t * p_es = NULL;
es_descriptor_t * p_es_old = NULL;
vlc_mutex_lock( &p_input->stream.stream_lock );
for( unsigned int i = 0; i < p_input->stream.i_selected_es_number ; i++ )
{
if( p_input->stream.pp_selected_es[i]->i_cat == i_cat )
if( p_input->stream.pp_selected_es[i]->i_cat == SPU_ES )
{
i_old = i;
p_es_old = p_input->stream.pp_selected_es[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 );
p_es = p_input->stream.pp_es[i_subtitle];
}
if( (i_old != -1) && (i_old != i_subtitle) )
if( p_es == p_es_old )
{
return;
}
if( p_es_old )
{
input_ToggleES( p_input, p_es_old, VLC_FALSE );
}
if( p_es )
{
input_ToggleES( p_input,
p_input->stream.pp_selected_es[i_old],
VLC_FALSE );
input_ToggleES( p_input, p_es, VLC_TRUE );
}
}
......@@ -346,7 +429,6 @@ bool VlcWrapper::PlaylistPlay()
if( PlaylistSize() )
{
playlist_Play( p_playlist );
//VolumeRestore();
}
return( true );
}
......@@ -601,6 +683,17 @@ void VlcWrapper::navigateNext()
* audio infos and control *
***************************/
unsigned short VlcWrapper::GetVolume()
{
if( p_aout != NULL )
{
unsigned short i_volume;
aout_VolumeGet( p_aout, (audio_volume_t*)&i_volume );
return i_volume;
}
return 0;
}
void VlcWrapper::SetVolume(int value)
{
if( p_aout != NULL )
......
......@@ -2,7 +2,7 @@
* VlcWrapper.h: BeOS plugin for vlc (derived from MacOS X port)
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: VlcWrapper.h,v 1.10 2002/12/09 13:37:38 titer Exp $
* $Id: VlcWrapper.h,v 1.11 2003/01/08 02:09:15 titer Exp $
*
* Authors: Florian G. Pflug <fgp@phlo.org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -62,17 +62,19 @@ public:
bool UpdateInputAndAOut();
/* input */
bool HasInput();
int InputStatus();
int InputRate();
int InputTell();
int InputSize();
void InputSlower();
void InputFaster();
BList * InputGetChannels( int i_cat );
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 );
void ToggleLanguage( int i_language );
void ToggleSubtitle( int i_subtitle );
const char* getTimeAsString();
float getTimeAsFloat();
void setTimeAsFloat( float i_offset );
......@@ -102,6 +104,7 @@ public:
void navigateNext();
/* audio */
unsigned short GetVolume();
void SetVolume( int value );
void VolumeMute();
void VolumeRestore();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment