網頁

2016年3月15日 星期二

VLC 追蹤之四 aout stream

src/playlist/engine.c -> playlist_Create -> input_resource_GetAout
src/input/resource.c -> input_resource_GetAout -> aout_New
src/audio_output_output.c -> aout_New -> module_need(audio output)

載入 mmdevice 時登記了 start
modules/audio_output/mmdevice.c
    set_capability("audio output", 150)
    set_callbacks(Open, Close)
static int Open(vlc_object_t *obj)
    aout->start = Start;

src/input/decoder.c
input_DecoderNew -> decoder_New -> CreateDecoder
    p_dec->pf_aout_format_update = aout_update_format;
    p_dec->pf_vout_format_update = vout_update_format;
input_DecoderNew -> decoder_New -> CreateDecoder -> LoadDecoder
    p_dec->p_module = module_need( p_dec, "decoder", "$codec", false );
此時載入了 avcodec, 並登記了 pf_vout_format_update

載入 g711 時登記了 pf_decode_audio
modules/codec/g711.c
    set_capability( "decoder", 100 )
    set_callbacks( DecoderOpen, DecoderClose )
static int DecoderOpen( vlc_object_t *p_this )
    p_dec->pf_decode_audio = DecodeBlock;

透過 pf_decode_audio 執行 DecodeBlock
src/input/es_out.c
input_DecoderNew -> decoder_New -> vlc_clone(DecoderThread)
src/input/decoder.c
DecoderThread -> DecoderProcess -> DecoderProcessAudio -> DecoderDecodeAudio
static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
    while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, pp_block ) ) )

透過 pf_aout_format_update 執行 aout_update_format
modules/codec/g711.c -> DecodeBlock -> decoder_NewAudioBuffer
include/vlc_codec.h -> decoder_UpdateAudioFormat
    return dec->pf_aout_format_update( dec );

透過 start 執行 Start
src/input/decoder.c -> aout_update_format -> aout_DecNew
src/audio_output/dec.c -> aout_DecNew -> aout_OutputNew
src/audio_output/output.c -> aout_OutputNew
    aout->start (aout, fmt)

最後載入 aout stream
modules/audio_output/mmdevice.c -> Start ->vlc_module_load(aout stream)

順便一提,之後載入 audio volume
src/audio_output/dec.c -> aout_DecNew -> aout_volume_SetFormat
src/audio_output/volume.c -> aout_volume_SetFormat -> module_need(audio volume)

載入 audio filter
src/audio_output/dec.c -> aout_DecNew -> aout_FiltersNew
src/audio_output/filters.c -> aout_FiltersNew -> AppendFilter(audio filter) -> CreateFilter(audio filter) -> module_need(audio filter)


載入 audio converter(audio_format)
src/audio_output/filters.c -> AppendFilter -> aout_FiltersPipelineCreate (Format) -> TryFormat -> FindConvert -> CreateFilter(audio converter) -> module_need(audio converter) -> audio_format

載入 audio converter(trivial)
src/audio_output/filters.c -> aout_FiltersNew -> aout_FiltersPipelineCreate (Remix channels) -> TryFormat -> FindConvert -> CreateFilter(audio converter) -> module_need(audio converter) -> trivial

載入 audio resampler(samplerate)
src/audio_output/filters.c -> aout_FiltersNew -> FindResampler -> CreateFilter(audio resampler) -> module_need(audio resampler) -> samplerate





沒有留言:

張貼留言