Changeset acfc0a55ff1669dbb02dd3d796fe4727b7f6844b

Show
Ignore:
Timestamp:
07/01/07 14:22:37 (2 years ago)
Author:
Jean-Paul Saman <jpsaman@videolan.org>
git-committer:
Jean-Paul Saman <jpsaman@videolan.org> 1168176157 +0000
git-parent:

[763252337dc2e33bf50f5a87108399c6ef8565b1]

git-author:
Jean-Paul Saman <jpsaman@videolan.org> 1168176157 +0000
Message:

Reworked vlc.audio.channel API for JavaScript?. All documentation is already updated.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • activex/axvlc.idl

    r2dfa55b racfc0a5  
    207207 
    208208        [propget, helpstring("Returns audio channel: reverse stereo, stereo, left, right, dolby.")] 
    209         HRESULT channel([out, retval] BSTR* channel); 
     209        HRESULT channel([out, retval] long* channel); 
    210210        [propput, helpstring("Sets audio channel to: reverse stereo, stereo, left, right, dolby.")] 
    211         HRESULT channel([in] BSTR channel); 
     211        HRESULT channel([in] long channel); 
    212212    }; 
    213213 
  • activex/vlccontrol2.cpp

    r600555d racfc0a5  
    249249}; 
    250250 
    251 STDMETHODIMP VLCAudio::get_channel(BSTR *channel) 
     251STDMETHODIMP VLCAudio::get_channel(long *channel) 
    252252{ 
    253253    if( NULL == channel ) 
     
    258258    if( SUCCEEDED(hr) ) 
    259259    { 
    260         char *psz_channel = NULL; 
    261         libvlc_exception_t ex; 
    262         libvlc_exception_init(&ex); 
    263  
    264         psz_channel = libvlc_audio_get_channel(p_libvlc, &ex); 
    265         if( ! libvlc_exception_raised(&ex) ) 
    266         { 
    267             if( NULL == psz_channel ) 
    268                 return E_OUTOFMEMORY; 
    269  
    270             *channel = BSTRFromCStr(CP_UTF8, psz_channel); 
    271             free( psz_channel ); 
    272             psz_channel = NULL; 
    273             return (NULL == channel) ? E_OUTOFMEMORY : NOERROR; 
    274         } 
    275         if( psz_channel ) free( psz_channel ); 
    276         psz_channel = NULL; 
    277         _p_instance->setErrorInfo(IID_IVLCAudio, 
    278                     libvlc_exception_get_message(&ex)); 
    279         libvlc_exception_clear(&ex); 
    280         return E_FAIL; 
    281     } 
    282     return hr; 
    283 }; 
    284  
    285 STDMETHODIMP VLCAudio::put_channel(BSTR channel) 
    286 
    287     if( NULL == channel ) 
    288         return E_POINTER; 
    289  
    290     if( 0 == SysStringLen(channel) ) 
    291         return E_INVALIDARG; 
    292  
    293     libvlc_instance_t* p_libvlc; 
    294     HRESULT hr = _p_instance->getVLC(&p_libvlc); 
    295     if( SUCCEEDED(hr) ) 
    296     { 
    297         char *psz_channel = NULL; 
    298         libvlc_exception_t ex; 
    299         libvlc_exception_init(&ex); 
    300  
    301         psz_channel = CStrFromBSTR(CP_UTF8, channel); 
    302         if( NULL == psz_channel ) 
    303             return E_OUTOFMEMORY; 
    304  
    305         libvlc_audio_set_channel(p_libvlc, psz_channel, &ex); 
    306         CoTaskMemFree(psz_channel); 
     260        libvlc_exception_t ex; 
     261        libvlc_exception_init(&ex); 
     262 
     263        *channel = libvlc_audio_get_channel(p_libvlc, &ex); 
     264        if( libvlc_exception_raised(&ex) ) 
     265        { 
     266            _p_instance->setErrorInfo(IID_IVLCAudio, 
     267                        libvlc_exception_get_message(&ex)); 
     268            libvlc_exception_clear(&ex); 
     269            return E_FAIL; 
     270        } 
     271        return NOERROR; 
     272    } 
     273    return hr; 
     274}; 
     275 
     276STDMETHODIMP VLCAudio::put_channel(long channel) 
     277
     278    libvlc_instance_t* p_libvlc; 
     279    HRESULT hr = _p_instance->getVLC(&p_libvlc); 
     280    if( SUCCEEDED(hr) ) 
     281    { 
     282        libvlc_exception_t ex; 
     283        libvlc_exception_init(&ex); 
     284 
     285        libvlc_audio_set_channel(p_libvlc, channel, &ex); 
    307286        if( libvlc_exception_raised(&ex) ) 
    308287        { 
  • activex/vlccontrol2.h

    r0459ac1 racfc0a5  
    6969    STDMETHODIMP get_track(long*); 
    7070    STDMETHODIMP put_track(long); 
    71     STDMETHODIMP get_channel(BSTR*); 
    72     STDMETHODIMP put_channel(BSTR); 
     71    STDMETHODIMP get_channel(long*); 
     72    STDMETHODIMP put_channel(long); 
    7373    STDMETHODIMP toggleMute(); 
    7474 
  • include/vlc/libvlc.h

    ra77fdc2 racfc0a5  
    511511 * \param p_instance input instance 
    512512 * \param p_exception an initialized exception 
    513  * \return the audio channel (char *
    514  */ 
    515 char *libvlc_audio_get_channel( libvlc_instance_t *, libvlc_exception_t * ); 
     513 * \return the audio channel (int
     514 */ 
     515int libvlc_audio_get_channel( libvlc_instance_t *, libvlc_exception_t * ); 
    516516 
    517517/** 
    518518 * Set current audio channel 
    519519 * \param p_instance input instance 
    520  * \param psz_channel the audio channel (char *
    521  * \param p_exception an initialized exception 
    522  */ 
    523 void libvlc_audio_set_channel( libvlc_instance_t *, char *, libvlc_exception_t * ); 
     520 * \param i_channel the audio channel (int
     521 * \param p_exception an initialized exception 
     522 */ 
     523void libvlc_audio_set_channel( libvlc_instance_t *, int, libvlc_exception_t * ); 
    524524 
    525525/** @} */ 
  • mozilla/control/npolibvlc.cpp

    r2dfa55b racfc0a5  
    251251            case ID_audio_channel: 
    252252            { 
    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); 
     253                int 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                INT32_TO_NPVARIANT(channel, result); 
    265262                return INVOKERESULT_NO_ERROR; 
    266263            } 
     
    339336            case ID_audio_channel: 
    340337            { 
    341                 char *psz_channel = NULL; 
    342  
    343                 libvlc_input_free(p_input); 
    344                 if( ! NPVARIANT_IS_STRING(value) ) 
    345                     return INVOKERESULT_INVALID_VALUE; 
    346  
    347                 psz_channel = stringValue(NPVARIANT_TO_STRING(value)); 
    348                 if( !psz_channel ) 
    349                     return INVOKERESULT_GENERIC_ERROR; 
    350  
    351                 libvlc_audio_set_channel(p_plugin->getVLC(), psz_channel, &ex); 
    352                 if( psz_channel ) 
    353                     free( psz_channel ); 
    354  
    355                 if( libvlc_exception_raised(&ex) ) 
    356                 { 
    357                     NPN_SetException(this, libvlc_exception_get_message(&ex)); 
    358                     libvlc_exception_clear(&ex); 
    359                     return INVOKERESULT_GENERIC_ERROR; 
    360                 } 
    361                 return INVOKERESULT_NO_ERROR; 
     338                libvlc_input_free(p_input); 
     339                if( isNumberValue(value) ) 
     340                { 
     341                    libvlc_audio_set_channel(p_plugin->getVLC(), 
     342                                         numberValue(value), &ex); 
     343                    if( libvlc_exception_raised(&ex) ) 
     344                    { 
     345                        NPN_SetException(this, libvlc_exception_get_message(&ex)); 
     346                        libvlc_exception_clear(&ex); 
     347                        return INVOKERESULT_GENERIC_ERROR; 
     348                    } 
     349                    return INVOKERESULT_NO_ERROR; 
     350                } 
     351                return INVOKERESULT_INVALID_VALUE; 
    362352            } 
    363353            default: 
  • src/control/audio.c

    r6e16579 racfc0a5  
    188188 * libvlc_audio_get_channel : Get the current audio channel 
    189189 *****************************************************************************/ 
    190 char *libvlc_audio_get_channel( libvlc_instance_t *p_instance, 
     190int libvlc_audio_get_channel( libvlc_instance_t *p_instance, 
    191191                                libvlc_exception_t *p_e ) 
    192192{ 
    193193    aout_instance_t *p_aout = GetAOut( p_instance, p_e ); 
    194     char *psz_channel = NULL; 
    195194    vlc_value_t val; 
    196195 
    197196    var_Get( p_aout, "audio-channels", &val ); 
    198     switch( val.i_int ) 
     197    vlc_object_release( p_aout ); 
     198    return val.i_int; 
     199
     200 
     201/***************************************************************************** 
     202 * libvlc_audio_set_channel : Set the current audio channel 
     203 *****************************************************************************/ 
     204void libvlc_audio_set_channel( libvlc_instance_t *p_instance, int i_channel, 
     205                               libvlc_exception_t *p_e ) 
     206
     207    aout_instance_t *p_aout = GetAOut( p_instance, p_e ); 
     208    vlc_value_t val; 
     209    int i_ret = -1; 
     210 
     211    val.i_int = i_channel; 
     212    switch( i_channel ) 
    199213    { 
    200214        case AOUT_VAR_CHAN_RSTEREO: 
    201             psz_channel = strdup("reverse stereo"); 
    202             break; 
    203215        case AOUT_VAR_CHAN_STEREO: 
    204             psz_channel = strdup("stereo"); 
    205             break; 
    206216        case AOUT_VAR_CHAN_LEFT: 
    207             psz_channel = strdup("left"); 
    208             break; 
    209217        case AOUT_VAR_CHAN_RIGHT: 
    210             psz_channel = strdup("right"); 
    211             break; 
    212218        case AOUT_VAR_CHAN_DOLBYS: 
    213             psz_channel = strdup("dolby"); 
    214             break; 
    215         default: 
    216             psz_channel = strdup("disabled"); 
    217             break; 
    218     } 
    219     vlc_object_release( p_aout ); 
    220     return psz_channel; 
    221 } 
    222  
    223 /***************************************************************************** 
    224  * libvlc_audio_set_channel : Set the current audio channel 
    225  *****************************************************************************/ 
    226 void libvlc_audio_set_channel( libvlc_instance_t *p_instance, char *psz_channel, 
    227                                libvlc_exception_t *p_e ) 
    228 { 
    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 ) 
    247         { 
    248219            i_ret = var_Set( p_aout, "audio-channels", val ); 
    249220            if( i_ret < 0 ) 
    250221            { 
    251                 libvlc_exception_raise( p_e, "failed setting audio range" ); 
     222                libvlc_exception_raise( p_e, "Failed setting audio channel" ); 
    252223                vlc_object_release( p_aout ); 
    253224                return; 
     
    255226            vlc_object_release( p_aout ); 
    256227            return; /* Found */ 
    257         } 
    258     } 
    259     libvlc_exception_raise( p_e, "Audio channel out of range" ); 
     228        default: 
     229            libvlc_exception_raise( p_e, "Audio channel out of range" ); 
     230            break; 
     231    } 
    260232    vlc_object_release( p_aout ); 
    261233} 
    262