Changeset 44de024820ed206165d81338c36439e786fe2f65

Show
Ignore:
Timestamp:
01/08/06 11:22:35 (2 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1154424155 +0000
git-parent:

[5d09f6000a0b589d63e1fc9c6af4e5b055658203]

git-author:
Clément Stenac <zorglub@videolan.org> 1154424155 +0000
Message:

src/control: a bit of cleanup here and there

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/libvlc_internal.h

    r05985a9 r44de024  
    5151}; 
    5252 
     53#define RAISENULL( psz ) { libvlc_exception_raise( p_e, psz ); return NULL; } 
     54#define RAISEVOID( psz ) { libvlc_exception_raise( p_e, psz ); return; } 
     55#define RAISEZERO( psz ) { libvlc_exception_raise( p_e, psz ); return 0; } 
    5356 
    5457# ifdef __cplusplus 
  • include/vlc/libvlc.h

    r8914d39 r44de024  
    115115 
    116116/** 
    117  * returns a libvlc instance identifier for legacy APIs 
    118  * \param p_instance the instance to destroy 
     117 * Returns a libvlc instance identifier for legacy APIs. Use of this 
     118 * function is discouraged, you should convert your program to use the 
     119 * new API. 
     120 * \param p_instance the instance 
    119121 */ 
    120122int libvlc_get_vlc_id( libvlc_instance_t *p_instance ); 
     
    202204 
    203205/** 
    204  * Go to next playlist item 
    205  * \param p_instance the instance 
    206  * \param p_exception an initialized exception 
    207  */ 
    208 void libvlc_playlist_next( libvlc_instance_t *, libvlc_exception_t * ); 
    209  
    210 /** 
    211  * Go to Previous playlist item 
    212  * \param p_instance the instance 
    213  * \param p_exception an initialized exception 
    214  */ 
    215 void libvlc_playlist_prev( libvlc_instance_t *, libvlc_exception_t * ); 
    216  
    217 /** 
    218206 * Add an item at the end of the playlist 
    219207 * If you need more advanced options, \see libvlc_playlist_add_extended 
     
    233221 * \param i_options the number of options to add 
    234222 * \param ppsz_options strings representing the options to add 
     223 * \param p_exception an initialized exception 
    235224 * \return the identifier of the new item 
    236225 */ 
     
    239228                                  libvlc_exception_t * ); 
    240229 
    241  
     230/**  
     231 * Delete the playlist item with the given ID. 
     232 * \param p_instance the instance 
     233 * \param i_id the id to remove 
     234 * \param p_exception an initialized exception 
     235 * \return 
     236 */ 
    242237int libvlc_playlist_delete_item( libvlc_instance_t *, int, 
    243238                                 libvlc_exception_t * ); 
     
    252247libvlc_input_t *libvlc_playlist_get_input( libvlc_instance_t *, 
    253248                                           libvlc_exception_t * ); 
    254  
    255  
    256249 
    257250/** @}*/ 
     
    278271void        libvlc_input_set_position   ( libvlc_input_t *, float, libvlc_exception_t *); 
    279272vlc_bool_t  libvlc_input_will_play      ( libvlc_input_t *, libvlc_exception_t *); 
     273         
     274/** @} */ 
     275 
     276/** defgroup libvlc_video Video 
     277 * \ingroup libvlc 
     278 * LibVLC Video handling 
     279 * @{ 
     280 */ 
     281 
     282/** 
     283 * Does this input have a video output ? 
     284 * \param p_input the input 
     285 * \param p_exception an initialized exception 
     286 */ 
    280287vlc_bool_t  libvlc_input_has_vout       ( libvlc_input_t *, libvlc_exception_t *); 
    281288float       libvlc_input_get_fps        ( libvlc_input_t *, libvlc_exception_t *); 
    282          
    283 /** @} */ 
    284  
    285 /** defgroup libvlc_video Video 
    286  * \ingroup libvlc 
    287  * LibVLC Video handling 
    288  * @{ 
    289  */ 
    290289 
    291290/** 
     
    475474                           libvlc_exception_t *); 
    476475 
    477  
    478  
    479476/** 
    480477 * Set output for a media 
  • src/control/audio.c

    r9781b84 r44de024  
    3232 *****************************************************************************/ 
    3333void libvlc_audio_toggle_mute( libvlc_instance_t *p_instance, 
    34                                libvlc_exception_t *p_exception
     34                               libvlc_exception_t *p_e
    3535{ 
    3636    aout_VolumeMute( p_instance->p_vlc, NULL ); 
     
    3838 
    3939vlc_bool_t libvlc_audio_get_mute( libvlc_instance_t *p_instance, 
    40                                   libvlc_exception_t *p_exception
     40                                  libvlc_exception_t *p_e
    4141{ 
    4242    /* 
     
    4545    audio_volume_t i_volume; 
    4646 
    47     i_volume = libvlc_audio_get_volume(p_instance, p_exception); 
     47    i_volume = libvlc_audio_get_volume(p_instance, p_e); 
    4848    if ( i_volume == 0 ) 
    4949        return VLC_TRUE; 
    50  
    5150    return VLC_FALSE; 
    5251} 
    5352 
    5453void libvlc_audio_set_mute( libvlc_instance_t *p_instance, vlc_bool_t status, 
    55                             libvlc_exception_t *p_exception
     54                            libvlc_exception_t *p_e
    5655{ 
    5756    if ( status ) 
    5857    { 
    59         /* 
    60          * Check if the volume is already muted 
    61          */ 
    62         if (! libvlc_audio_get_volume( p_instance, p_exception ) ) 
     58        /* Check if the volume is already muted */ 
     59        if (! libvlc_audio_get_volume( p_instance, p_e ) ) 
    6360        { 
    6461            return; 
    6562        } 
    66          
    6763        aout_VolumeMute( p_instance->p_vlc, NULL ); 
    68         return; 
    69          
    7064    } 
    7165    else 
    7266    { 
    73         /* 
    74          * the aout_VolumeMute is a toggle function, so this is enough. 
    75          */ 
     67        /* the aout_VolumeMute is a toggle function, so this is enough. */ 
    7668        aout_VolumeMute( p_instance->p_vlc, NULL ); 
    77         return; 
    7869    } 
    7970} 
    80  
    8171 
    8272/***************************************************************************** 
     
    8474 *****************************************************************************/ 
    8575int libvlc_audio_get_volume( libvlc_instance_t *p_instance, 
    86                              libvlc_exception_t *p_exception
     76                             libvlc_exception_t *p_e
    8777{ 
    8878    audio_volume_t i_volume; 
     
    9888 *****************************************************************************/ 
    9989void libvlc_audio_set_volume( libvlc_instance_t *p_instance, int i_volume, 
    100                               libvlc_exception_t *p_exception
     90                              libvlc_exception_t *p_e
    10191{ 
    10292    if( i_volume >= 0 && i_volume <= 200 ) 
     
    10797    else 
    10898    { 
    109         libvlc_exception_raise( p_exception, "Volume out of range" ); 
     99        libvlc_exception_raise( p_e, "Volume out of range" ); 
    110100    } 
    111101} 
  • src/control/core.c

    rde277e8 r44de024  
    6464 
    6565    /* does caller care about exceptions ? */ 
    66     if( p_exception == NULL ) 
    67        return; 
     66    if( p_exception == NULL ) return; 
    6867 
    6968    /* remove previous exception if it wasn't cleared */ 
    7069    if( p_exception->b_raised && p_exception->psz_message ) 
    7170    { 
    72        free(p_exception->psz_message); 
    73        p_exception->psz_message = NULL; 
     71        free(p_exception->psz_message); 
     72        p_exception->psz_message = NULL; 
    7473    } 
    7574 
     
    8281 
    8382libvlc_instance_t * libvlc_new( int argc, char **argv, 
    84                                 libvlc_exception_t *p_exception
     83                                libvlc_exception_t *p_e
    8584{ 
    8685    int i_vlc_id; 
     
    9190    p_vlc = (vlc_t* ) vlc_current_object( i_vlc_id ); 
    9291 
    93     if( !p_vlc ) 
    94     { 
    95         libvlc_exception_raise( p_exception, "VLC initialization failed" ); 
    96         return NULL; 
    97     } 
     92    if( !p_vlc ) RAISENULL( "VLC initialization failed" ); 
     93 
    9894    p_new = (libvlc_instance_t *)malloc( sizeof( libvlc_instance_t ) ); 
     95    if( !p_new ) RAISENULL( "Out of memory" ); 
    9996 
    10097    /** \todo Look for interface settings. If we don't have any, add -I dummy */ 
    10198    /* Because we probably don't want a GUI by default */ 
    10299 
    103     if( !p_new ) 
    104     { 
    105         libvlc_exception_raise( p_exception, "Out of memory" ); 
    106         return NULL; 
    107     } 
    108100 
    109101    VLC_Init( i_vlc_id, argc, argv ); 
     
    114106    p_new->p_vlm = NULL; 
    115107 
    116     if( !p_new->p_playlist ) 
    117     { 
    118         libvlc_exception_raise( p_exception, "Playlist creation failed" ); 
    119         return NULL; 
    120     } 
     108    if( !p_new->p_playlist ) RAISENULL( "Playlist creation failed" ); 
     109     
    121110    p_new->i_vlc_id = i_vlc_id; 
    122  
    123111    return p_new; 
    124112} 
     
    137125    return p_instance->i_vlc_id; 
    138126} 
    139  
  • src/control/input.c

    r8914d39 r44de024  
    3030void libvlc_input_free( libvlc_input_t *p_input ) 
    3131{ 
    32     if( p_input ) 
    33         free( p_input ); 
     32    if( p_input ) free( p_input ); 
    3433} 
    3534 
     
    4342    input_thread_t *p_input_thread; 
    4443 
    45     if( !p_input ) 
    46     { 
    47         libvlc_exception_raise( p_e, "Input is NULL" ); 
    48         return NULL; 
    49     } 
     44    if( !p_input ) RAISENULL( "Input is NULL" ); 
    5045 
    5146    p_input_thread = (input_thread_t*)vlc_object_get( 
    52                                  p_input->p_instance->p_vlc, 
    53                                  p_input->i_input_id ); 
    54     if( !p_input_thread ) 
    55     { 
    56         libvlc_exception_raise( p_e, "Input does not exist" ); 
    57         return NULL; 
    58     } 
     47                                                    p_input->p_instance->p_vlc, 
     48                                                    p_input->i_input_id ); 
     49    if( !p_input_thread ) RAISENULL( "Input does not exist" ); 
    5950 
    6051    return p_input_thread; 
     
    6758 **************************************************************************/ 
    6859vlc_int64_t libvlc_input_get_length( libvlc_input_t *p_input, 
    69                              libvlc_exception_t *p_exception
     60                             libvlc_exception_t *p_e
    7061{ 
    7162    input_thread_t *p_input_thread; 
    7263    vlc_value_t val; 
    7364 
    74     p_input_thread = libvlc_get_input_thread ( p_input, p_exception); 
    75  
    76     if ( libvlc_exception_raised( p_exception ) ) 
    77         return -1.0; 
     65    p_input_thread = libvlc_get_input_thread ( p_input, p_e); 
     66    if( libvlc_exception_raised( p_e ) )  return -1.0; 
    7867        
    7968    var_Get( p_input_thread, "length", &val ); 
     
    8473 
    8574vlc_int64_t libvlc_input_get_time( libvlc_input_t *p_input, 
    86                            libvlc_exception_t *p_exception
     75                                   libvlc_exception_t *p_e
    8776{ 
    8877    input_thread_t *p_input_thread; 
    8978    vlc_value_t val; 
    9079 
    91  
    92     p_input_thread = libvlc_get_input_thread ( p_input, p_exception); 
    93  
    94     if ( libvlc_exception_raised( p_exception ) ) 
    95         return -1.0; 
     80    p_input_thread = libvlc_get_input_thread ( p_input, p_e ); 
     81    if( libvlc_exception_raised( p_e ) )  return -1.0; 
    9682 
    9783    var_Get( p_input_thread , "time", &val ); 
    9884    vlc_object_release( p_input_thread ); 
    99  
    10085    return val.i_time / 1000; 
    10186} 
    10287 
    103 void libvlc_input_set_time( libvlc_input_t *p_input, vlc_int64_t time, libvlc_exception_t *p_exception ) 
     88void libvlc_input_set_time( libvlc_input_t *p_input, vlc_int64_t time, 
     89                            libvlc_exception_t *p_e ) 
    10490{ 
    10591    input_thread_t *p_input_thread; 
    10692    vlc_value_t value; 
    10793 
    108     p_input_thread = libvlc_get_input_thread ( p_input, p_exception); 
    109  
    110     if ( libvlc_exception_raised( p_exception ) ) 
    111         return; 
     94    p_input_thread = libvlc_get_input_thread ( p_input, p_e ); 
     95    if( libvlc_exception_raised( p_e ) )  return; 
    11296     
    11397    value.i_time = time; 
    11498    var_Set( p_input_thread, "time", value ); 
    11599    vlc_object_release( p_input_thread ); 
    116  
    117     return; 
    118      
    119100} 
    120101 
    121 void libvlc_input_set_position( libvlc_input_t *p_input, float position, libvlc_exception_t *p_exception )  
     102void libvlc_input_set_position( libvlc_input_t *p_input, float position, 
     103                                libvlc_exception_t *p_e )  
     104
     105    input_thread_t *p_input_thread; 
     106    vlc_value_t val; 
     107    val.f_float = position; 
     108     
     109    p_input_thread = libvlc_get_input_thread ( p_input, p_e); 
     110    if ( libvlc_exception_raised( p_e ) ) return; 
     111 
     112    var_Set( p_input_thread, "position", val ); 
     113    vlc_object_release( p_input_thread ); 
     114
     115 
     116float libvlc_input_get_position( libvlc_input_t *p_input, 
     117                                 libvlc_exception_t *p_e ) 
    122118{ 
    123119    input_thread_t *p_input_thread; 
    124120    vlc_value_t val; 
    125121 
    126     val.f_float = position; 
    127      
    128     p_input_thread = libvlc_get_input_thread ( p_input, p_exception); 
    129  
    130     if ( libvlc_exception_raised( p_exception ) ) 
    131         return; 
    132  
    133     var_Set( p_input_thread, "position", val ); 
    134     vlc_object_release( p_input_thread ); 
    135  
    136     return; 
    137  
    138 
    139  
    140  
    141  
    142 float libvlc_input_get_position( libvlc_input_t *p_input, 
    143                                  libvlc_exception_t *p_exception ) 
    144 
    145     input_thread_t *p_input_thread; 
    146     vlc_value_t val; 
    147  
    148     p_input_thread = libvlc_get_input_thread ( p_input, p_exception); 
    149  
    150     if ( libvlc_exception_raised( p_exception ) ) 
    151         return -1.0; 
     122    p_input_thread = libvlc_get_input_thread ( p_input, p_e); 
     123    if ( libvlc_exception_raised( p_e ) )  return -1.0; 
    152124 
    153125    var_Get( p_input_thread, "position", &val ); 
     
    158130 
    159131float libvlc_input_get_fps( libvlc_input_t *p_input, 
    160                             libvlc_exception_t *p_exception)  
     132                            libvlc_exception_t *p_e)  
    161133{ 
    162134    double f_fps; 
    163135    input_thread_t *p_input_thread; 
    164136 
    165     p_input_thread = libvlc_get_input_thread ( p_input, p_exception); 
     137    p_input_thread = libvlc_get_input_thread ( p_input, p_e ); 
     138    if ( libvlc_exception_raised( p_e ) )  return 0.0; 
    166139 
    167     if( demux2_Control( p_input_thread->input.p_demux, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1 )  
     140    if( demux2_Control( p_input_thread->input.p_demux, DEMUX_GET_FPS, &f_fps ) 
     141        || f_fps < 0.1 )  
    168142    { 
    169143        vlc_object_release( p_input_thread ); 
    170         return 0
     144        return 0.0
    171145    } 
    172146    else 
     
    178152 
    179153vlc_bool_t libvlc_input_will_play( libvlc_input_t *p_input, 
    180                                    libvlc_exception_t *p_exception)  
     154                                   libvlc_exception_t *p_e)  
    181155{ 
    182     input_thread_t *p_input_thread; 
    183  
    184     p_input_thread = libvlc_get_input_thread ( p_input, p_exception); 
    185  
    186     if ( libvlc_exception_raised( p_exception ) ) 
    187         return VLC_FALSE; 
     156    input_thread_t *p_input_thread = 
     157                            libvlc_get_input_thread ( p_input, p_e); 
     158    if ( libvlc_exception_raised( p_e ) ) return VLC_FALSE; 
    188159 
    189160    if ( !p_input_thread->b_die && !p_input_thread->b_dead )  
     
    192163        return VLC_TRUE; 
    193164    } 
    194      
    195165    vlc_object_release( p_input_thread ); 
    196166    return VLC_FALSE; 
  • src/control/playlist.c

    r3398355 r44de024  
    2929void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id, 
    3030                           int i_options, char **ppsz_options, 
    31                            libvlc_exception_t *p_exception
     31                           libvlc_exception_t *p_e
    3232{ 
     33    assert( p_instance->p_playlist ); 
    3334    ///\todo Handle additionnal options 
    3435 
    35     if( p_instance->p_playlist->i_size == 0 ) 
    36     { 
    37         libvlc_exception_raise( p_exception, "Empty playlist" ); 
    38         return; 
    39     } 
     36    if( p_instance->p_playlist->i_size == 0 ) RAISEVOID( "Empty playlist" ); 
    4037    if( i_id > 0 ) 
    4138    { 
    42         playlist_item_t *p_item = playlist_ItemGetById( p_instance->p_playlist, i_id ); 
     39        playlist_item_t *p_item = playlist_ItemGetById( p_instance->p_playlist, 
     40                                                        i_id ); 
     41        if( !p_item ) RAISEVOID( "Unable to find item" ); 
    4342 
    44         if( !p_item ) 
    45         { 
    46             libvlc_exception_raise( p_exception, "Unable to find item " ); 
    47             return; 
    48         } 
    4943        playlist_LockControl( p_instance->p_playlist, PLAYLIST_VIEWPLAY, 
    5044                          p_instance->p_playlist->status.p_node, p_item ); 
     
    5751 
    5852void libvlc_playlist_pause( libvlc_instance_t *p_instance, 
    59                            libvlc_exception_t *p_exception
     53                           libvlc_exception_t *p_e
    6054{ 
     55    assert( p_instance->p_playlist ); 
    6156    if( playlist_Pause( p_instance->p_playlist ) != VLC_SUCCESS ) 
    62     { 
    63         libvlc_exception_raise( p_exception, "Empty playlist" ); 
    64     } 
     57        RAISEVOID( "Empty playlist" ); 
    6558} 
    6659 
    6760 
    6861void libvlc_playlist_stop( libvlc_instance_t *p_instance, 
    69                            libvlc_exception_t *p_exception
     62                           libvlc_exception_t *p_e
    7063{ 
     64    assert( p_instance->p_playlist ); 
    7165    if( playlist_Stop( p_instance->p_playlist ) != VLC_SUCCESS ) 
    72     { 
    73         libvlc_exception_raise( p_exception, "Empty playlist" ); 
    74     } 
     66        RAISEVOID( "Empty playlist" ); 
    7567} 
    7668 
    7769void libvlc_playlist_clear( libvlc_instance_t *p_instance, 
    78                            libvlc_exception_t *p_exception
     70                           libvlc_exception_t *p_e
    7971{ 
     72    assert( p_instance->p_playlist ); 
    8073    playlist_Clear( p_instance->p_playlist ); 
    8174} 
    8275 
    8376void libvlc_playlist_next( libvlc_instance_t *p_instance, 
    84                            libvlc_exception_t *p_exception
     77                           libvlc_exception_t *p_e
    8578{ 
     79    assert( p_instance->p_playlist ); 
    8680    if( playlist_Next( p_instance->p_playlist ) != VLC_SUCCESS ) 
    87     { 
    88         libvlc_exception_raise( p_exception, "Empty playlist" ); 
    89     } 
     81        RAISEVOID( "Empty playlist" ); 
    9082} 
    9183 
    9284void libvlc_playlist_prev( libvlc_instance_t *p_instance, 
    93                            libvlc_exception_t *p_exception
     85                           libvlc_exception_t *p_e
    9486{ 
    9587    if( playlist_Prev( p_instance->p_playlist ) != VLC_SUCCESS ) 
    96     { 
    97         libvlc_exception_raise( p_exception, "Empty playlist" ); 
    98     } 
     88        RAISEVOID( "Empty playlist" ); 
    9989} 
    10090 
    10191int libvlc_playlist_add( libvlc_instance_t *p_instance, const char *psz_uri, 
    102                          const char *psz_name, libvlc_exception_t *p_exception
     92                         const char *psz_name, libvlc_exception_t *p_e
    10393{ 
    10494    return libvlc_playlist_add_extended( p_instance, psz_uri, psz_name, 
    105                                          0, NULL, p_exception ); 
     95                                         0, NULL, p_e ); 
    10696} 
    10797 
     
    10999                                  const char *psz_uri, const char *psz_name, 
    110100                                  int i_options, const char **ppsz_options, 
    111                                   libvlc_exception_t *p_exception
     101                                  libvlc_exception_t *p_e
    112102{ 
     103    assert( p_instance->p_playlist ); 
    113104    return playlist_PlaylistAddExt( p_instance->p_playlist, psz_uri, psz_name, 
    114105                            PLAYLIST_INSERT, PLAYLIST_END, -1, ppsz_options, 
     
    117108 
    118109int libvlc_playlist_delete_item( libvlc_instance_t *p_instance, int i_id, 
    119                                  libvlc_exception_t *p_exception
     110                                 libvlc_exception_t *p_e
    120111{ 
     112    assert( p_instance->p_playlist ); 
    121113    return playlist_DeleteFromItemId( p_instance->p_playlist, i_id ); 
    122114} 
     
    124116 
    125117int libvlc_playlist_isplaying( libvlc_instance_t *p_instance, 
    126                                libvlc_exception_t *p_exception
     118                               libvlc_exception_t *p_e
    127119{ 
    128     if( !p_instance->p_playlist ) 
    129     { 
    130         libvlc_exception_raise( p_exception, "No playlist" ); 
    131         return 0; 
    132     } 
     120    assert( p_instance->p_playlist ); 
    133121    return playlist_IsPlaying( p_instance->p_playlist ); 
    134122} 
    135123 
    136124int libvlc_playlist_items_count( libvlc_instance_t *p_instance, 
    137                                  libvlc_exception_t *p_exception
     125                                 libvlc_exception_t *p_e
    138126{ 
    139     if( !p_instance->p_playlist ) 
    140     { 
    141         libvlc_exception_raise( p_exception, "No playlist" ); 
    142         return 0; 
    143     } 
     127    assert( p_instance->p_playlist ); 
    144128    return p_instance->p_playlist->i_size; 
    145129} 
    146130 
    147131libvlc_input_t * libvlc_playlist_get_input( libvlc_instance_t *p_instance, 
    148                                             libvlc_exception_t *p_exception
     132                                            libvlc_exception_t *p_e
    149133{ 
    150134    libvlc_input_t *p_input; 
     135    assert( p_instance->p_playlist ); 
    151136 
    152137    vlc_mutex_lock( &p_instance->p_playlist->object_lock ); 
    153138    if( p_instance->p_playlist->p_input == NULL ) 
    154139    { 
    155         libvlc_exception_raise( p_exception, "No active input" ); 
     140        libvlc_exception_raise( p_e, "No active input" ); 
    156141        vlc_mutex_unlock( &p_instance->p_playlist->object_lock ); 
    157142        return NULL;