Changeset 255b41ac05c5be955025636475c5c50398b76530

Show
Ignore:
Timestamp:
11/11/02 20:16:21 (6 years ago)
Author:
Gildas Bazin <gbazin@videolan.org>
git-committer:
Gildas Bazin <gbazin@videolan.org> 1037042181 +0000
git-parent:

[bc061e8455fa11eec3167681d53f9df3974b13a5]

git-author:
Gildas Bazin <gbazin@videolan.org> 1037042181 +0000
Message:

* modules/audio_output/file.c: will write a WAV header by default. Can be

disabled with --no-audiofile-wav.

* modules/audio_filter/resampler/linear.c: disabled for now, until I actually

manage to make it work without a problem.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/audio_filter/resampler/linear.c

    re6c4183 r255b41a  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: linear.c,v 1.2 2002/11/10 13:24:35 sigmunau Exp $ 
     5 * $Id: linear.c,v 1.3 2002/11/11 19:16:21 gbazin Exp $ 
    66 * 
    77 * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> 
     
    4646vlc_module_begin(); 
    4747    set_description( _("audio filter for linear interpolation resampling") ); 
    48     set_capability( "audio filter", 10 ); 
     48    set_capability( "audio filter", 0 ); 
    4949    set_callbacks( Create, NULL ); 
    5050vlc_module_end(); 
  • modules/audio_output/file.c

    r5492973 r255b41a  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: file.c,v 1.13 2002/10/20 12:23:47 massiot Exp $ 
     5 * $Id: file.c,v 1.14 2002/11/11 19:16:21 gbazin Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     8 *          Gildas Bazin <gbazin@netcourrier.com> 
    89 * 
    910 * This program is free software; you can redistribute it and/or modify 
     
    3334 
    3435#include "aout_internal.h" 
     36#include "codecs.h" 
    3537 
    3638#define FRAME_SIZE 2048 
    3739#define A52_FRAME_NB 1536 
     40 
     41typedef struct WAVEHEADER 
     42{ 
     43    uint32_t MainChunkID;                      // it will be 'RIFF' 
     44    uint32_t Length; 
     45    uint32_t ChunkTypeID;                      // it will be 'WAVE' 
     46    uint32_t SubChunkID;                       // it will be 'fmt ' 
     47    uint32_t SubChunkLength; 
     48    uint16_t Format; 
     49    uint16_t Modus; 
     50    uint32_t SampleFreq; 
     51    uint32_t BytesPerSec; 
     52    uint16_t BytesPerSample; 
     53    uint16_t BitsPerSample; 
     54    uint32_t DataChunkID;                      // it will be 'data' 
     55    uint32_t DataLength; 
     56} WAVEHEADER; 
     57 
     58/***************************************************************************** 
     59 * aout_sys_t: audio output method descriptor 
     60 ***************************************************************************** 
     61 * This structure is part of the audio output thread descriptor. 
     62 * It describes the direct sound specific properties of an audio device. 
     63 *****************************************************************************/ 
     64struct aout_sys_t 
     65{ 
     66    FILE     * p_file; 
     67    vlc_bool_t b_add_wav_header; 
     68 
     69    WAVEHEADER waveh;                      /* Wave header of the output file */ 
     70}; 
    3871 
    3972/***************************************************************************** 
     
    4982#define FORMAT_TEXT N_("output format") 
    5083#define FORMAT_LONGTEXT N_("one of \"u8\", \"s8\", \"u16\", \"s16\"," \ 
    51                            " \"u16_le\", \"s16_le\", \"u16_be\"," \ 
    52                            " \"s16_be\", \"fixed32\", \"float32\" or \"spdif\"") 
     84                        " \"u16_le\", \"s16_le\", \"u16_be\"," \ 
     85                        " \"s16_be\", \"fixed32\", \"float32\" or \"spdif\"") 
     86#define WAV_TEXT N_("add wave header") 
     87#define WAV_LONGTEXT N_("instead of writing a raw file, you can add a wav " \ 
     88                        "header to the file") 
    5389 
    5490static char *format_list[] = { "u8", "s8", "u16", "s16", "u16_le", "s16_le", 
     
    71107vlc_module_begin(); 
    72108    add_category_hint( N_("Audio"), NULL ); 
    73     add_string_from_list( "format", "s16", format_list, NULL, 
     109    add_string_from_list( "audiofile-format", "s16", format_list, NULL, 
    74110                          FORMAT_TEXT, FORMAT_LONGTEXT ); 
    75     add_string( "path", "samples.raw", NULL, PATH_TEXT, PATH_LONGTEXT ); 
    76     set_description( _("file output module") ); 
     111    add_string( "audiofile-path", "audiofile.wav", NULL, PATH_TEXT, 
     112                PATH_LONGTEXT ); 
     113    add_bool( "audiofile-wav", 1, NULL, WAV_TEXT, WAV_LONGTEXT ); 
     114    set_description( _("file audio output module") ); 
    77115    set_capability( "audio output", 0 ); 
    78116    add_shortcut( "file" ); 
     117    add_shortcut( "audiofile" ); 
    79118    set_callbacks( Open, Close ); 
    80119vlc_module_end(); 
     
    86125{ 
    87126    aout_instance_t * p_aout = (aout_instance_t *)p_this; 
    88     FILE * p_file; 
    89     char * psz_name = config_GetPsz( p_this, "path" ); 
    90     char * psz_format = config_GetPsz( p_aout, "format" ); 
     127    char * psz_name = config_GetPsz( p_this, "audiofile-path" ); 
     128    char * psz_format = config_GetPsz( p_aout, "audiofile-format" ); 
    91129    char ** ppsz_compare = format_list; 
    92130    int i = 0; 
    93131 
    94  
    95     p_file = fopen( psz_name, "wb" ); 
    96     p_aout->output.p_sys = (void *)p_file; 
     132   /* Allocate structure */ 
     133    p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) ); 
     134    if( p_aout->output.p_sys == NULL ) 
     135    { 
     136        msg_Err( p_aout, "out of memory" ); 
     137        return VLC_EGENERIC; 
     138    } 
     139 
     140    p_aout->output.p_sys->p_file = fopen( psz_name, "wb" ); 
    97141    free( psz_name ); 
    98     if ( p_file == NULL ) return -1; 
     142    if ( p_aout->output.p_sys->p_file == NULL ) 
     143    { 
     144        free( p_aout->output.p_sys ); 
     145        return -1; 
     146    } 
    99147 
    100148    p_aout->output.pf_play = Play; 
     
    113161        msg_Err( p_aout, "Cannot understand the format string (%s)", 
    114162                 psz_format ); 
     163        fclose( p_aout->output.p_sys->p_file ); 
     164        free( p_aout->output.p_sys ); 
    115165        return -1; 
    116166    } 
     
    129179        aout_VolumeSoftInit( p_aout ); 
    130180    } 
     181 
     182    p_aout->output.p_sys->b_add_wav_header = 
     183        config_GetInt( p_this, "audiofile-wav" ); 
     184 
     185    if( p_aout->output.p_sys->b_add_wav_header ) 
     186    { 
     187        /* Write wave header */ 
     188        WAVEHEADER *wh = &p_aout->output.p_sys->waveh; 
     189 
     190        memset( wh, 0, sizeof(wh) ); 
     191 
     192        switch( p_aout->output.output.i_format ) 
     193        { 
     194        case VLC_FOURCC('f','l','3','2'): 
     195            wh->Format     = WAVE_FORMAT_IEEE_FLOAT; 
     196            wh->BitsPerSample = sizeof(float) * 8; 
     197            break; 
     198        case VLC_FOURCC('u','8',' ',' '): 
     199            wh->Format     = WAVE_FORMAT_PCM; 
     200            wh->BitsPerSample = 8; 
     201            break; 
     202        case VLC_FOURCC('s','1','6','l'): 
     203        default: 
     204            wh->Format     = WAVE_FORMAT_PCM; 
     205            wh->BitsPerSample = 16; 
     206            break; 
     207        } 
     208 
     209        wh->MainChunkID = VLC_FOURCC('R', 'I', 'F', 'F'); 
     210        wh->Length = 0;                    /* temp, to be filled in as we go */ 
     211        wh->ChunkTypeID = VLC_FOURCC('W', 'A', 'V', 'E'); 
     212        wh->SubChunkID = VLC_FOURCC('f', 'm', 't', ' '); 
     213        wh->SubChunkLength = 16; 
     214 
     215        wh->Modus = aout_FormatNbChannels( &p_aout->output.output ); 
     216        wh->SampleFreq = p_aout->output.output.i_rate; 
     217        wh->BytesPerSample = wh->Modus * ( wh->BitsPerSample / 8 ); 
     218        wh->BytesPerSec = wh->BytesPerSample * wh->SampleFreq; 
     219 
     220        wh->DataChunkID = VLC_FOURCC('d', 'a', 't', 'a'); 
     221        wh->DataLength = 0;                /* temp, to be filled in as we go */ 
     222 
     223        if( fwrite( wh, sizeof(WAVEHEADER), 1, 
     224                    p_aout->output.p_sys->p_file ) != 1 ) 
     225        { 
     226            msg_Err( p_aout, "write error (%s)", strerror(errno) ); 
     227        } 
     228    } 
     229 
    131230    return 0; 
    132231} 
     
    139238    aout_instance_t * p_aout = (aout_instance_t *)p_this; 
    140239 
    141     fclose( (FILE *)p_aout->output.p_sys ); 
     240    msg_Dbg( p_aout, "closing audio file" ); 
     241 
     242    if( p_aout->output.p_sys->b_add_wav_header ) 
     243    { 
     244        /* Update Wave Header */ 
     245        p_aout->output.p_sys->waveh.Length = 
     246            p_aout->output.p_sys->waveh.DataLength + sizeof(WAVEHEADER) - 4; 
     247 
     248        /* Write Wave Header */ 
     249        if( fseek( p_aout->output.p_sys->p_file, 0, SEEK_SET ) ) 
     250        { 
     251            msg_Err( p_aout, "seek error (%s)", strerror(errno) ); 
     252        } 
     253        if( fwrite( &p_aout->output.p_sys->waveh, sizeof(WAVEHEADER), 1, 
     254                    p_aout->output.p_sys->p_file ) != 1 ) 
     255        { 
     256            msg_Err( p_aout, "write error (%s)", strerror(errno) ); 
     257        } 
     258    } 
     259 
     260    fclose( p_aout->output.p_sys->p_file ); 
     261    free( p_aout->output.p_sys ); 
    142262} 
    143263 
     
    152272 
    153273    if( fwrite( p_buffer->p_buffer, p_buffer->i_nb_bytes, 1, 
    154                 (FILE *)p_aout->output.p_sys ) != 1 ) 
     274                p_aout->output.p_sys->p_file ) != 1 ) 
    155275    { 
    156276        msg_Err( p_aout, "write error (%s)", strerror(errno) ); 
     277    } 
     278 
     279    if( p_aout->output.p_sys->b_add_wav_header ) 
     280    { 
     281        /* Update Wave Header */ 
     282        p_aout->output.p_sys->waveh.DataLength += p_buffer->i_nb_bytes; 
    157283    } 
    158284 
    159285    aout_BufferFree( p_buffer ); 
    160286} 
    161