Changeset 2dfa55bd53357dc8bfcb6c94ec9a204dc9d3fe65
- Timestamp:
- 20/12/06 23:11:54 (2 years ago)
- git-parent:
- Files:
-
- activex/axvlc.idl (modified) (1 diff)
- activex/vlccontrol2.cpp (modified) (6 diffs)
- include/vlc/libvlc.h (modified) (2 diffs)
- mozilla/control/npolibvlc.cpp (modified) (13 diffs)
- mozilla/control/npolibvlc.h (modified) (3 diffs)
- src/control/audio.c (modified) (6 diffs)
- src/control/video.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
activex/axvlc.idl
rdc1ce79 r2dfa55b 206 206 HRESULT track([in] long track); 207 207 208 [propget, helpstring("Returns audio channel: reverse , stereo, left, right, dolby.")]208 [propget, helpstring("Returns audio channel: reverse stereo, stereo, left, right, dolby.")] 209 209 HRESULT channel([out, retval] BSTR* channel); 210 [propput, helpstring("Sets audio channel to: reverse , stereo, left, right, dolby.")]210 [propput, helpstring("Sets audio channel to: reverse stereo, stereo, left, right, dolby.")] 211 211 HRESULT channel([in] BSTR channel); 212 212 }; activex/vlccontrol2.cpp
rf386482 r2dfa55b 212 212 libvlc_exception_init(&ex); 213 213 214 *track = libvlc_audio_get_track(p_libvlc, &ex); 214 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex); 215 *track = libvlc_audio_get_track(p_input, &ex); 216 libvlc_input_free(p_input); 215 217 if( libvlc_exception_raised(&ex) ) 216 218 { … … 233 235 libvlc_exception_init(&ex); 234 236 235 libvlc_audio_set_track(p_libvlc, track, &ex); 237 libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex); 238 libvlc_audio_set_track(p_input, track, &ex); 239 libvlc_input_free(p_input); 236 240 if( libvlc_exception_raised(&ex) ) 237 241 { … … 266 270 *channel = BSTRFromCStr(CP_UTF8, psz_channel); 267 271 free( psz_channel ); 268 return NOERROR; 272 psz_channel = NULL; 273 return (NULL == *channel) ? E_OUTOFMEMORY : NOERROR; 269 274 } 270 275 if( psz_channel ) free( psz_channel ); 276 psz_channel = NULL; 271 277 _p_instance->setErrorInfo(IID_IVLCAudio, 272 278 libvlc_exception_get_message(&ex)); … … 298 304 299 305 libvlc_audio_set_channel(p_libvlc, psz_channel, &ex); 300 301 306 CoTaskMemFree(psz_channel); 302 307 if( libvlc_exception_raised(&ex) ) … … 2088 2093 return E_OUTOFMEMORY; 2089 2094 2090 *aspect = SysAllocStringByteLen(psz_aspect, strlen(psz_aspect));2095 *aspect = BSTRFromCStr(CP_UTF8, psz_aspect); 2091 2096 free( psz_aspect ); 2092 2097 psz_aspect = NULL; 2093 return NOERROR;2098 return (NULL == *aspect) ? E_OUTOFMEMORY : NOERROR; 2094 2099 } 2095 2100 if( psz_aspect ) free( psz_aspect ); 2101 psz_aspect = NULL; 2096 2102 } 2097 2103 _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); … … 2467 2473 return E_OUTOFMEMORY; 2468 2474 }; 2469 include/vlc/libvlc.h
rb28e412 r2dfa55b 493 493 494 494 /** 495 * Get current audio track496 * \param p_instance libvlcinstance497 * \param p_exception an initialized exception498 * \return the audio track (int)499 */500 int libvlc_audio_get_track( libvlc_in stance_t *, libvlc_exception_t * );495 + * Get current audio track 496 + * \param p_input input instance 497 + * \param p_exception an initialized exception 498 + * \return the audio track (int) 499 + */ 500 int libvlc_audio_get_track( libvlc_input_t *, libvlc_exception_t * ); 501 501 502 502 /** 503 503 * Set current audio track 504 * \param p_in stance libvlcinstance504 * \param p_input input instance 505 505 * \param i_track the track (int) 506 506 * \param p_exception an initialized exception 507 507 * \return void 508 508 */ 509 void libvlc_audio_set_track( libvlc_in stance_t *, int, libvlc_exception_t * );509 void libvlc_audio_set_track( libvlc_input_t *, int, libvlc_exception_t * ); 510 510 511 511 /** 512 512 * Get current audio channel 513 * \param p_instance libvlcinstance513 * \param p_instance input instance 514 514 * \param p_exception an initialized exception 515 515 * \return the audio channel (char *) … … 518 518 519 519 /** 520 * Set current audio track521 * \param p_instance libvlcinstance520 * Set current audio channel 521 * \param p_instance input instance 522 522 * \param psz_channel the audio channel (char *) 523 523 * \param p_exception an initialized exception mozilla/control/npolibvlc.cpp
rdc1ce79 r2dfa55b 200 200 libvlc_exception_init(&ex); 201 201 202 libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex); 203 if( libvlc_exception_raised(&ex) ) 204 { 205 NPN_SetException(this, libvlc_exception_get_message(&ex)); 206 libvlc_exception_clear(&ex); 207 return INVOKERESULT_GENERIC_ERROR; 208 } 209 202 210 switch( index ) 203 211 { … … 205 213 { 206 214 vlc_bool_t muted = libvlc_audio_get_mute(p_plugin->getVLC(), &ex); 215 libvlc_input_free(p_input); 207 216 if( libvlc_exception_raised(&ex) ) 208 217 { … … 217 226 { 218 227 int volume = libvlc_audio_get_volume(p_plugin->getVLC(), &ex); 228 libvlc_input_free(p_input); 219 229 if( libvlc_exception_raised(&ex) ) 220 230 { … … 228 238 case ID_audio_track: 229 239 { 230 int track = libvlc_audio_get_track(p_plugin->getVLC(), &ex); 240 int track = libvlc_audio_get_track(p_input, &ex); 241 libvlc_input_free(p_input); 231 242 if( libvlc_exception_raised(&ex) ) 232 243 { … … 240 251 case ID_audio_channel: 241 252 { 242 char *channel = libvlc_audio_get_channel(p_plugin->getVLC(), &ex); 243 if( libvlc_exception_raised(&ex) ) 244 { 245 NPN_SetException(this, libvlc_exception_get_message(&ex)); 246 libvlc_exception_clear(&ex); 247 return INVOKERESULT_GENERIC_ERROR; 248 } 249 if( channel ) 250 { 251 int len = strlen(channel); 252 NPUTF8 *retval = (NPUTF8*)NPN_MemAlloc(len); 253 if( retval ) 254 { 255 memcpy(retval, channel, len); 256 STRINGN_TO_NPVARIANT(retval, len, result); 257 } 258 else 259 { 260 NULL_TO_NPVARIANT(result); 261 } 262 free( channel ); 263 channel = NULL; 264 return INVOKERESULT_NO_ERROR; 265 } 266 return INVOKERESULT_NO_SUCH_METHOD; 253 NPUTF8 *psz_channel = libvlc_audio_get_channel(p_plugin->getVLC(), &ex); 254 libvlc_input_free(p_input); 255 if( libvlc_exception_raised(&ex) ) 256 { 257 NPN_SetException(this, libvlc_exception_get_message(&ex)); 258 libvlc_exception_clear(&ex); 259 return INVOKERESULT_GENERIC_ERROR; 260 } 261 if( !psz_channel ) 262 return INVOKERESULT_GENERIC_ERROR; 263 264 STRINGZ_TO_NPVARIANT(psz_channel, result); 265 return INVOKERESULT_NO_ERROR; 267 266 } 268 267 default: 269 268 ; 270 269 } 270 libvlc_input_free(p_input); 271 271 } 272 272 return INVOKERESULT_GENERIC_ERROR; … … 281 281 libvlc_exception_init(&ex); 282 282 283 libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex); 284 if( libvlc_exception_raised(&ex) ) 285 { 286 NPN_SetException(this, libvlc_exception_get_message(&ex)); 287 libvlc_exception_clear(&ex); 288 return INVOKERESULT_GENERIC_ERROR; 289 } 290 283 291 switch( index ) 284 292 { … … 288 296 libvlc_audio_set_mute(p_plugin->getVLC(), 289 297 NPVARIANT_TO_BOOLEAN(value), &ex); 298 libvlc_input_free(p_input); 290 299 if( libvlc_exception_raised(&ex) ) 291 300 { … … 298 307 return INVOKERESULT_INVALID_VALUE; 299 308 case ID_audio_volume: 309 libvlc_input_free(p_input); 300 310 if( isNumberValue(value) ) 301 311 { … … 314 324 if( isNumberValue(value) ) 315 325 { 316 libvlc_audio_set_track(p_ plugin->getVLC(),326 libvlc_audio_set_track(p_input, 317 327 numberValue(value), &ex); 328 libvlc_input_free(p_input); 318 329 if( libvlc_exception_raised(&ex) ) 319 330 { … … 324 335 return INVOKERESULT_NO_ERROR; 325 336 } 337 libvlc_input_free(p_input); 326 338 return INVOKERESULT_INVALID_VALUE; 327 339 case ID_audio_channel: … … 329 341 char *psz_channel = NULL; 330 342 343 libvlc_input_free(p_input); 331 344 if( ! NPVARIANT_IS_STRING(value) ) 332 {333 345 return INVOKERESULT_INVALID_VALUE; 334 }335 346 336 347 psz_channel = stringValue(NPVARIANT_TO_STRING(value)); … … 353 364 ; 354 365 } 366 libvlc_input_free(p_input); 355 367 } 356 368 return INVOKERESULT_GENERIC_ERROR; … … 1901 1913 psz_aspect = stringValue(NPVARIANT_TO_STRING(value)); 1902 1914 if( !psz_aspect ) 1903 return INVOKERESULT_GENERIC_ERROR; 1915 { 1916 libvlc_input_free(p_input); 1917 return INVOKERESULT_GENERIC_ERROR; 1918 } 1904 1919 1905 1920 libvlc_video_set_aspect_ratio(p_input, psz_aspect, &ex); mozilla/control/npolibvlc.h
rec07766 r2dfa55b 81 81 LibvlcInputNPObject(NPP instance, const NPClass *aClass) : 82 82 RuntimeNPObject(instance, aClass) {}; 83 83 84 84 virtual ~LibvlcInputNPObject() {}; 85 85 … … 107 107 LibvlcMessageNPObject(NPP instance, const NPClass *aClass) : 108 108 RuntimeNPObject(instance, aClass) {}; 109 109 110 110 virtual ~LibvlcMessageNPObject() {}; 111 111 … … 153 153 LibvlcMessagesNPObject(NPP instance, const NPClass *aClass) : 154 154 RuntimeNPObject(instance, aClass) {}; 155 155 156 156 virtual ~LibvlcMessagesNPObject() {}; 157 157 src/control/audio.c
rd9d80e1 r2dfa55b 26 26 #include <vlc/libvlc.h> 27 27 28 #include <vlc_input.h> 28 29 #include <vlc_aout.h> 30 31 /* 32 * Remember to release the returned input_thread_t since it is locked at 33 * the end of this function. 34 */ 35 static input_thread_t *GetInput( libvlc_input_t *p_input, 36 libvlc_exception_t *p_exception ) 37 { 38 input_thread_t *p_input_thread = NULL; 39 40 if( !p_input ) 41 { 42 libvlc_exception_raise( p_exception, "Input is NULL" ); 43 return NULL; 44 } 45 46 p_input_thread = (input_thread_t*)vlc_object_get( 47 p_input->p_instance->p_libvlc_int, 48 p_input->i_input_id ); 49 if( !p_input_thread ) 50 { 51 libvlc_exception_raise( p_exception, "Input does not exist" ); 52 return NULL; 53 } 54 55 return p_input_thread; 56 } 57 58 /* 59 * Remember to release the returned aout_instance_t since it is locked at 60 * the end of this function. 61 */ 62 static aout_instance_t *GetAOut( libvlc_instance_t *p_instance, 63 libvlc_exception_t *p_exception ) 64 { 65 aout_instance_t * p_aout = NULL; 66 67 p_aout = vlc_object_find( p_instance->p_libvlc_int, VLC_OBJECT_AOUT, FIND_CHILD ); 68 if( !p_aout ) 69 { 70 libvlc_exception_raise( p_exception, "No active audio output" ); 71 return NULL; 72 } 73 74 return p_aout; 75 } 76 29 77 30 78 /***************************************************************************** … … 95 143 * libvlc_audio_get_track : Get the current audio track 96 144 *****************************************************************************/ 97 int libvlc_audio_get_track( libvlc_in stance_t *p_instance,145 int libvlc_audio_get_track( libvlc_input_t *p_input, 98 146 libvlc_exception_t *p_e ) 99 147 { 148 input_thread_t *p_input_thread = GetInput( p_input, p_e ); 100 149 int i_track = 0; 101 150 102 i_track = var_GetInteger( p_instance->p_libvlc_int, "audio-track" ); 151 i_track = var_GetInteger( p_input_thread, "audio-es" ); 152 vlc_object_release( p_input_thread ); 103 153 104 154 return i_track; … … 108 158 * libvlc_audio_set_track : Set the current audio track 109 159 *****************************************************************************/ 110 void libvlc_audio_set_track( libvlc_in stance_t *p_instance, int i_track,160 void libvlc_audio_set_track( libvlc_input_t *p_input, int i_track, 111 161 libvlc_exception_t *p_e ) 112 162 { 163 input_thread_t *p_input_thread = GetInput( p_input, p_e ); 164 vlc_value_t val_list; 113 165 int i_ret = -1; 114 115 i_ret = var_SetInteger( p_instance->p_libvlc_int, "audio-track", i_track ); 116 117 if( i_ret < 0 ) 118 { 119 libvlc_exception_raise( p_e, "Setting audio track failed" ); 120 } 166 int i; 167 168 var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL ); 169 for( i = 0; i < val_list.p_list->i_count; i++ ) 170 { 171 vlc_value_t val = val_list.p_list->p_values[i]; 172 if( i_track == val.i_int ) 173 { 174 i_ret = var_SetInteger( p_input_thread, "audio-es", i_track ); 175 if( i_ret < 0 ) 176 { 177 libvlc_exception_raise( p_e, "Setting audio track failed" ); 178 } 179 vlc_object_release( p_input_thread ); 180 return; 181 } 182 } 183 libvlc_exception_raise( p_e, "Audio track out of range" ); 184 vlc_object_release( p_input_thread ); 121 185 } 122 186 … … 127 191 libvlc_exception_t *p_e ) 128 192 { 193 aout_instance_t *p_aout = GetAOut( p_instance, p_e ); 129 194 char *psz_channel = NULL; 130 int i_channel = 0;131 132 i_channel = var_GetInteger( p_instance->p_libvlc_int, "audio-channel");133 switch( i_channel)195 vlc_value_t val; 196 197 var_Get( p_aout, "audio-channels", &val ); 198 switch( val.i_int ) 134 199 { 135 200 case AOUT_VAR_CHAN_RSTEREO: 136 psz_channel = strdup("reverse ");201 psz_channel = strdup("reverse stereo"); 137 202 break; 138 203 case AOUT_VAR_CHAN_STEREO: … … 152 217 break; 153 218 } 219 vlc_object_release( p_aout ); 154 220 return psz_channel; 155 221 } … … 161 227 libvlc_exception_t *p_e ) 162 228 { 163 int i_ret = -1; 164 int i_channel = 0; 165 166 if( !psz_channel ) 167 { 168 libvlc_exception_raise( p_e, "Audio track out of range" ); 169 } 170 else 171 { 172 if( strncmp( psz_channel, "reverse", 7 ) == 0 ) 173 i_channel = AOUT_VAR_CHAN_RSTEREO; 174 else if( strncmp( psz_channel, "stereo", 6 ) == 0 ) 175 i_channel = AOUT_VAR_CHAN_STEREO; 176 else if( strncmp( psz_channel, "left", 4 ) == 0 ) 177 i_channel = AOUT_VAR_CHAN_LEFT; 178 else if( strncmp( psz_channel, "right", 5 ) == 0 ) 179 i_channel = AOUT_VAR_CHAN_RIGHT; 180 else if( strncmp( psz_channel, "dolby", 5 ) == 0 ) 181 i_channel = AOUT_VAR_CHAN_DOLBYS; 182 183 i_ret = var_SetInteger( p_instance->p_libvlc_int, "audio-channel", i_channel ); 184 if( i_ret < 0 ) 229 aout_instance_t *p_aout = GetAOut( p_instance, p_e ); 230 vlc_value_t val_list, text_list; 231 int i_ret = -1, i; 232 233 i_ret = var_Change( p_aout, "audio-channels", VLC_VAR_GETCHOICES, &val_list, &text_list ); 234 if( (i_ret < 0) || !psz_channel ) 235 { 236 libvlc_exception_raise( p_e, "Audio channel out of range" ); 237 vlc_object_release( p_aout ); 238 return; 239 } 240 241 for( i = 0; i < val_list.p_list->i_count; i++ ) 242 { 243 vlc_value_t val = val_list.p_list->p_values[i]; 244 vlc_value_t text = text_list.p_list->p_values[i]; 245 246 if( strncasecmp( psz_channel, text.psz_string, strlen(text.psz_string) ) == 0 ) 185 247 { 186 libvlc_exception_raise( p_e, "Audio track out of range" ); 248 i_ret = var_Set( p_aout, "audio-channels", val ); 249 if( i_ret < 0 ) 250 { 251 break; 252 } 187 253 } 188 254 } 189 } 255 libvlc_exception_raise( p_e, "Audio channel out of range" ); 256 vlc_object_release( p_aout ); 257 } 258 src/control/video.c
ra10792f r2dfa55b 201 201 { 202 202 if ( strcmp( "No active video output", libvlc_exception_get_message( p_e ) ) == 0 ) 203 {204 libvlc_exception_clear( p_e );205 }206 return VLC_FALSE;203 { 204 libvlc_exception_clear( p_e ); 205 } 206 return VLC_FALSE; 207 207 } 208 208 … … 222 222 return 0; 223 223 } 224 224 225 225 vout_Control( p_vout , VOUT_REPARENT, d); 226 226 vlc_object_release( p_vout );
