Changeset 06996317f9c056ba12188a797ba38444ddcc782c

Show
Ignore:
Timestamp:
31/08/02 01:27:06 (6 years ago)
Author:
Christophe Massiot <massiot@videolan.org>
git-committer:
Christophe Massiot <massiot@videolan.org> 1030750026 +0000
git-parent:

[0b88e7753a08b42a15d6e01cae20bfeed192d56a]

git-author:
Christophe Massiot <massiot@videolan.org> 1030750026 +0000
Message:

aout3 API change :
pf_setformat disappears (it was never called independantly of Open). If
the format needs to be changed, we will have Close/Open. This is much
simpler than before. Please check that I didn't break some plug-ins.

Files:

Legend:

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

    r0b88e77 r0699631  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: aout_internal.h,v 1.13 2002/08/30 22:22:24 massiot Exp $ 
     5 * $Id: aout_internal.h,v 1.14 2002/08/30 23:27:05 massiot Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    159159    struct module_t *       p_module; 
    160160    struct aout_sys_t *     p_sys; 
    161     int                  (* pf_setformat)( aout_instance_t * ); 
    162161    void                 (* pf_play)( aout_instance_t * ); 
    163162    int                     i_nb_samples; 
  • modules/audio_output/alsa.c

    r7d2f6de r0699631  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000-2001 VideoLAN 
    5  * $Id: alsa.c,v 1.9 2002/08/29 23:53:22 massiot Exp $ 
     5 * $Id: alsa.c,v 1.10 2002/08/30 23:27:06 massiot Exp $ 
    66 * 
    77 * Authors: Henri Fallon <henri@videolan.org> - Original Author 
     
    5353    int                 i_period_time; 
    5454 
    55     volatile vlc_bool_t b_initialized; 
    56  
    5755    volatile vlc_bool_t b_can_sleek; 
    5856 
     
    7876static int  Open         ( vlc_object_t * ); 
    7977static void Close        ( vlc_object_t * ); 
    80  
    81 static int  SetFormat    ( aout_instance_t * ); 
    8278static void Play         ( aout_instance_t * ); 
    83  
    8479static int  ALSAThread   ( aout_instance_t * ); 
    8580static void ALSAFill     ( aout_instance_t * ); 
     
    106101    struct aout_sys_t * p_sys; 
    107102 
     103    int i_snd_rc; 
     104 
     105    char * psz_device; 
     106    char psz_alsadev[128]; 
     107    char * psz_userdev; 
     108 
     109    int i_format; 
     110    int i_channels; 
     111 
     112    snd_pcm_hw_params_t *p_hw; 
     113    snd_pcm_sw_params_t *p_sw; 
     114 
    108115    /* Allocate structures */ 
    109116    p_aout->output.p_sys = p_sys = malloc( sizeof( aout_sys_t ) ); 
     
    114121    } 
    115122 
    116     /* Create ALSA thread and wait for its readiness. */ 
    117     p_sys->b_initialized = VLC_FALSE; 
    118     if( vlc_thread_create( p_aout, "aout", ALSAThread, 
    119                            VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) ) 
    120     { 
    121         msg_Err( p_aout, "cannot create ALSA thread (%s)", strerror(errno) ); 
    122         free( p_sys ); 
    123         return -1; 
    124     } 
    125  
    126     p_aout->output.pf_setformat = SetFormat; 
    127123    p_aout->output.pf_play = Play; 
    128124 
     
    130126    snd_output_stdio_attach( &p_sys->p_snd_stderr, stderr, 0 ); 
    131127#endif 
    132  
    133     return 0; 
    134 } 
    135  
    136 /***************************************************************************** 
    137  * SetFormat : sets the alsa output format 
    138  ***************************************************************************** 
    139  * This function prepares the device, sets the rate, format, the mode 
    140  * ( "play as soon as you have data" ), and buffer information. 
    141  *****************************************************************************/ 
    142 static int SetFormat( aout_instance_t * p_aout ) 
    143 { 
    144     struct aout_sys_t * p_sys = p_aout->output.p_sys; 
    145  
    146     int i_snd_rc; 
    147  
    148     char * psz_device; 
    149     char psz_alsadev[128]; 
    150     char * psz_userdev; 
    151  
    152     int i_format; 
    153     int i_channels; 
    154  
    155     snd_pcm_hw_params_t *p_hw; 
    156     snd_pcm_sw_params_t *p_sw; 
    157128 
    158129    /* Read in ALSA device preferences from configuration */ 
     
    335306#endif 
    336307 
    337     p_sys->b_initialized = VLC_TRUE; 
     308    /* Create ALSA thread and wait for its readiness. */ 
     309    if( vlc_thread_create( p_aout, "aout", ALSAThread, 
     310                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) ) 
     311    { 
     312        msg_Err( p_aout, "cannot create ALSA thread (%s)", strerror(errno) ); 
     313        free( p_sys ); 
     314        return -1; 
     315    } 
    338316 
    339317    return 0; 
     
    341319 
    342320/***************************************************************************** 
    343  * Play: queue a buffer for playing by ALSAThread 
     321 * Play: nothing to do 
    344322 *****************************************************************************/ 
    345323static void Play( aout_instance_t *p_aout ) 
     
    383361{ 
    384362    struct aout_sys_t * p_sys = p_aout->output.p_sys; 
    385  
    386     while ( !p_aout->b_die && !p_sys->b_initialized ) 
    387         msleep( THREAD_SLEEP ); 
    388363 
    389364    while ( !p_aout->b_die ) 
  • modules/audio_output/arts.c

    r7d2f6de r0699631  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001-2002 VideoLAN 
     5 * $Id: arts.c,v 1.10 2002/08/30 23:27:06 massiot Exp $ 
    56 * 
    67 * Authors: Emmanuel Blindauer <manu@agat.net> 
     
    4748{ 
    4849    arts_stream_t stream; 
    49     vlc_bool_t    b_initialized; 
    5050 
    5151    mtime_t       latency; 
     
    5858static int  Open         ( vlc_object_t * ); 
    5959static void Close        ( vlc_object_t * ); 
    60  
    61 static int  SetFormat    ( aout_instance_t * ); 
    6260static void Play         ( aout_instance_t * ); 
    6361static int  aRtsThread   ( aout_instance_t * ); 
     
    8886        return -1; 
    8987    } 
     88    p_aout->output.p_sys = p_sys; 
    9089 
    9190    i_err = arts_init(); 
     
    9897    } 
    9998 
    100     p_aout->output.p_sys = p_sys; 
    101  
    102     /* Create aRts thread and wait for its readiness. */ 
    103     p_sys->b_initialized = VLC_FALSE; 
    104     if( vlc_thread_create( p_aout, "aout", aRtsThread, 
    105                            VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) ) 
    106     { 
    107         msg_Err( p_aout, "cannot create aRts thread (%s)", strerror(errno) ); 
    108         free( p_sys ); 
    109         return -1; 
    110     } 
    111  
    112     p_aout->output.pf_setformat = SetFormat; 
    11399    p_aout->output.pf_play = Play; 
    114100 
    115101    p_sys->stream = NULL; 
    116  
    117     return 0; 
    118 } 
    119  
    120 /***************************************************************************** 
    121  * SetFormat: set the output format 
    122  *****************************************************************************/ 
    123 static int SetFormat( aout_instance_t *p_aout ) 
    124 { 
    125     struct aout_sys_t * p_sys = p_aout->output.p_sys; 
    126  
    127     p_sys->b_initialized = VLC_FALSE; 
    128102 
    129103    if( p_sys->stream ) 
     
    153127    p_aout->output.i_nb_samples = p_sys->i_size; 
    154128 
    155     p_sys->b_initialized = VLC_TRUE; 
     129    /* Create aRts thread and wait for its readiness. */ 
     130    if( vlc_thread_create( p_aout, "aout", aRtsThread, 
     131                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) ) 
     132    { 
     133        msg_Err( p_aout, "cannot create aRts thread (%s)", strerror(errno) ); 
     134        free( p_sys ); 
     135        return -1; 
     136    } 
    156137 
    157138    return 0; 
     
    159140 
    160141/***************************************************************************** 
    161  * Play: queue a buffer for playing by aRtsThread 
     142 * Play: nothing to do 
    162143 *****************************************************************************/ 
    163144static void Play( aout_instance_t *p_aout ) 
     
    198179        int i_tmp, i_size; 
    199180        byte_t * p_bytes; 
    200  
    201         if( !p_sys->b_initialized ) 
    202         { 
    203             msleep( THREAD_SLEEP ); 
    204             continue; 
    205         } 
    206181 
    207182        /* Get the presentation date of the next write() operation. It 
  • modules/audio_output/esd.c

    r7d2f6de r0699631  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000, 2001 VideoLAN 
    5  * $Id: esd.c,v 1.11 2002/08/29 23:53:22 massiot Exp $ 
     5 * $Id: esd.c,v 1.12 2002/08/30 23:27:06 massiot Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    4747    esd_format_t esd_format; 
    4848    int          i_fd; 
    49     vlc_bool_t   b_initialized; 
    5049 
    5150    mtime_t      latency; 
     
    5756static int  Open         ( vlc_object_t * ); 
    5857static void Close        ( vlc_object_t * ); 
    59  
    60 static int  SetFormat    ( aout_instance_t * ); 
    6158static void Play         ( aout_instance_t * ); 
    6259static int  ESDThread    ( aout_instance_t * ); 
     
    9087    p_aout->output.p_sys = p_sys; 
    9188 
    92     /* Create ESD thread and wait for its readiness. */ 
    93     p_sys->b_initialized = VLC_FALSE; 
    94     if( vlc_thread_create( p_aout, "aout", ESDThread, 
    95                            VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) ) 
    96     { 
    97         msg_Err( p_aout, "cannot create ESD thread (%s)", strerror(errno) ); 
    98         free( p_sys ); 
    99         return -1; 
    100     } 
    101  
    102     p_aout->output.pf_setformat = SetFormat; 
    10389    p_aout->output.pf_play = Play; 
    104  
    105     return( 0 ); 
    106 } 
    107  
    108 /***************************************************************************** 
    109  * SetFormat: set the output format 
    110  *****************************************************************************/ 
    111 static int SetFormat( aout_instance_t *p_aout ) 
    112 { 
    113     struct aout_sys_t * p_sys = p_aout->output.p_sys; 
    114  
    115     p_sys->b_initialized = VLC_FALSE; 
    11690 
    11791    /* Initialize some variables */ 
     
    156130      / p_aout->output.output.i_rate; 
    157131 
    158     p_sys->b_initialized = VLC_TRUE; 
     132    /* Create ESD thread and wait for its readiness. */ 
     133    if( vlc_thread_create( p_aout, "aout", ESDThread, 
     134                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) ) 
     135    { 
     136        msg_Err( p_aout, "cannot create ESD thread (%s)", strerror(errno) ); 
     137        free( p_sys ); 
     138        return -1; 
     139    } 
    159140 
    160141    return 0; 
     
    162143 
    163144/***************************************************************************** 
    164  * Play: queue a buffer for playing by ESDThread 
     145 * Play: nothing to do 
    165146 *****************************************************************************/ 
    166147static void Play( aout_instance_t *p_aout ) 
     
    195176        int i_tmp, i_size; 
    196177        byte_t * p_bytes; 
    197  
    198         if( !p_sys->b_initialized ) 
    199         { 
    200             msleep( THREAD_SLEEP ); 
    201             continue; 
    202         } 
    203178 
    204179        /* Get the presentation date of the next write() operation. It 
  • modules/audio_output/file.c

    r0b88e77 r0699631  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: file.c,v 1.9 2002/08/30 22:22:24 massiot Exp $ 
     5 * $Id: file.c,v 1.10 2002/08/30 23:27:06 massiot Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    4242static int     Open        ( vlc_object_t * ); 
    4343static void    Close       ( vlc_object_t * ); 
    44 static int     SetFormat   ( aout_instance_t * ); 
    4544static void    Play        ( aout_instance_t * ); 
    4645 
     
    8382    FILE * p_file; 
    8483    char * psz_name = config_GetPsz( p_this, "path" ); 
     84    char * psz_format = config_GetPsz( p_aout, "format" ); 
     85    char ** ppsz_compare = format_list; 
     86    int i = 0; 
     87 
    8588 
    8689    p_file = fopen( psz_name, "wb" ); 
     
    8992    if ( p_file == NULL ) return -1; 
    9093 
    91     p_aout->output.pf_setformat = SetFormat; 
    9294    p_aout->output.pf_play = Play; 
    93  
    94     return VLC_SUCCESS; 
    95 } 
    96  
    97 /***************************************************************************** 
    98  * Close: close our file 
    99  *****************************************************************************/ 
    100 static void Close( vlc_object_t * p_this ) 
    101 { 
    102     aout_instance_t * p_aout = (aout_instance_t *)p_this; 
    103  
    104     fclose( (FILE *)p_aout->output.p_sys ); 
    105 } 
    106  
    107 /***************************************************************************** 
    108  * SetFormat: pretend to set the dsp output format 
    109  *****************************************************************************/ 
    110 static int SetFormat( aout_instance_t * p_aout ) 
    111 { 
    112     char * psz_format = config_GetPsz( p_aout, "format" ); 
    113     char ** ppsz_compare = format_list; 
    114     int i = 0; 
    11595 
    11696    while ( *ppsz_compare != NULL ) 
     
    145125 
    146126/***************************************************************************** 
     127 * Close: close our file 
     128 *****************************************************************************/ 
     129static void Close( vlc_object_t * p_this ) 
     130{ 
     131    aout_instance_t * p_aout = (aout_instance_t *)p_this; 
     132 
     133    fclose( (FILE *)p_aout->output.p_sys ); 
     134} 
     135 
     136/***************************************************************************** 
    147137 * Play: pretend to play a sound 
    148138 *****************************************************************************/ 
  • modules/audio_output/oss.c

    r7d2f6de r0699631  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000-2002 VideoLAN 
    5  * $Id: oss.c,v 1.20 2002/08/29 23:53:22 massiot Exp $ 
     5 * $Id: oss.c,v 1.21 2002/08/30 23:27:06 massiot Exp $ 
    66 * 
    77 * Authors: Michel Kaempf <maxx@via.ecp.fr> 
     
    6363{ 
    6464    int                   i_fd; 
    65     volatile vlc_bool_t   b_initialized; 
    6665}; 
    6766 
     
    7675static void Close        ( vlc_object_t * ); 
    7776 
    78 static int  SetFormat    ( aout_instance_t * ); 
    7977static void Play         ( aout_instance_t * ); 
    8078static int  OSSThread    ( aout_instance_t * ); 
     
    103101    struct aout_sys_t * p_sys; 
    104102    char * psz_device; 
     103    int i_format; 
     104    int i_rate; 
     105    int i_fragments; 
     106    vlc_bool_t b_stereo; 
    105107 
    106108    /* Allocate structure */ 
     
    130132    free( psz_device ); 
    131133 
     134    p_aout->output.pf_play = Play; 
     135 
     136    /* Reset the DSP device */ 
     137    if( ioctl( p_sys->i_fd, SNDCTL_DSP_RESET, NULL ) < 0 ) 
     138    { 
     139        msg_Err( p_aout, "cannot reset OSS audio device" ); 
     140        return VLC_EGENERIC; 
     141    } 
     142 
     143    /* Set the fragment size */ 
     144    i_fragments = FRAME_COUNT << 16 | FRAME_SIZE; 
     145    if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFRAGMENT, &i_fragments ) < 0 ) 
     146    { 
     147        msg_Err( p_aout, "cannot set fragment size (%.8x)", i_fragments ); 
     148        return VLC_EGENERIC; 
     149    } 
     150 
     151    /* Set the output format */ 
     152    if ( p_aout->output.output.i_format == AOUT_FMT_SPDIF ) 
     153    { 
     154        i_format = AOUT_FMT_SPDIF; 
     155        p_aout->output.i_nb_samples = A52_FRAME_NB; 
     156        p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; 
     157        p_aout->output.output.i_frame_length = A52_FRAME_NB; 
     158    } 
     159    else 
     160    { 
     161        p_aout->output.output.i_format = i_format = AOUT_FMT_S16_NE; 
     162        p_aout->output.i_nb_samples = FRAME_SIZE; 
     163    } 
     164 
     165    if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 
     166         || i_format != p_aout->output.output.i_format ) 
     167    { 
     168        msg_Err( p_aout, "cannot set audio output format (%i)", i_format ); 
     169        return VLC_EGENERIC; 
     170    } 
     171 
     172    if ( p_aout->output.output.i_format != AOUT_FMT_SPDIF ) 
     173    { 
     174        /* FIXME */ 
     175        if ( p_aout->output.output.i_channels > 2 ) 
     176        { 
     177            msg_Warn( p_aout, "only two channels are supported at the moment" ); 
     178            /* Trigger downmixing */ 
     179            p_aout->output.output.i_channels = 2; 
     180        } 
     181 
     182        /* Set the number of channels */ 
     183        b_stereo = p_aout->output.output.i_channels - 1; 
     184 
     185        if( ioctl( p_sys->i_fd, SNDCTL_DSP_STEREO, &b_stereo ) < 0 ) 
     186        { 
     187            msg_Err( p_aout, "cannot set number of audio channels (%i)", 
     188                              p_aout->output.output.i_channels ); 
     189            return VLC_EGENERIC; 
     190        } 
     191 
     192        if ( b_stereo + 1 != p_aout->output.output.i_channels ) 
     193        { 
     194            msg_Warn( p_aout, "driver forced up/downmixing %li->%li", 
     195                              p_aout->output.output.i_channels, 
     196                              b_stereo + 1 ); 
     197            p_aout->output.output.i_channels = b_stereo + 1; 
     198        } 
     199 
     200        /* Set the output rate */ 
     201        i_rate = p_aout->output.output.i_rate; 
     202        if( ioctl( p_sys->i_fd, SNDCTL_DSP_SPEED, &i_rate ) < 0 ) 
     203        { 
     204            msg_Err( p_aout, "cannot set audio output rate (%i)", 
     205                             p_aout->output.output.i_rate ); 
     206            return VLC_EGENERIC; 
     207        } 
     208 
     209        if( i_rate != p_aout->output.output.i_rate ) 
     210        { 
     211            msg_Warn( p_aout, "driver forced resampling %li->%li", 
     212                              p_aout->output.output.i_rate, i_rate ); 
     213            p_aout->output.output.i_rate = i_rate; 
     214        } 
     215    } 
     216 
    132217    /* Create OSS thread and wait for its readiness. */ 
    133     p_sys->b_initialized = VLC_FALSE; 
    134218    if( vlc_thread_create( p_aout, "aout", OSSThread, 
    135219                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) ) 
     
    142226    } 
    143227 
    144     p_aout->output.pf_setformat = SetFormat; 
    145     p_aout->output.pf_play = Play; 
    146  
    147228    return VLC_SUCCESS; 
    148229} 
    149230 
    150231/***************************************************************************** 
    151  * SetFormat: reset the dsp and set its format 
    152  ***************************************************************************** 
    153  * This functions resets the DSP device, tries to initialize the output 
    154  * format with the value contained in the dsp structure, and if this value 
    155  * could not be set, the default value returned by ioctl is set. It then 
    156  * does the same for the stereo mode, and for the output rate. 
    157  *****************************************************************************/ 
    158 static int SetFormat( aout_instance_t *p_aout ) 
    159 
    160     struct aout_sys_t * p_sys = p_aout->output.p_sys; 
    161     int i_format; 
    162     int i_rate; 
    163     int i_fragments; 
    164     vlc_bool_t b_stereo; 
    165  
    166     p_sys->b_initialized = VLC_FALSE; 
    167  
    168     /* Reset the DSP device */ 
    169     if( ioctl( p_sys->i_fd, SNDCTL_DSP_RESET, NULL ) < 0 ) 
    170     { 
    171         msg_Err( p_aout, "cannot reset OSS audio device" ); 
    172         return VLC_EGENERIC; 
    173     } 
    174  
    175     /* Set the fragment size */ 
    176     i_fragments = FRAME_COUNT << 16 | FRAME_SIZE; 
    177     if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFRAGMENT, &i_fragments ) < 0 ) 
    178     { 
    179         msg_Err( p_aout, "cannot set fragment size (%.8x)", i_fragments ); 
    180         return VLC_EGENERIC; 
    181     } 
    182  
    183     /* Set the output format */ 
    184     if ( p_aout->output.output.i_format == AOUT_FMT_SPDIF ) 
    185     { 
    186         i_format = AOUT_FMT_SPDIF; 
    187         p_aout->output.i_nb_samples = A52_FRAME_NB; 
    188         p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; 
    189         p_aout->output.output.i_frame_length = A52_FRAME_NB; 
    190     } 
    191     else 
    192     { 
    193         p_aout->output.output.i_format = i_format = AOUT_FMT_S16_NE; 
    194         p_aout->output.i_nb_samples = FRAME_SIZE; 
    195     } 
    196  
    197     if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 
    198          || i_format != p_aout->output.output.i_format ) 
    199     { 
    200         msg_Err( p_aout, "cannot set audio output format (%i)", i_format ); 
    201         return VLC_EGENERIC; 
    202     } 
    203  
    204     if ( p_aout->output.output.i_format != AOUT_FMT_SPDIF ) 
    205     { 
    206         /* FIXME */ 
    207         if ( p_aout->output.output.i_channels > 2 ) 
    208         { 
    209             msg_Warn( p_aout, "only two channels are supported at the moment" ); 
    210             /* Trigger downmixing */ 
    211             p_aout->output.output.i_channels = 2; 
    212         } 
    213  
    214         /* Set the number of channels */ 
    215         b_stereo = p_aout->output.output.i_channels - 1; 
    216  
    217         if( ioctl( p_sys->i_fd, SNDCTL_DSP_STEREO, &b_stereo ) < 0 ) 
    218         { 
    219             msg_Err( p_aout, "cannot set number of audio channels (%i)", 
    220                               p_aout->output.output.i_channels ); 
    221             return VLC_EGENERIC; 
    222         } 
    223  
    224         if ( b_stereo + 1 != p_aout->output.output.i_channels ) 
    225         { 
    226             msg_Warn( p_aout, "driver forced up/downmixing %li->%li", 
    227                               p_aout->output.output.i_channels, 
    228                               b_stereo + 1 ); 
    229             p_aout->output.output.i_channels = b_stereo + 1; 
    230         } 
    231  
    232         /* Set the output rate */ 
    233         i_rate = p_aout->output.output.i_rate; 
    234         if( ioctl( p_sys->i_fd, SNDCTL_DSP_SPEED, &i_rate ) < 0 ) 
    235         { 
    236             msg_Err( p_aout, "cannot set audio output rate (%i)", 
    237                              p_aout->output.output.i_rate ); 
    238             return VLC_EGENERIC; 
    239         } 
    240  
    241         if( i_rate != p_aout->output.output.i_rate ) 
    242         { 
    243             msg_Warn( p_aout, "driver forced resampling %li->%li", 
    244                               p_aout->output.output.i_rate, i_rate ); 
    245             p_aout->output.output.i_rate = i_rate; 
    246         } 
    247     } 
    248  
    249     p_sys->b_initialized = VLC_TRUE; 
    250  
    251     return VLC_SUCCESS; 
    252 
    253  
    254 /***************************************************************************** 
    255  * Play: queue a buffer for playing by OSSThread 
     232 * Play: nothing to do 
    256233 *****************************************************************************/ 
    257234static void Play( aout_instance_t *p_aout ) 
     
    319296        int i_tmp, i_size; 
    320297        byte_t * p_bytes; 
    321  
    322         if( !p_sys->b_initialized ) 
    323         { 
    324             msleep( THREAD_SLEEP ); 
    325             continue; 
    326         } 
    327298 
    328299        if ( p_aout->output.output.i_format != AOUT_FMT_SPDIF ) 
  • modules/audio_output/sdl.c

    r0b88e77 r0699631  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000-2002 VideoLAN 
    5  * $Id: sdl.c,v 1.8 2002/08/30 22:22:24 massiot Exp $ 
     5 * $Id: sdl.c,v 1.9 2002/08/30 23:27:06 massiot Exp $ 
    66 * 
    77 * Authors: Michel Kaempf <maxx@via.ecp.fr> 
     
    5858static int  Open        ( vlc_object_t * ); 
    5959static void Close       ( vlc_object_t * ); 
    60  
    61 static int  SetFormat   ( aout_instance_t * ); 
    6260static void Play        ( aout_instance_t * ); 
    63  
    6461static void SDLCallback ( void *, Uint8 *, int ); 
    6562 
     
    7976{ 
    8077    aout_instance_t *p_aout = (aout_instance_t *)p_this; 
     78    SDL_AudioSpec desired; 
    8179 
    8280    Uint32 i_flags = SDL_INIT_AUDIO; 
     
    107105    } 
    108106 
    109     return VLC_SUCCESS; 
    110 } 
    111  
    112 /***************************************************************************** 
    113  * SetFormat: reset the audio device and sets its format 
    114  *****************************************************************************/ 
    115 static int SetFormat( aout_instance_t *p_aout ) 
    116 { 
    117107    /* TODO: finish and clean this */ 
    118     SDL_AudioSpec desired; 
    119108 
    120109    desired.freq       = p_aout->output.output.i_rate; 
  • modules/audio_output/waveout.c

    r51e9975 r0699631  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: waveout.c,v 1.5 2002/08/25 09:40:00 sam Exp $ 
     5 * $Id: waveout.c,v 1.6 2002/08/30 23:27:06 massiot Exp $ 
    66 * 
    77 * Authors: Gildas Bazin <gbazin@netcourrier.com> 
     
    4444static int  Open         ( vlc_object_t * );              
    4545static void Close        ( vlc_object_t * );                    
    46  
    47 static int  SetFormat    ( aout_instance_t * );   
    4846static void Play         ( aout_instance_t * ); 
    4947 
     
    103101    } 
    104102 
    105     p_aout->output.pf_setformat = SetFormat; 
    106103    p_aout->output.pf_play = Play; 
    107104 
     
    120117    /* We need to open the device with default values to be sure it is 
    121118     * available */ 
    122     return OpenWaveOut( p_aout, WAVE_FORMAT_PCM, 2, 44100 ); 
    123 
    124  
    125 /***************************************************************************** 
    126  * SetFormat: reset the audio device and sets its format 
    127  ***************************************************************************** 
    128  * This functions set a new audio format. 
    129  * For this we need to close the current device and create another 
    130  * one with the desired format. 
    131  *****************************************************************************/ 
    132 static int SetFormat( aout_instance_t *p_aout ) 
    133 
    134     msg_Dbg( p_aout, "SetFormat" ); 
     119    if ( OpenWaveOut( p_aout, WAVE_FORMAT_PCM, 2, 44100 ) ) 
     120    { 
     121        msg_Err( p_aout, "cannot open waveout" ); 
     122        return 1; 
     123    } 
    135124 
    136125    waveOutReset( p_aout->output.p_sys->h_waveout ); 
     
    138127    p_aout->output.output.i_format = AOUT_FMT_S16_NE; 
    139128    p_aout->output.i_nb_samples = FRAME_SIZE; 
    140  
    141     /* Check if the format has changed */ 
    142     if( (p_aout->output.p_sys->waveformat.nChannels != 
    143              p_aout->output.output.i_channels) || 
    144         (p_aout->output.p_sys->waveformat.nSamplesPerSec != 
    145              p_aout->output.output.i_rate) ) 
    146     { 
    147         if( waveOutClose( p_aout->output.p_sys->h_waveout ) != 
    148                 MMSYSERR_NOERROR ) 
    149         { 
    150             msg_Err( p_aout, "waveOutClose failed" ); 
    151         } 
    152  
    153         /* calculate the frame size in bytes */ 
    154         p_aout->output.p_sys->i_buffer_size = FRAME_SIZE * sizeof(s16) 
    155                                             * p_aout->output.output.i_channels; 
    156  
    157         /* take care of silence buffer */ 
    158         free( p_aout->output.p_sys->p_silence_buffer ); 
    159         p_aout->output.p_sys->p_silence_buffer = 
    160             calloc( p_aout->output.p_sys->i_buffer_size, 1 ); 
    161         if( p_aout->output.p_sys->p_silence_buffer == NULL ) 
    162         { 
    163             msg_Err( p_aout, "out of memory" ); 
    164             return 1; 
    165         } 
    166  
    167         if( OpenWaveOut( p_aout, WAVE_FORMAT_PCM, 
    168                          p_aout->output.output.i_channels, 
    169                          p_aout->output.output.i_rate ) ) 
    170             return 1; 
    171     } 
    172129 
    173130    /* We need to kick off the playback in order to have the callback properly 
  • modules/gui/beos/AudioOutput.cpp

    r7d2f6de r0699631  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999, 2000, 2001 VideoLAN 
    5  * $Id: AudioOutput.cpp,v 1.6 2002/08/29 23:53:22 massiot Exp $ 
     5 * $Id: AudioOutput.cpp,v 1.7 2002/08/30 23:27:06 massiot Exp $ 
    66 * 
    77 * Authors: Jean-Marc Dressler <polux@via.ecp.fr> 
     
    5555    int              i_buffer_size; 
    5656    uint             i_buffer_pos; 
    57     volatile vlc_bool_t   b_initialized; 
    5857    mtime_t          clock_diff; 
    59  
    6058}; 
    6159 
     
    6563 * Local prototypes. 
    6664 *****************************************************************************/ 
    67 int  Open         ( vlc_object_t * ); 
    68 void Close        ( vlc_object_t * ); 
    69  
    7065static int  SetFormat    ( aout_instance_t * ); 
    7166static void Play         ( aout_instance_t * ); 
    72 static int  BeOSThread    ( aout_instance_t * ); 
     67static int  BeOSThread   ( aout_instance_t * ); 
    7368 
    7469/***************************************************************************** 
     
    7772int E_(OpenAudio) ( vlc_object_t * p_this ) 
    7873{        
    79  
    8074    aout_instance_t * p_aout = (aout_instance_t *)p_this; 
    8175    struct aout_sys_t * p_sys; 
     
    114108        free( p_sys ); 
    115109        return -1; 
    116  
    117     } 
    118      
    119     p_aout->output.pf_setformat = SetFormat; 
     110    } 
     111     
    120112    p_aout->output.pf_play = Play; 
    121113 
     
    158150    p_aout->output.p_sys->p_format->buffer_size = 4*8192; 
    159151 
    160     p_aout->output.p_sys->b_initialized = VLC_TRUE; 
    161  
    162152    return( 0 ); 
    163153} 
    164154 
    165155/***************************************************************************** 
    166  * Play: plays a sound samples buffer 
    167  ***************************************************************************** 
    168  * This function writes a buffer of i_length bytes in the dsp 
     156 * Play: nothing to do 
    169157 *****************************************************************************/ 
    170158static void Play( aout_instance_t *p_aout ) 
     
    223211        byte_t * p_bytes; 
    224212 
    225         if( !p_sys->b_initialized ) 
    226         { 
    227             msleep( THREAD_SLEEP ); 
    228             continue; 
    229         } 
    230213        mtime_t next_date = 0; 
    231214        /* Get the presentation date of the next write() operation. It 
  • modules/gui/macosx/aout.m

    r51e9975 r0699631  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: aout.m,v 1.7 2002/08/25 09:40:00 sam Exp $ 
     5 * $Id: aout.m,v 1.8 2002/08/30 23:27:06 massiot Exp $ 
    66 * 
    77 * Authors: Colin Delacroix <colin@zoy.org> 
     
    5858 * Local prototypes. 
    5959 *****************************************************************************/ 
    60 static int      SetFormat       ( aout_instance_t *p_aout ); 
    6160static void     Play            ( aout_instance_t *p_aout ); 
    6261 
     
    10099    } 
    101100 
    102     p_aout->output.pf_setformat = SetFormat; 
    103101    p_aout->output.pf_play = Play; 
    104102 
    105     return 0; 
    106 } 
    107  
    108 /***************************************************************************** 
    109  * SetFormat: find the closest available format from p_format 
    110  *****************************************************************************/ 
    111 static int SetFormat( aout_instance_t * p_aout ) 
    112 { 
    113     struct aout_sys_t * p_sys = p_aout->output.p_sys; 
    114     OSErr err; 
    115  
    116103    /* Get a description of the data format used by the device */ 
    117     UInt32 i_param_size = sizeof( p_sys->stream_format );  
     104    i_param_size = sizeof( p_sys->stream_format );  
    118105    err = AudioDeviceGetProperty( p_sys->device, 0, false,  
    119106                                  kAudioDevicePropertyStreamFormat,  
     
    209196 
    210197/***************************************************************************** 
    211  * Play: queue a buffer for playing by IOCallback 
     198 * Play: nothing to do 
    212199 *****************************************************************************/ 
    213200static void Play( aout_instance_t * p_aout ) 
  • modules/gui/qnx/aout.c

    r7d2f6de r0699631  
    4848 
    4949    byte_t *     p_silent_buffer; 
    50     vlc_bool_t   b_initialized; 
    5150}; 
    5251 
     
    5958void           E_(CloseAudio)   ( vlc_object_t *p_this ); 
    6059static int     GetBufInfo       ( aout_instance_t * ); 
    61 static int     SetFormat        ( aout_instance_t * ); 
    6260static void    Play             ( aout_instance_t * ); 
    6361static int     QNXaoutThread    ( aout_instance_t * ); 
     
    7270    aout_instance_t *p_aout = (aout_instance_t *)p_this; 
    7371    int i_ret; 
     72    int i_bytes_per_sample; 
     73    snd_pcm_channel_info_t pi; 
     74    snd_pcm_channel_params_t pp; 
     75    aout_instance_t *p_aout = (aout_instance_t *)p_this; 
    7476 
    7577    /* allocate structure */ 
     
    103105    } 
    104106 
    105     /* Create audio thread and wait for its readiness. */ 
    106     p_aout->output.p_sys->b_initialized = VLC_FALSE; 
    107     if( vlc_thread_create( p_aout, "aout", QNXaoutThread, 
    108                            VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) ) 
    109     { 
    110         msg_Err( p_aout, "cannot create QNX audio thread (%s)", strerror(errno) ); 
    111         E_(CloseAudio)( p_this ); 
    112         free( p_aout->output.p_sys ); 
    113         return -1; 
    114     } 
    115  
    116107    p_aout->output.p_sys->p_silent_buffer = malloc( DEFAULT_FRAME_SIZE * 4 ); 
    117  
    118     p_aout->output.pf_setformat = SetFormat; 
    119108    p_aout->output.pf_play = Play; 
    120  
    121     return( 0 ); 
    122 } 
    123  
    124 /***************************************************************************** 
    125  * SetFormat : set the audio output format 
    126  ***************************************************************************** 
    127  * This function prepares the device, sets the rate, format, the mode 
    128  * ("play as soon as you have data"), and buffer information. 
    129  *****************************************************************************/ 
    130 static int SetFormat( aout_instance_t *p_this ) 
    131 { 
    132     int i_ret; 
    133     int i_bytes_per_sample; 
    134     snd_pcm_channel_info_t pi; 
    135     snd_pcm_channel_params_t pp;