Changeset 54929735f8c480fcbdecb870e97405670acc6ce8

Show
Ignore:
Timestamp:
20/10/02 14:23:48 (6 years ago)
Author:
Christophe Massiot <massiot@videolan.org>
git-committer:
Christophe Massiot <massiot@videolan.org> 1035116628 +0000
git-parent:

[8622c1bb22fdda2841a361bfb5f2dc1cf981a75e]

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

* modules/demux/mpeg: Added DVB stream type for A/52 streams (0x6),
* include/vlc_threads.h: Avoid locking the interface,
* ALL: reworked all audio output plug-ins to correctly take into account

i_channels. At present this is known to break OSS, probably others.

Files:

Legend:

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

    ref6c706 r5492973  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: aout_internal.h,v 1.22 2002/09/27 23:38:04 massiot Exp $ 
     5 * $Id: aout_internal.h,v 1.23 2002/10/20 12:23:47 massiot Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    261261VLC_EXPORT( int, aout_FormatNbChannels, ( audio_sample_format_t * p_format ) ); 
    262262void aout_FormatPrepare( audio_sample_format_t * p_format ); 
     263VLC_EXPORT( void, aout_FormatPrint, ( aout_instance_t * p_aout, const char * psz_text, audio_sample_format_t * p_format ) ); 
     264VLC_EXPORT( void, aout_FormatsPrint, ( aout_instance_t * p_aout, const char * psz_text, audio_sample_format_t * p_format1, audio_sample_format_t * p_format2 ) ); 
    263265void aout_FifoInit( aout_instance_t *, aout_fifo_t *, u32 ); 
    264266mtime_t aout_FifoNextStart( aout_instance_t *, aout_fifo_t * ); 
  • include/audio_output.h

    r9a6b90b r5492973  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: audio_output.h,v 1.68 2002/09/30 21:32:31 massiot Exp $ 
     5 * $Id: audio_output.h,v 1.69 2002/10/20 12:23:47 massiot Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    179179VLC_EXPORT( int, aout_VolumeDown, ( aout_instance_t *, int, audio_volume_t * ) ); 
    180180VLC_EXPORT( int, aout_Restart, ( aout_instance_t * p_aout ) ); 
     181VLC_EXPORT( void, aout_FindAndRestart, ( vlc_object_t * p_this ) ); 
    181182 
  • include/vlc_threads.h

    r146bc0b r5492973  
    44 ***************************************************************************** 
    55 * Copyright (C) 1999, 2002 VideoLAN 
    6  * $Id: vlc_threads.h,v 1.14 2002/10/08 22:48:25 massiot Exp $ 
     6 * $Id: vlc_threads.h,v 1.15 2002/10/20 12:23:47 massiot Exp $ 
    77 * 
    88 * Authors: Jean-Marc Dressler <polux@via.ecp.fr> 
     
    7373#   define VLC_THREAD_PRIORITY_AUDIO 38 
    7474#   define VLC_THREAD_PRIORITY_VIDEO 31 
    75 #   define VLC_THREAD_PRIORITY_OUTPUT 38 
     75#   define VLC_THREAD_PRIORITY_OUTPUT 31 
    7676 
    7777#elif defined(WIN32) 
  • modules/audio_filter/converter/a52tofloat32.c

    r9a6b90b r5492973  
    55 ***************************************************************************** 
    66 * Copyright (C) 2001, 2002 VideoLAN 
    7  * $Id: a52tofloat32.c,v 1.3 2002/09/30 21:32:32 massiot Exp $ 
     7 * $Id: a52tofloat32.c,v 1.4 2002/10/20 12:23:47 massiot Exp $ 
    88 * 
    99 * Authors: Gildas Bazin <gbazin@netcourrier.com> 
     
    195195        msg_Err( p_filter, 
    196196                 "liba52 couldn't do the requested downmix 0x%x->0x%x", 
    197                  p_sys->i_flags, i_flags ); 
     197                 p_sys->i_flags  & A52_CHANNEL_MASK, 
     198                 i_flags & A52_CHANNEL_MASK ); 
    198199        memset( p_out_buf->p_buffer, 0, i_bytes_per_block * 6 ); 
    199200        return; 
  • modules/audio_output/alsa.c

    rd81ece4 r5492973  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000-2001 VideoLAN 
    5  * $Id: alsa.c,v 1.13 2002/10/05 03:44:50 bozo Exp $ 
     5 * $Id: alsa.c,v 1.14 2002/10/20 12:23:47 massiot Exp $ 
    66 * 
    77 * Authors: Henri Fallon <henri@videolan.org> - Original Author 
     
    5050{ 
    5151    snd_pcm_t         * p_snd_pcm; 
    52     snd_pcm_sframes_t   i_buffer_size; 
    5352    int                 i_period_time; 
    54  
    55     volatile vlc_bool_t b_can_sleek; 
    5653 
    5754#ifdef DEBUG 
     
    7067#define ALSA_SPDIF_PERIOD_SIZE          A52_FRAME_NB 
    7168#define ALSA_SPDIF_BUFFER_SIZE          ( ALSA_SPDIF_PERIOD_SIZE << 4 ) 
     69/* Why << 4 ? --Meuuh */ 
    7270 
    7371/***************************************************************************** 
     
    8583vlc_module_begin(); 
    8684    add_category_hint( N_("ALSA"), NULL ); 
    87     add_string( "alsa-device", NULL, NULL, N_("device name"), NULL ); 
     85    add_string( "alsa-device", "default", aout_FindAndRestart, 
     86                N_("device name"), NULL ); 
    8887    set_description( _("ALSA audio module") ); 
    8988    set_capability( "audio output", 50 ); 
     
    10099    aout_instance_t * p_aout = (aout_instance_t *)p_this; 
    101100    struct aout_sys_t * p_sys; 
    102  
    103     int i_snd_rc = -1; 
    104  
    105     char * psz_device = NULL; 
    106     char psz_alsadev[128]; 
    107     char * psz_userdev; 
    108  
    109     int i_format_tries[2]; 
    110     int i_tries_count, i; 
    111  
    112     int i_format; 
    113     int i_channels; 
     101    char * psz_device; 
     102    int i_buffer_size; 
    114103 
    115104    snd_pcm_hw_params_t *p_hw; 
    116105    snd_pcm_sw_params_t *p_sw; 
     106 
     107    int i_snd_rc = -1; 
     108 
     109    int i_format; 
     110 
    117111 
    118112    /* Allocate structures */ 
     
    124118    } 
    125119 
    126     p_aout->output.pf_play = Play; 
     120    /* Get device name */ 
     121    if( (psz_device = config_GetPsz( p_aout, "dspdev" )) == NULL ) 
     122    { 
     123        msg_Err( p_aout, "no audio device given (maybe \"default\" ?)" ); 
     124        free( p_sys ); 
     125        return VLC_EGENERIC; 
     126    } 
    127127 
    128128#ifdef DEBUG 
     
    130130#endif 
    131131 
    132     i_tries_count = 0; 
    133     i_format_tries[i_tries_count++] = p_aout->output.output.i_format; 
    134     if( i_format_tries[0] == VLC_FOURCC('s','p','d','i') ) 
    135     { 
    136         /* Try S/PDIF, and then FLOAT32 */ 
    137         i_format_tries[i_tries_count++] = VLC_FOURCC('f','l','3','2'); 
    138     } 
    139  
    140     /* Read in ALSA device preferences from configuration */ 
    141     psz_userdev = config_GetPsz( p_aout, "alsa-device" ); 
    142  
    143     for( i = 0 ; ( i_snd_rc < 0 ) && ( i < i_tries_count ) ; ++i ) 
    144     { 
    145         if( i_format_tries[i] == VLC_FOURCC('s','p','d','i') ) 
    146         { 
    147             if( psz_userdev ) 
    148             { 
    149                 psz_device = psz_userdev; 
    150             } 
    151             else 
    152             { 
    153                 /* Will probably need some little modification in the case 
    154                    we want to send some data at a different rate 
    155                    (32000, 44100 and 48000 are the possibilities) -- bozo */ 
    156                 unsigned char s[4]; 
    157                 s[0] = IEC958_AES0_CON_EMPHASIS_NONE | IEC958_AES0_NONAUDIO; 
    158                 s[1] = IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER; 
    159                 s[2] = 0; 
    160                 s[3] = IEC958_AES3_CON_FS_48000; 
    161                 sprintf( psz_alsadev, 
    162                          "iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x", 
    163                          s[0], s[1], s[2], s[3] ); 
    164                 psz_device = psz_alsadev; 
    165             } 
     132    /* Open the device */ 
     133    if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) 
     134          && !strcmp( "default", psz_device ) ) 
     135    { 
     136        /* ALSA doesn't understand "default" for S/PDIF. Cheat a little. */ 
     137        char psz_iecdev[128]; 
     138 
     139        if ( !strcmp( "default", psz_device ) ) 
     140        { 
     141            snprintf( psz_iecdev, sizeof(psz_iecdev), 
     142                 "iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x", 
     143                 IEC958_AES0_CON_EMPHASIS_NONE | IEC958_AES0_NONAUDIO, 
     144                 IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER, 
     145                 0, 
     146                 (p_aout->output.output.i_rate == 48000 ? 
     147                  IEC958_AES3_CON_FS_48000 : 
     148                  (p_aout->output.output.i_rate == 44100 ? 
     149                   IEC958_AES3_CON_FS_44100 : IEC958_AES3_CON_FS_32000)) ); 
    166150        } 
    167151        else 
    168152        { 
    169             if( psz_userdev ) 
    170                 psz_device = psz_userdev; 
    171             else 
    172                 psz_device = "default"; 
    173         } 
    174  
    175         /* Open device */ 
    176         i_snd_rc = snd_pcm_open( &p_sys->p_snd_pcm, psz_device, 
    177                                  SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); 
    178     } 
    179  
    180     if( i_snd_rc < 0 ) 
    181     { 
    182         msg_Err( p_aout, "cannot open ALSA device `%s' (%s)", 
    183                          psz_device, snd_strerror(i_snd_rc) ); 
    184         if( psz_userdev ) 
    185             free( psz_userdev ); 
    186         p_sys->p_snd_pcm = NULL; 
    187         return -1; 
    188     } 
    189  
    190     if( psz_userdev ) 
    191         free( psz_userdev ); 
    192  
    193     p_aout->output.output.i_format = i_format_tries[i - 1]; 
    194  
    195     /* Default settings */ 
    196     p_sys->b_can_sleek = VLC_FALSE; 
    197     i_channels = p_aout->output.output.i_channels; 
    198     if ( p_aout->output.output.i_format == VLC_FOURCC('s','p','d','i') ) 
    199     { 
    200         p_sys->i_buffer_size = ALSA_SPDIF_BUFFER_SIZE; 
    201         p_aout->output.i_nb_samples = ALSA_SPDIF_PERIOD_SIZE; 
    202         aout_VolumeNoneInit( p_aout ); 
    203     } 
    204     else 
    205     { 
    206         p_sys->i_buffer_size = ALSA_DEFAULT_BUFFER_SIZE; 
     153            strncat( psz_iecdev, psz_device, sizeof(psz_iecdev) ); 
     154        } 
     155 
     156        if ( (i_snd_rc = snd_pcm_open( &p_sys->p_snd_pcm, psz_iecdev, 
     157                           SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0 ) 
     158        { 
     159            /* No S/PDIF. */ 
     160            msg_Warn( p_aout, "cannot open S/PDIF ALSA device `%s' (%s)", 
     161                      psz_device, snd_strerror(i_snd_rc) ); 
     162            p_aout->output.output.i_format = VLC_FOURCC('f','l','3','2'); 
     163        } 
     164        else 
     165        { 
     166            i_buffer_size = ALSA_SPDIF_BUFFER_SIZE; 
     167            i_format = SND_PCM_FORMAT_S16_NE; 
     168 
     169            p_aout->output.i_nb_samples = ALSA_SPDIF_PERIOD_SIZE; 
     170            p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i'); 
     171            p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; 
     172            p_aout->output.output.i_frame_length = A52_FRAME_NB; 
     173 
     174            aout_VolumeNoneInit( p_aout ); 
     175        } 
     176    } 
     177 
     178    if ( !AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) 
     179    { 
     180        if ( (i_snd_rc = snd_pcm_open( &p_sys->p_snd_pcm, psz_device, 
     181                           SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0 ) 
     182        { 
     183            msg_Err( p_aout, "cannot open ALSA device `%s' (%s)", 
     184                             psz_device, snd_strerror(i_snd_rc) ); 
     185            free( p_sys ); 
     186            free( psz_device ); 
     187            return VLC_EGENERIC; 
     188        } 
     189 
     190        if ( p_aout->p_libvlc->i_cpu & CPU_CAPABILITY_FPU ) 
     191        { 
     192            p_aout->output.output.i_format = VLC_FOURCC('f','l','3','2'); 
     193            i_format = SND_PCM_FORMAT_FLOAT; 
     194        } 
     195        else 
     196        { 
     197            p_aout->output.output.i_format = AOUT_FMT_S16_NE; 
     198            i_format = SND_PCM_FORMAT_S16_NE; 
     199        } 
     200 
     201        i_buffer_size = ALSA_DEFAULT_BUFFER_SIZE; 
    207202        p_aout->output.i_nb_samples = ALSA_DEFAULT_PERIOD_SIZE; 
     203 
    208204        aout_VolumeSoftInit( p_aout ); 
    209205    } 
    210206 
    211     /* Compute the settings */ 
    212     switch (p_aout->output.output.i_format) 
    213     { 
    214         case VLC_FOURCC('f','l','3','2'): 
    215             i_format = SND_PCM_FORMAT_FLOAT; 
    216             break; 
    217  
    218         case VLC_FOURCC('s','p','d','i'): 
    219             /* Override some settings to make S/PDIF work */ 
    220             p_sys->b_can_sleek = VLC_TRUE; 
    221             i_format = SND_PCM_FORMAT_S16_LE; 
    222             i_channels = 2; 
    223             p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; 
    224             p_aout->output.output.i_frame_length = ALSA_SPDIF_PERIOD_SIZE; 
    225             break; 
    226         default: 
    227             msg_Err( p_aout, "audio output format '%.4s' not supported", 
    228                      &p_aout->output.output.i_format ); 
    229             return -1; 
    230             break; 
    231     } 
     207    free( psz_device ); 
     208    p_aout->output.pf_play = Play; 
    232209 
    233210    snd_pcm_hw_params_alloca(&p_hw); 
    234211    snd_pcm_sw_params_alloca(&p_sw); 
    235212 
    236     i_snd_rc = snd_pcm_hw_params_any( p_sys->p_snd_pcm, p_hw ); 
    237     if( i_snd_rc < 0 ) 
     213    if ( snd_pcm_hw_params_any( p_sys->p_snd_pcm, p_hw ) < 0 ) 
    238214    { 
    239215        msg_Err( p_aout, "unable to retrieve initial hardware parameters" ); 
    240         return -1; 
    241     } 
    242  
    243     i_snd_rc = snd_pcm_hw_params_set_access( p_sys->p_snd_pcm, p_hw, 
    244                                              SND_PCM_ACCESS_RW_INTERLEAVED ); 
    245     if( i_snd_rc < 0 ) 
    246     { 
    247         msg_Err( p_aout, "unable to set interleaved stream format" ); 
    248         return -1; 
    249     } 
    250  
    251     i_snd_rc = snd_pcm_hw_params_set_format( p_sys->p_snd_pcm, p_hw, i_format ); 
    252     if( i_snd_rc < 0 ) 
     216        goto error; 
     217    } 
     218 
     219    /* Set format. */ 
     220    if ( snd_pcm_hw_params_set_format( p_sys->p_snd_pcm, p_hw, i_format ) < 0 ) 
    253221    { 
    254222        msg_Err( p_aout, "unable to set stream sample size and word order" ); 
    255         return -1; 
    256     } 
    257  
    258     i_snd_rc = snd_pcm_hw_params_set_channels( p_sys->p_snd_pcm, p_hw, 
    259                                                i_channels ); 
    260     if( i_snd_rc < 0 ) 
    261     { 
    262         msg_Err( p_aout, "unable to set number of output channels" ); 
    263         return -1; 
    264     } 
    265  
    266     i_snd_rc = snd_pcm_hw_params_set_rate_near( p_sys->p_snd_pcm, p_hw, 
    267                                                 p_aout->output.output.i_rate, 
    268                                                 NULL ); 
    269     if( i_snd_rc < 0 ) 
    270     { 
    271         msg_Err( p_aout, "unable to set sample rate" ); 
    272         return -1; 
    273     } 
    274     p_aout->output.output.i_rate = i_snd_rc; 
    275  
     223        goto error; 
     224    } 
     225 
     226    if ( !AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) 
     227    { 
     228        int i_nb_channels; 
     229 
     230        if ( snd_pcm_hw_params_set_access( p_sys->p_snd_pcm, p_hw, 
     231                                       SND_PCM_ACCESS_RW_INTERLEAVED ) < 0 ) 
     232        { 
     233            msg_Err( p_aout, "unable to set interleaved stream format" ); 
     234            goto error; 
     235        } 
     236 
     237        /* Set channels. */ 
     238        i_nb_channels = aout_FormatNbChannels( &p_aout->output.output ); 
     239 
     240        if ( (i_snd_rc = snd_pcm_hw_params_set_channels( p_sys->p_snd_pcm, 
     241                                 p_hw, i_nb_channels )) < 0 ) 
     242        { 
     243            msg_Err( p_aout, "unable to set number of output channels" ); 
     244            goto error; 
     245        } 
     246        if ( i_snd_rc != i_nb_channels ) 
     247        { 
     248            switch ( i_snd_rc ) 
     249            { 
     250            case 1: p_aout->output.output.i_channels = AOUT_CHAN_MONO; break; 
     251            case 2: p_aout->output.output.i_channels = AOUT_CHAN_STEREO; break; 
     252            case 4: p_aout->output.output.i_channels = AOUT_CHAN_2F2R; break; 
     253            default: 
     254                msg_Err( p_aout, "Unsupported downmixing (%d)", i_snd_rc ); 
     255                goto error; 
     256            } 
     257        } 
     258 
     259        /* Set rate. */ 
     260        if ( (i_snd_rc = snd_pcm_hw_params_set_rate_near( p_sys->p_snd_pcm, 
     261                                 p_hw, p_aout->output.output.i_rate, 
     262                                 NULL )) < 0 ) 
     263        { 
     264            msg_Err( p_aout, "unable to set sample rate" ); 
     265            goto error; 
     266        } 
     267        p_aout->output.output.i_rate = i_snd_rc; 
     268    } 
     269 
     270    /* Set buffer size. */ 
    276271    i_snd_rc = snd_pcm_hw_params_set_buffer_size_near( p_sys->p_snd_pcm, p_hw, 
    277272                                                       p_sys->i_buffer_size ); 
    278273    if( i_snd_rc < 0 ) 
    279274    { 
    280         msg_Err( p_aout, "unable to set buffer time" ); 
    281         return -1
    282     } 
    283     p_sys->i_buffer_size = i_snd_rc; 
    284  
     275        msg_Err( p_aout, "unable to set buffer size" ); 
     276        goto error
     277    } 
     278 
     279    /* Set period size. */ 
    285280    i_snd_rc = snd_pcm_hw_params_set_period_size_near( 
    286                     p_sys->p_snd_pcm, p_hw, p_aout->output.i_nb_samples, NULL ); 
     281                  p_sys->p_snd_pcm, p_hw, p_aout->output.i_nb_samples, NULL ); 
    287282    if( i_snd_rc < 0 ) 
    288283    { 
    289284        msg_Err( p_aout, "unable to set period size" ); 
    290         return -1
     285        goto error
    291286    } 
    292287    p_aout->output.i_nb_samples = i_snd_rc; 
    293288 
    294     i_snd_rc = snd_pcm_hw_params( p_sys->p_snd_pcm, p_hw ); 
    295     if (i_snd_rc < 0
     289    /* Write hardware configuration. */ 
     290    if ( snd_pcm_hw_params( p_sys->p_snd_pcm, p_hw ) < 0
    296291    { 
    297292        msg_Err( p_aout, "unable to set hardware configuration" ); 
    298         return -1
     293        goto error
    299294    } 
    300295 
     
    307302                                                p_aout->output.i_nb_samples ); 
    308303 
    309     i_snd_rc = snd_pcm_sw_params( p_sys->p_snd_pcm, p_sw ); 
    310     if( i_snd_rc < 0 ) 
     304    /* Write software configuration. */ 
     305    if ( snd_pcm_sw_params( p_sys->p_snd_pcm, p_sw ) < 0 ) 
    311306    { 
    312307        msg_Err( p_aout, "unable to set software configuration" ); 
    313         return -1
     308        goto error
    314309    } 
    315310 
     
    327322    { 
    328323        msg_Err( p_aout, "cannot create ALSA thread (%s)", strerror(errno) ); 
    329         free( p_sys ); 
    330         return -1; 
     324        goto error; 
    331325    } 
    332326 
    333327    return 0; 
     328 
     329error: 
     330    snd_pcm_close( p_sys->p_snd_pcm ); 
     331#ifdef DEBUG 
     332    snd_output_close( p_sys->p_snd_stderr ); 
     333#endif 
     334    free( p_sys ); 
     335    return VLC_EGENERIC; 
    334336} 
    335337 
     
    342344 
    343345/***************************************************************************** 
    344  * Close: close the Alsa device 
     346 * Close: close the ALSA device 
    345347 *****************************************************************************/ 
    346348static void Close( vlc_object_t *p_this ) 
     
    353355    vlc_thread_join( p_aout ); 
    354356 
    355     if( p_sys->p_snd_pcm ) 
    356     { 
    357         i_snd_rc = snd_pcm_close( p_sys->p_snd_pcm ); 
    358  
    359         if( i_snd_rc > 0 ) 
    360         { 
    361             msg_Err( p_aout, "failed closing ALSA device (%s)", 
    362                              snd_strerror( i_snd_rc ) ); 
    363         } 
     357    i_snd_rc = snd_pcm_close( p_sys->p_snd_pcm ); 
     358 
     359    if( i_snd_rc > 0 ) 
     360    { 
     361        msg_Err( p_aout, "failed closing ALSA device (%s)", 
     362                         snd_strerror( i_snd_rc ) ); 
    364363    } 
    365364 
     
    384383        /* Sleep during less than one period to avoid a lot of buffer 
    385384           underruns */ 
     385 
     386        /* Why do we need to sleep ? --Meuuh */ 
    386387        msleep( p_sys->i_period_time >> 2 ); 
    387388    } 
     
    410411    if( i_snd_rc < 0 ) 
    411412    { 
    412         msg_Err( p_aout, "alsa device not ready !!! (%s)", 
     413        msg_Err( p_aout, "ALSA device not ready !!! (%s)", 
    413414                         snd_strerror( i_snd_rc ) ); 
    414415        return; 
     
    416417 
    417418    /* Fill in the buffer until space or audio output buffer shortage */ 
    418     while( VLC_TRUE
     419    for ( ; ;
    419420    { 
    420421        /* Get the status */ 
     
    467468 
    468469            p_buffer = aout_OutputNextBuffer( p_aout, next_date, 
    469                                               p_sys->b_can_sleek ); 
     470                        (p_aout->output.output.i_format != 
     471                            VLC_FOURCC('s','p','d','i')) ); 
    470472 
    471473            /* Audio output buffer shortage -> stop the fill process and 
     
    482484                                 snd_strerror( i_snd_rc ) ); 
    483485            } 
    484             else 
    485             { 
    486                 aout_BufferFree( p_buffer ); 
    487             } 
     486 
     487            aout_BufferFree( p_buffer ); 
    488488        } 
    489489    } 
  • modules/audio_output/arts.c

    r89987e1 r5492973  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001-2002 VideoLAN 
    5  * $Id: arts.c,v 1.13 2002/10/04 18:07:21 sam Exp $ 
     5 * $Id: arts.c,v 1.14 2002/10/20 12:23:47 massiot Exp $ 
    66 * 
    77 * Authors: Emmanuel Blindauer <manu@agat.net> 
     
    7878    struct aout_sys_t * p_sys; 
    7979    int i_err; 
     80    int i_nb_channels; 
    8081 
    8182    /* Allocate structure */ 
     
    100101    aout_VolumeSoftInit( p_aout ); 
    101102 
    102     p_sys->stream = NULL; 
    103  
    104     if( p_sys->stream ) 
    105     { 
    106         arts_close_stream( p_sys->stream ); 
     103    p_aout->output.output.i_format = AOUT_FMT_S16_NE; 
     104    i_nb_channels = aout_FormatNbChannels( &p_aout->output.output ); 
     105    if ( i_nb_channels > 2 ) 
     106    { 
     107        /* aRts doesn't support more than two channels. */ 
     108        i_nb_channels = 2; 
     109        p_aout->output.output.i_channels = AOUT_CHAN_STEREO; 
    107110    } 
    108111 
    109112    /* Open a socket for playing a stream, set format to 16 bits */ 
    110113    p_sys->stream = arts_play_stream( p_aout->output.output.i_rate, 16, 
    111                                       p_aout->output.output.i_channels, "vlc" ); 
     114                                      i_nb_channels, "vlc" ); 
    112115    if( p_sys->stream == NULL ) 
    113116    { 
    114117        msg_Err( p_aout, "cannot open aRts socket" ); 
     118        free( p_sys ); 
    115119        return -1; 
    116120    } 
     
    129133                     arts_stream_get( p_sys->stream, ARTS_P_PACKET_SIZE ) ); 
    130134 
    131     p_aout->output.output.i_format = AOUT_FMT_S16_NE; 
    132     p_aout->output.i_nb_samples = p_sys->i_size 
    133                                    / sizeof(u16) 
    134                                    / p_aout->output.output.i_channels; 
     135    p_aout->output.i_nb_samples = p_sys->i_size / sizeof(u16) / i_nb_channels; 
    135136 
    136137    /* Create aRts thread and wait for its readiness. */ 
     
    139140    { 
    140141        msg_Err( p_aout, "cannot create aRts thread (%s)", strerror(errno) ); 
     142        arts_close_stream( p_sys->stream ); 
     143        arts_free(); 
    141144        free( p_sys ); 
    142145        return -1; 
     
    165168    vlc_thread_join( p_aout ); 
    166169 
    167     if( p_sys->stream ) 
    168     { 
    169         arts_close_stream( p_sys->stream ); 
    170     } 
    171  
     170    arts_close_stream( p_sys->stream ); 
    172171    arts_free(); 
    173172    free( p_sys ); 
  • modules/audio_output/directx.c

    rcc5919a r5492973  
    11/***************************************************************************** 
    2  * aout.c: Windows DirectX audio output method 
     2 * directx.c: Windows DirectX audio output method 
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: directx.c,v 1.3 2002/10/11 10:08:06 gbazin Exp $ 
     5 * $Id: directx.c,v 1.4 2002/10/20 12:23:47 massiot Exp $ 
    66 * 
    77 * Authors: Gildas Bazin <gbazin@netcourrier.com> 
     
    131131    { 
    132132        msg_Err( p_aout, "out of memory" ); 
    133         return 1
     133        return VLC_EGENERIC
    134134    } 
    135135 
     
    224224 error: 
    225225    CloseAudio( VLC_OBJECT(p_aout) ); 
    226     return 1
     226    return VLC_EGENERIC
    227227} 
    228228 
     
    270270       FreeLibrary( p_aout->output.p_sys->hdsound_dll ); 
    271271 
    272     /* Close the Output. */ 
    273     if ( p_aout->output.p_sys  ) 
    274     {  
    275         free( p_aout->output.p_sys ); 
    276         p_aout->output.p_sys = NULL; 
    277     } 
     272    free( p_aout->output.p_sys ); 
    278273} 
    279274 
     
    356351    DSBUFFERDESC         dsbdesc; 
    357352    DSBCAPS              dsbcaps; 
    358  
    359     if( p_aout->output.output.i_channels > 2 ) 
    360         p_aout->output.output.i_channels = 2; 
     353    int                  i_nb_channels; 
     354 
     355    i_nb_channels = aout_FormatNbChannels( &p_aout->output.output ); 
     356    if ( i_nb_channels > 2 ) 
     357    { 
     358        i_nb_channels = 2; 
     359        p_aout->output.output.i_channels = AOUT_CHAN_STEREO; 
     360    } 
    361361 
    362362    /* First set the buffer format */ 
    363363    memset(&waveformat, 0, sizeof(WAVEFORMATEX)); 
    364364    waveformat.wFormatTag      = WAVE_FORMAT_PCM; 
    365     waveformat.nChannels       = p_aout->output.output.i_channels; 
     365    waveformat.nChannels       = i_nb_channels; 
    366366    waveformat.nSamplesPerSec  = p_aout->output.output.i_rate; 
    367367    waveformat.wBitsPerSample  = 16; 
     
    378378                    | DSBCAPS_GLOBALFOCUS;      /* Allows background playing */ 
    379379    dsbdesc.dwBufferBytes = FRAME_SIZE * 2 /* frames*/ *      /* buffer size */ 
    380                             sizeof(s16) * p_aout->output.output.i_channels; 
     380                            sizeof(s16) * i_nb_channels; 
    381381    dsbdesc.lpwfxFormat = &waveformat; 
    382382  
     
    392392    /* backup the size of a frame */ 
    393393    p_aout->output.p_sys->p_notif->i_buffer_size = FRAME_SIZE * sizeof(s16) 
    394                                             * p_aout->output.output.i_channels; 
     394                                            * i_nb_channels; 
    395395 
    396396    memset(&dsbcaps, 0, sizeof(DSBCAPS)); 
     
    440440        p_aout->output.p_sys->p_dsnotify = NULL; 
    441441    } 
    442     return 1
     442    return VLC_EGENERIC
    443443} 
    444444 
  • modules/audio_output/esd.c

    r35b4740 r5492973  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000, 2001 VideoLAN 
    5  * $Id: esd.c,v 1.13 2002/09/18 21:21:23 massiot Exp $ 
     5 * $Id: esd.c,v 1.14 2002/10/20 12:23:47 massiot Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    7676    aout_instance_t *p_aout = (aout_instance_t *)p_this; 
    7777    struct aout_sys_t * p_sys; 
     78    int i_nb_channels; 
    7879 
    7980    /* Allocate structure */ 
     
    9495    p_sys->esd_format &= ~ESD_MASK_CHAN; 
    9596 
    96     switch( p_aout->output.output.i_channels ) 
     97    p_aout->output.output.i_format = AOUT_FMT_S16_NE; 
     98    i_nb_channels = aout_FormatNbChannels( &p_aout->output.output ); 
     99    if ( i_nb_channels > 2 ) 
     100    { 
     101        /* EsounD doesn't support more than two channels. */ 
     102        i_nb_channels = 2; 
     103        p_aout->output.output.i_channels = AOUT_CHAN_STEREO; 
     104    } 
     105 
     106    switch( i_nb_channels ) 
    97107    { 
    98108    case 1: 
     
    102112        p_sys->esd_format |= ESD_STEREO; 
    103113        break; 
    104     default: 
    105         return -1; 
    106114    } 
    107115 
     
    114122        msg_Err( p_aout, "cannot open esound socket (format 0x%08x at %ld Hz)", 
    115123                         p_sys->esd_format, p_aout->output.output.i_rate ); 
     124        free( p_sys ); 
    116125        return -1; 
    117126    } 
    118127 
    119     p_aout->output.output.i_format = AOUT_FMT_S16_NE; 
    120128    p_aout->output.i_nb_samples = ESD_BUF_SIZE * 2; 
    121129 
     
    136144    { 
    137145        msg_Err( p_aout, "cannot create ESD thread (%s)", strerror(errno) ); 
     146        close( p_sys->i_fd ); 
    138147        free( p_sys ); 
    139148        return -1; 
  • modules/audio_output/file.c

    r9a6b90b r5492973  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: file.c,v 1.12 2002/09/30 21:32:32 massiot Exp $ 
     5 * $Id: file.c,v 1.13 2002/10/20 12:23:47 massiot Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    9999 
    100100    p_aout->output.pf_play = Play; 
    101     aout_VolumeSoftInit( p_aout ); 
    102101 
    103102    while ( *ppsz_compare != NULL ) 
     
    118117 
    119118    p_aout->output.output.i_format = format_int[i]; 
    120     if ( p_aout->output.output.i_format == VLC_FOURCC('s','p','d','i') ) 
     119    if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) 
    121120    { 
    122121        p_aout->output.i_nb_samples = A52_FRAME_NB; 
    123122        p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; 
    124123        p_aout->output.output.i_frame_length = A52_FRAME_NB; 
     124        aout_VolumeNoneInit( p_aout ); 
    125125    } 
    126126    else 
    127127    { 
    128128        p_aout->output.i_nb_samples = FRAME_SIZE; 
     129        aout_VolumeSoftInit( p_aout ); 
    129130    } 
    130131    return 0; 
  • modules/audio_output/oss.c

    r31c3158 r5492973  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000-2002 VideoLAN 
    5  * $Id: oss.c,v 1.29 2002/10/02 15:37:58 sigmunau Exp $ 
     5 * $Id: oss.c,v 1.30 2002/10/20 12:23:47 massiot Exp $ 
    66 * 
    77 * Authors: Michel Kaempf <maxx@via.ecp.fr> 
     
    6565}; 
    6666 
     67/* This must be a power of 2. */ 
    6768#define FRAME_SIZE 1024 
    6869#define FRAME_COUNT 8 
     
    8384vlc_module_begin(); 
    8485    add_category_hint( N_("OSS"), NULL ); 
    85     add_file( "dspdev", "/dev/dsp", NULL, N_("OSS dsp device"), NULL ); 
     86    add_file( "dspdev", "/dev/dsp", aout_FindAndRestart, 
     87              N_("OSS dsp device"), NULL ); 
    8688    set_description( _("Linux OSS /dev/dsp module") ); 
    8789    set_capability( "audio output", 100 ); 
    88     add_shortcut( "dsp" ); 
     90    add_shortcut( "oss" ); 
    8991    set_callbacks( Open, Close ); 
    9092vlc_module_end(); 
     
    101103    struct aout_sys_t * p_sys; 
    102104    char * psz_device; 
    103     int i_format, i_format_orig; 
    104     int i_rate; 
    105     int i_frame_size; 
    106     int i_fragments; 
    107     vlc_bool_t b_stereo; 
    108105 
    109106    /* Allocate structure */ 
     
    115112    } 
    116113 
    117     /* Initialize some variables */ 
     114    /* Get device name */ 
    118115    if( (psz_device = config_GetPsz( p_aout, "dspdev" )) == NULL ) 
    119116    { 
     
    139136    { 
    140137        msg_Err( p_aout, "cannot reset OSS audio device" ); 
     138        close( p_sys->i_fd ); 
     139        free( p_sys ); 
    141140        return VLC_EGENERIC; 
    142141    } 
    143142     
    144     /* Set the fragment size 
    145      * i_fragment = xxxxyyyy where: xxxx        is fragtotal 
    146      *                              1 << yyyy   is fragsize */ 
    147     i_fragments = 0; 
    148     i_frame_size = FRAME_SIZE; 
    149     while( i_frame_size >>= 1 ) 
    150     { 
    151         ++i_fragments; 
    152     } 
    153     i_fragments |= FRAME_COUNT << 16; 
    154     if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFRAGMENT, &i_fragments ) < 0 ) 
    155     { 
    156         msg_Err( p_aout, "cannot set fragment size (%.8x)", i_fragments ); 
    157         return VLC_EGENERIC; 
    158     } 
    159  
    160143    /* Set the output format */ 
    161     if ( p_aout->output.output.i_format == VLC_FOURCC('s','p','d','i') ) 
    162     { 
    163         i_format = AFMT_AC3; 
    164         i_format_orig = AFMT_AC3; 
    165         p_aout->output.i_nb_samples = A52_FRAME_NB; 
    166         p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; 
    167         p_aout->output.output.i_frame_length = A52_FRAME_NB; 
    168  
    169         aout_VolumeNoneInit( p_aout ); 
    170     } 
    171     else 
    172     { 
     144    if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) 
     145    { 
     146        int i_format = AFMT_AC3; 
     147 
     148        if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 
     149             || i_format != AFMT_AC3 ) 
     150        { 
     151            p_aout->output.output.i_format = AOUT_FMT_S16_NE; 
     152        } 
     153        else 
     154        { 
     155            p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i'); 
     156            p_aout->output.i_nb_samples = A52_FRAME_NB; 
     157            p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; 
     158            p_aout->output.output.i_frame_length = A52_FRAME_NB; 
     159 
     160            aout_VolumeNoneInit( p_aout ); 
     161        } 
     162    } 
     163 
     164    if ( !AOUT_FMT_NON_LINEAR( &p_aout->output.output ) ) 
     165    { 
     166        int i_format = AFMT_S16_NE; 
     167        int i_frame_size, i_fragments; 
     168        int i_rate; 
     169        int i_nb_channels; 
     170 
     171        if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 ) 
     172        { 
     173            msg_Err( p_aout, "cannot set audio output format" ); 
     174            close( p_sys->i_fd ); 
     175