Changeset 2d8e1a61809e9fc5be3294f9811aa99786ab9c18

Show
Ignore:
Timestamp:
08/01/03 03:09:15 (6 years ago)
Author:
Eric Petit <titer@videolan.org>
git-committer:
Eric Petit <titer@videolan.org> 1041991755 +0000
git-parent:

[5361fc7d3e9c3430c42dcb8a3bc49f158f565796]

git-author:
Eric Petit <titer@videolan.org> 1041991755 +0000
Message:

Fixed language and subtitle selection.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/gui/beos/InterfaceWindow.cpp

    r29b488f r2d8e1a6  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999, 2000, 2001 VideoLAN 
    5  * $Id: InterfaceWindow.cpp,v 1.12 2002/12/09 07:57:04 titer Exp $ 
     5 * $Id: InterfaceWindow.cpp,v 1.13 2003/01/08 02:09:15 titer Exp $ 
    66 * 
    77 * Authors: Jean-Marc Dressler <polux@via.ecp.fr> 
     
    136136    fileMenu->AddItem( new BMenuItem( "Quit", new BMessage( B_QUIT_REQUESTED ), 'Q') ); 
    137137 
    138     fLanguageMenu = new LanguageMenu("Language", AUDIO_ES, p_intf); 
    139     fSubtitlesMenu = new LanguageMenu("Subtitles", SPU_ES, p_intf); 
     138    fLanguageMenu = new LanguageMenu("Language", AUDIO_ES, p_wrapper); 
     139    fSubtitlesMenu = new LanguageMenu("Subtitles", SPU_ES, p_wrapper); 
    140140 
    141141    /* Add the Audio menu */ 
     
    347347                if ( p_message->FindInt32( "channel", &channel ) == B_OK ) 
    348348                { 
    349                     p_wrapper->toggleLanguage( channel ); 
     349                    p_wrapper->ToggleLanguage( channel ); 
    350350                } 
    351351            } 
     
    357357                int32 subtitle; 
    358358                if ( p_message->FindInt32( "subtitle", &subtitle ) == B_OK ) 
    359                      p_wrapper->toggleSubtitle( subtitle ); 
     359                     p_wrapper->ToggleSubtitle( subtitle ); 
    360360            } 
    361361            break; 
     
    474474void InterfaceWindow::updateInterface() 
    475475{ 
    476     if( /* has_input */ true
     476    if( p_wrapper->HasInput()
    477477    { 
    478478        if ( acquire_sem( p_mediaControl->fScrubSem ) == B_OK ) 
     
    523523        Unlock(); 
    524524    } 
     525 
     526    /* always force the user-specified volume */ 
     527    /* FIXME : I'm quite sure there is a cleaner way to do this */ 
     528    if( p_wrapper->GetVolume() != p_mediaControl->GetVolume() ) 
     529    { 
     530        p_wrapper->SetVolume( p_mediaControl->GetVolume() ); 
     531    } 
    525532 
    526533    fLastUpdateTime = system_time(); 
     
    891898 * LanguageMenu::LanguageMenu 
    892899 *****************************************************************************/ 
    893 LanguageMenu::LanguageMenu(const char *name, int menu_kind,  
    894                             intf_thread_t  *p_interface
     900LanguageMenu::LanguageMenu( const char *name, int menu_kind,  
     901                            VlcWrapper *p_wrapper
    895902    :BMenu(name) 
    896903{ 
    897904    kind = menu_kind; 
    898     p_intf = p_interface
     905    this->p_wrapper = p_wrapper
    899906} 
    900907 
     
    925932void LanguageMenu::_GetChannels() 
    926933{ 
    927 #if 0 // must be ported to 0.5.0 
    928     char  *psz_name; 
    929     bool   b_active; 
    930     BMessage *msg; 
    931     BMenuItem *menu_item; 
    932     int i; 
    933     es_descriptor_t *p_es  = NULL; 
    934  
    935     // Insert the "None" item if in subtitle mode 
    936     if( kind != AUDIO_ES ) //subtitle 
    937     { 
    938         msg = new BMessage( SELECT_SUBTITLE ); 
    939         msg->AddInt32( "subtitle", -1 ); 
    940         menu_item = new BMenuItem( "None", msg ); 
    941         AddItem( menu_item ); 
    942         menu_item->SetMarked( true ); 
    943     } 
    944  
    945     input_thread_t* input = p_intf->p_sys->p_input; 
    946     if ( input ) 
    947     { 
    948         vlc_mutex_lock( &input->stream.stream_lock ); 
    949         for( i = 0; i < input->stream.i_selected_es_number; i++ ) 
    950         { 
    951             if( kind == input->stream.pp_selected_es[i]->i_cat ) 
    952                 p_es = input->stream.pp_selected_es[i]; 
    953         } 
    954      
    955         int32 addedItems = 0; 
    956         bool emptyItemAdded = false; 
    957         uint32 what = kind == AUDIO_ES ? SELECT_CHANNEL : SELECT_SUBTITLE; 
    958         const char* fieldName = kind == AUDIO_ES ? "channel" : "subtitle"; 
    959      
    960         for ( i = 0; i < input->stream.i_es_number; i++ ) 
    961         { 
    962             if ( kind == input->stream.pp_es[i]->i_cat ) 
    963             { 
    964                 bool addItem = true; 
    965                 psz_name = input->stream.pp_es[i]->psz_desc; 
    966                 // workarround for irritating empty strings 
    967                 if ( strcmp(psz_name, "") == 0 ) 
    968                 { 
    969 //                  if ( kind != AUDIO_ES ) // don't add empty subtitle items, they don't work anyways 
    970 //                      addItem = false; 
    971 //                  else 
    972 //                  { 
    973                         if (!emptyItemAdded) 
    974                         { 
    975                             psz_name = "<default>"; 
    976                             emptyItemAdded = true; 
    977                         } 
    978                         else 
    979                             psz_name = "<unkown>"; 
    980 //                  } 
    981                 } 
    982                 if ( addItem ) 
    983                 { 
    984                     addedItems++; 
    985                     msg = new BMessage( what ); 
    986                     msg->AddInt32( fieldName, i ); 
    987                     menu_item = new BMenuItem( psz_name, msg ); 
    988                     AddItem( menu_item ); 
    989                     b_active = ( p_es == input->stream.pp_es[i] ); 
    990                     menu_item->SetMarked( b_active ); 
    991                 } 
    992             } 
    993         } 
    994         vlc_mutex_unlock( &input->stream.stream_lock ); 
    995      
    996         // enhance readability and separate first item from rest 
    997         if ( ( emptyItemAdded || kind != AUDIO_ES ) && addedItems > 1 ) 
    998              AddItem( new BSeparatorItem(), 1 ); 
    999     } 
    1000 #endif 
    1001 
    1002  
     934    BMenuItem *item; 
     935    BList *list; 
     936     
     937    if( ( list = p_wrapper->InputGetChannels( kind ) ) == NULL ) 
     938        return; 
     939     
     940    for( int i = 0; i < list->CountItems(); i++ ) 
     941    { 
     942        item = (BMenuItem*)list->ItemAt( i ); 
     943        AddItem( item ); 
     944    } 
     945     
     946    if( list->CountItems() > 1 ) 
     947        AddItem( new BSeparatorItem(), 1 ); 
     948
    1003949 
    1004950 
  • modules/gui/beos/InterfaceWindow.h

    r3b078b7 r2d8e1a6  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999, 2000, 2001 VideoLAN 
    5  * $Id: InterfaceWindow.h,v 1.6 2002/11/27 05:36:41 titer Exp $ 
     5 * $Id: InterfaceWindow.h,v 1.7 2003/01/08 02:09:15 titer Exp $ 
    66 * 
    77 * Authors: Jean-Marc Dressler <polux@via.ecp.fr> 
     
    5454                            LanguageMenu( const char* name, 
    5555                                          int menu_kind, 
    56                                           intf_thread_t* p_interface ); 
     56                                          VlcWrapper *p_wrapper ); 
    5757    virtual                 ~LanguageMenu(); 
    5858 
     
    6262            void            _GetChannels(); 
    6363 
    64     intf_thread_t*         p_intf
     64    VlcWrapper *            p_wrapper
    6565    int                     kind; 
    6666}; 
  • modules/gui/beos/VlcWrapper.cpp

    re00996a r2d8e1a6  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: VlcWrapper.cpp,v 1.14 2002/12/26 18:17:38 stippi Exp $ 
     5 * $Id: VlcWrapper.cpp,v 1.15 2003/01/08 02:09:15 titer Exp $ 
    66 * 
    77 * Authors: Florian G. Pflug <fgp@phlo.org> 
     
    2525 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. 
    2626 *****************************************************************************/ 
     27#include <AppKit.h> 
     28#include <InterfaceKit.h> 
    2729#include <SupportKit.h> 
    2830 
     
    3537 
    3638#include "VlcWrapper.h" 
     39#include "MsgVals.h" 
    3740 
    3841/* constructor */ 
     
    101104 ***************************/ 
    102105 
     106bool VlcWrapper::HasInput() 
     107{ 
     108    return( p_input != NULL ); 
     109} 
     110 
    103111/* status (UNDEF_S, PLAYING_S, PAUSE_S, FORWARD_S, BACKWARD_S, 
    104112   REWIND_S, NOT_STARTED_S, START_S) */ 
     
    147155        input_SetStatus( p_input, INPUT_STATUS_SLOWER ); 
    148156    } 
    149     //VolumeMute(); 
    150157} 
    151158 
     
    156163        input_SetStatus( p_input, INPUT_STATUS_FASTER ); 
    157164    } 
    158     //VolumeMute(); 
     165
     166 
     167BList * VlcWrapper::InputGetChannels( int i_cat ) 
     168
     169    if( p_input ) 
     170    { 
     171        unsigned int i; 
     172        uint32 what; 
     173        const char* fieldName; 
     174 
     175        switch( i_cat ) 
     176        { 
     177            case AUDIO_ES: 
     178            { 
     179                what = SELECT_CHANNEL; 
     180                fieldName = "channel"; 
     181                break; 
     182            } 
     183            case SPU_ES: 
     184            { 
     185                what = SELECT_SUBTITLE; 
     186                fieldName = "subtitle"; 
     187                break; 
     188            } 
     189            default: 
     190            return NULL; 
     191       } 
     192 
     193        vlc_mutex_lock( &p_input->stream.stream_lock ); 
     194       
     195        /* find which track is currently playing */ 
     196        es_descriptor_t *p_es = NULL; 
     197        for( i = 0; i < p_input->stream.i_selected_es_number; i++ ) 
     198        { 
     199            if( p_input->stream.pp_selected_es[i]->i_cat == i_cat ) 
     200                p_es = p_input->stream.pp_selected_es[i]; 
     201        } 
     202         
     203        /* build a list of all tracks */ 
     204        BList *list = new BList( p_input->stream.i_es_number ); 
     205        BMenuItem *menuItem; 
     206        BMessage *message; 
     207        char *trackName; 
     208         
     209        /* "None" */ 
     210        message = new BMessage( what ); 
     211        message->AddInt32( fieldName, -1 ); 
     212        menuItem = new BMenuItem( "None", message ); 
     213        if( !p_es ) 
     214            menuItem->SetMarked( true ); 
     215        list->AddItem( menuItem ); 
     216         
     217        for( i = 0; i < p_input->stream.i_es_number; i++ ) 
     218        { 
     219            if( p_input->stream.pp_es[i]->i_cat == i_cat ) 
     220            { 
     221                message = new BMessage( what ); 
     222                message->AddInt32( fieldName, i ); 
     223                if( strlen( p_input->stream.pp_es[i]->psz_desc ) ) 
     224                    trackName = strdup( p_input->stream.pp_es[i]->psz_desc ); 
     225                else 
     226                    trackName = "<unknown>"; 
     227                menuItem = new BMenuItem( trackName, message ); 
     228                if( p_input->stream.pp_es[i] == p_es ) 
     229                    menuItem->SetMarked( true ); 
     230                list->AddItem( menuItem ); 
     231            } 
     232        } 
     233         
     234        vlc_mutex_unlock( &p_input->stream.stream_lock ); 
     235 
     236        return list; 
     237    } 
     238    return NULL; 
    159239} 
    160240 
     
    183263 
    184264 
    185 void VlcWrapper::toggleLanguage(int i_language) 
    186 
    187  
    188     int32 i_old = -1; 
    189     int i_cat = AUDIO_ES; 
     265void VlcWrapper::ToggleLanguage( int i_language ) 
     266
     267    es_descriptor_t * p_es = NULL; 
     268    es_descriptor_t * p_es_old = NULL; 
    190269 
    191270    vlc_mutex_lock( &p_input->stream.stream_lock ); 
    192271    for( unsigned int i = 0; i < p_input->stream.i_selected_es_number ; i++ ) 
    193272    { 
    194         if( p_input->stream.pp_selected_es[i]->i_cat == i_cat
     273        if( p_input->stream.pp_selected_es[i]->i_cat == AUDIO_ES
    195274        { 
    196             i_old = i
     275            p_es_old = p_input->stream.pp_selected_es[i]
    197276            break; 
    198277        } 
    199278    } 
    200279    vlc_mutex_unlock( &p_input->stream.stream_lock ); 
    201  
    202     msg_Info( p_intf, "Old: %d,  New: %d", i_old, i_language); 
     280     
    203281    if( i_language != -1 ) 
    204282    { 
    205         input_ToggleES( p_input,  
    206                         p_input->stream.pp_selected_es[i_language], 
    207                         VLC_TRUE ); 
    208     } 
    209  
    210     if( (i_old != -1) && (i_old != i_language) ) 
    211     { 
    212         input_ToggleES( p_input,  
    213                         p_input->stream.pp_selected_es[i_old], 
    214                         VLC_FALSE ); 
    215     } 
    216 
    217  
    218 void VlcWrapper::toggleSubtitle(int i_subtitle) 
    219 
    220     int32 i_old = -1; 
    221     int i_cat = SPU_ES; 
     283        p_es = p_input->stream.pp_es[i_language]; 
     284    } 
     285    if( p_es == p_es_old ) 
     286    { 
     287        return; 
     288    } 
     289    if( p_es_old ) 
     290    { 
     291        input_ToggleES( p_input, p_es_old, VLC_FALSE ); 
     292    } 
     293    if( p_es ) 
     294    { 
     295        input_ToggleES( p_input, p_es, VLC_TRUE ); 
     296    } 
     297
     298 
     299void VlcWrapper::ToggleSubtitle( int i_subtitle ) 
     300
     301    es_descriptor_t * p_es = NULL; 
     302    es_descriptor_t * p_es_old = NULL; 
    222303 
    223304    vlc_mutex_lock( &p_input->stream.stream_lock ); 
    224305    for( unsigned int i = 0; i < p_input->stream.i_selected_es_number ; i++ ) 
    225306    { 
    226         if( p_input->stream.pp_selected_es[i]->i_cat == i_cat
     307        if( p_input->stream.pp_selected_es[i]->i_cat == SPU_ES
    227308        { 
    228             i_old = i
     309            p_es_old = p_input->stream.pp_selected_es[i]
    229310            break; 
    230311        } 
     
    232313    vlc_mutex_unlock( &p_input->stream.stream_lock ); 
    233314     
    234     msg_Info( p_intf, "Old: %d,  New: %d", i_old, i_subtitle); 
    235315    if( i_subtitle != -1 ) 
    236316    { 
    237         input_ToggleES( p_input,  
    238                         p_input->stream.pp_selected_es[i_subtitle], 
    239                         VLC_TRUE ); 
    240     } 
    241  
    242     if( (i_old != -1) && (i_old != i_subtitle) ) 
    243     { 
    244         input_ToggleES( p_input,  
    245                         p_input->stream.pp_selected_es[i_old], 
    246                         VLC_FALSE ); 
     317        p_es = p_input->stream.pp_es[i_subtitle]; 
     318    } 
     319    if( p_es == p_es_old ) 
     320    { 
     321        return; 
     322    } 
     323    if( p_es_old ) 
     324    { 
     325        input_ToggleES( p_input, p_es_old, VLC_FALSE ); 
     326    } 
     327    if( p_es ) 
     328    { 
     329        input_ToggleES( p_input, p_es, VLC_TRUE ); 
    247330    } 
    248331} 
     
    347430    { 
    348431        playlist_Play( p_playlist ); 
    349         //VolumeRestore(); 
    350432    } 
    351433    return( true ); 
     
    602684 ***************************/ 
    603685 
     686unsigned short VlcWrapper::GetVolume() 
     687{ 
     688    if( p_aout != NULL ) 
     689    { 
     690        unsigned short i_volume; 
     691        aout_VolumeGet( p_aout, (audio_volume_t*)&i_volume ); 
     692        return i_volume; 
     693    } 
     694    return 0; 
     695} 
     696 
    604697void VlcWrapper::SetVolume(int value) 
    605698{ 
  • modules/gui/beos/VlcWrapper.h

    r98363dc r2d8e1a6  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: VlcWrapper.h,v 1.10 2002/12/09 13:37:38 titer Exp $ 
     5 * $Id: VlcWrapper.h,v 1.11 2003/01/08 02:09:15 titer Exp $ 
    66 * 
    77 * Authors: Florian G. Pflug <fgp@phlo.org> 
     
    6363     
    6464    /* input */ 
     65    bool HasInput(); 
    6566    int InputStatus(); 
    6667    int InputRate(); 
     
    6970    void InputSlower(); 
    7071    void InputFaster(); 
     72    BList * InputGetChannels( int i_cat ); 
    7173    void openFiles( BList *o_files, bool replace = true ); 
    7274    void openDisc( BString o_type, BString o_device, 
    7375                   int i_title, int i_chapter ); 
    74     void toggleLanguage( int i_language ); 
    75     void toggleSubtitle( int i_subtitle ); 
     76    void ToggleLanguage( int i_language ); 
     77    void ToggleSubtitle( int i_subtitle ); 
    7678    const char* getTimeAsString(); 
    7779    float getTimeAsFloat(); 
     
    103105 
    104106    /* audio */ 
     107    unsigned short GetVolume(); 
    105108    void SetVolume( int value ); 
    106109    void VolumeMute();