Changeset 2d8e1a61809e9fc5be3294f9811aa99786ab9c18
- Timestamp:
- 08/01/03 03:09:15 (6 years ago)
- git-parent:
- Files:
-
- modules/gui/beos/InterfaceWindow.cpp (modified) (8 diffs)
- modules/gui/beos/InterfaceWindow.h (modified) (3 diffs)
- modules/gui/beos/VlcWrapper.cpp (modified) (10 diffs)
- modules/gui/beos/VlcWrapper.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/gui/beos/InterfaceWindow.cpp
r29b488f r2d8e1a6 3 3 ***************************************************************************** 4 4 * Copyright (C) 1999, 2000, 2001 VideoLAN 5 * $Id: InterfaceWindow.cpp,v 1.1 2 2002/12/09 07:57:04titer Exp $5 * $Id: InterfaceWindow.cpp,v 1.13 2003/01/08 02:09:15 titer Exp $ 6 6 * 7 7 * Authors: Jean-Marc Dressler <polux@via.ecp.fr> … … 136 136 fileMenu->AddItem( new BMenuItem( "Quit", new BMessage( B_QUIT_REQUESTED ), 'Q') ); 137 137 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); 140 140 141 141 /* Add the Audio menu */ … … 347 347 if ( p_message->FindInt32( "channel", &channel ) == B_OK ) 348 348 { 349 p_wrapper-> toggleLanguage( channel );349 p_wrapper->ToggleLanguage( channel ); 350 350 } 351 351 } … … 357 357 int32 subtitle; 358 358 if ( p_message->FindInt32( "subtitle", &subtitle ) == B_OK ) 359 p_wrapper-> toggleSubtitle( subtitle );359 p_wrapper->ToggleSubtitle( subtitle ); 360 360 } 361 361 break; … … 474 474 void InterfaceWindow::updateInterface() 475 475 { 476 if( /* has_input */ true)476 if( p_wrapper->HasInput() ) 477 477 { 478 478 if ( acquire_sem( p_mediaControl->fScrubSem ) == B_OK ) … … 523 523 Unlock(); 524 524 } 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 } 525 532 526 533 fLastUpdateTime = system_time(); … … 891 898 * LanguageMenu::LanguageMenu 892 899 *****************************************************************************/ 893 LanguageMenu::LanguageMenu( const char *name, int menu_kind,894 intf_thread_t *p_interface)900 LanguageMenu::LanguageMenu( const char *name, int menu_kind, 901 VlcWrapper *p_wrapper ) 895 902 :BMenu(name) 896 903 { 897 904 kind = menu_kind; 898 p_intf = p_interface;905 this->p_wrapper = p_wrapper; 899 906 } 900 907 … … 925 932 void LanguageMenu::_GetChannels() 926 933 { 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 } 1003 949 1004 950 modules/gui/beos/InterfaceWindow.h
r3b078b7 r2d8e1a6 3 3 ***************************************************************************** 4 4 * Copyright (C) 1999, 2000, 2001 VideoLAN 5 * $Id: InterfaceWindow.h,v 1. 6 2002/11/27 05:36:41titer Exp $5 * $Id: InterfaceWindow.h,v 1.7 2003/01/08 02:09:15 titer Exp $ 6 6 * 7 7 * Authors: Jean-Marc Dressler <polux@via.ecp.fr> … … 54 54 LanguageMenu( const char* name, 55 55 int menu_kind, 56 intf_thread_t* p_interface);56 VlcWrapper *p_wrapper ); 57 57 virtual ~LanguageMenu(); 58 58 … … 62 62 void _GetChannels(); 63 63 64 intf_thread_t* p_intf;64 VlcWrapper * p_wrapper; 65 65 int kind; 66 66 }; modules/gui/beos/VlcWrapper.cpp
re00996a r2d8e1a6 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001 VideoLAN 5 * $Id: VlcWrapper.cpp,v 1.1 4 2002/12/26 18:17:38 stippiExp $5 * $Id: VlcWrapper.cpp,v 1.15 2003/01/08 02:09:15 titer Exp $ 6 6 * 7 7 * Authors: Florian G. Pflug <fgp@phlo.org> … … 25 25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 26 26 *****************************************************************************/ 27 #include <AppKit.h> 28 #include <InterfaceKit.h> 27 29 #include <SupportKit.h> 28 30 … … 35 37 36 38 #include "VlcWrapper.h" 39 #include "MsgVals.h" 37 40 38 41 /* constructor */ … … 101 104 ***************************/ 102 105 106 bool VlcWrapper::HasInput() 107 { 108 return( p_input != NULL ); 109 } 110 103 111 /* status (UNDEF_S, PLAYING_S, PAUSE_S, FORWARD_S, BACKWARD_S, 104 112 REWIND_S, NOT_STARTED_S, START_S) */ … … 147 155 input_SetStatus( p_input, INPUT_STATUS_SLOWER ); 148 156 } 149 //VolumeMute();150 157 } 151 158 … … 156 163 input_SetStatus( p_input, INPUT_STATUS_FASTER ); 157 164 } 158 //VolumeMute(); 165 } 166 167 BList * 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; 159 239 } 160 240 … … 183 263 184 264 185 void VlcWrapper::toggleLanguage(int i_language) 186 { 187 188 int32 i_old = -1; 189 int i_cat = AUDIO_ES; 265 void VlcWrapper::ToggleLanguage( int i_language ) 266 { 267 es_descriptor_t * p_es = NULL; 268 es_descriptor_t * p_es_old = NULL; 190 269 191 270 vlc_mutex_lock( &p_input->stream.stream_lock ); 192 271 for( unsigned int i = 0; i < p_input->stream.i_selected_es_number ; i++ ) 193 272 { 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 ) 195 274 { 196 i_old = i;275 p_es_old = p_input->stream.pp_selected_es[i]; 197 276 break; 198 277 } 199 278 } 200 279 vlc_mutex_unlock( &p_input->stream.stream_lock ); 201 202 msg_Info( p_intf, "Old: %d, New: %d", i_old, i_language); 280 203 281 if( i_language != -1 ) 204 282 { 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 299 void VlcWrapper::ToggleSubtitle( int i_subtitle ) 300 { 301 es_descriptor_t * p_es = NULL; 302 es_descriptor_t * p_es_old = NULL; 222 303 223 304 vlc_mutex_lock( &p_input->stream.stream_lock ); 224 305 for( unsigned int i = 0; i < p_input->stream.i_selected_es_number ; i++ ) 225 306 { 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 ) 227 308 { 228 i_old = i;309 p_es_old = p_input->stream.pp_selected_es[i]; 229 310 break; 230 311 } … … 232 313 vlc_mutex_unlock( &p_input->stream.stream_lock ); 233 314 234 msg_Info( p_intf, "Old: %d, New: %d", i_old, i_subtitle);235 315 if( i_subtitle != -1 ) 236 316 { 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 ); 247 330 } 248 331 } … … 347 430 { 348 431 playlist_Play( p_playlist ); 349 //VolumeRestore();350 432 } 351 433 return( true ); … … 602 684 ***************************/ 603 685 686 unsigned 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 604 697 void VlcWrapper::SetVolume(int value) 605 698 { modules/gui/beos/VlcWrapper.h
r98363dc r2d8e1a6 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001 VideoLAN 5 * $Id: VlcWrapper.h,v 1.1 0 2002/12/09 13:37:38titer Exp $5 * $Id: VlcWrapper.h,v 1.11 2003/01/08 02:09:15 titer Exp $ 6 6 * 7 7 * Authors: Florian G. Pflug <fgp@phlo.org> … … 63 63 64 64 /* input */ 65 bool HasInput(); 65 66 int InputStatus(); 66 67 int InputRate(); … … 69 70 void InputSlower(); 70 71 void InputFaster(); 72 BList * InputGetChannels( int i_cat ); 71 73 void openFiles( BList *o_files, bool replace = true ); 72 74 void openDisc( BString o_type, BString o_device, 73 75 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 ); 76 78 const char* getTimeAsString(); 77 79 float getTimeAsFloat(); … … 103 105 104 106 /* audio */ 107 unsigned short GetVolume(); 105 108 void SetVolume( int value ); 106 109 void VolumeMute();
