⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 input.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 3 页
字号:
/***************************************************************************** * input.c : internal management of input streams for the audio output ***************************************************************************** * Copyright (C) 2002-2007 the VideoLAN team * $Id: 24de3d31c9a9eafaedbe74e4a50fde50ea6dfa04 $ * * Authors: Christophe Massiot <massiot@via.ecp.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#ifdef HAVE_CONFIG_H# include "config.h"#endif#include <vlc_common.h>#include <stdio.h>#include <string.h>#include <math.h>#include <assert.h>#include <vlc_input.h>                 /* for input_thread_t and i_pts_delay */#ifdef HAVE_ALLOCA_H#   include <alloca.h>#endif#include <vlc_aout.h>#include "aout_internal.h"/** FIXME: Ugly but needed to access the counters */#include "input/input_internal.h"#define AOUT_ASSERT_MIXER_LOCKED vlc_assert_locked( &p_aout->mixer_lock )#define AOUT_ASSERT_INPUT_LOCKED vlc_assert_locked( &p_input->lock )static void inputFailure( aout_instance_t *, aout_input_t *, const char * );static void inputDrop( aout_instance_t *, aout_input_t *, aout_buffer_t * );static void inputResamplingStop( aout_input_t *p_input );static int VisualizationCallback( vlc_object_t *, char const *,                                  vlc_value_t, vlc_value_t, void * );static int EqualizerCallback( vlc_object_t *, char const *,                              vlc_value_t, vlc_value_t, void * );static int ReplayGainCallback( vlc_object_t *, char const *,                               vlc_value_t, vlc_value_t, void * );static void ReplayGainSelect( aout_instance_t *, aout_input_t * );/***************************************************************************** * aout_InputNew : allocate a new input and rework the filter pipeline *****************************************************************************/int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input ){    audio_sample_format_t chain_input_format;    audio_sample_format_t chain_output_format;    vlc_value_t val, text;    char * psz_filters, *psz_visual;    int i_visual;    aout_FormatPrint( p_aout, "input", &p_input->input );    p_input->i_nb_resamplers = p_input->i_nb_filters = 0;    /* Prepare FIFO. */    aout_FifoInit( p_aout, &p_input->fifo, p_aout->mixer.mixer.i_rate );    p_input->p_first_byte_to_mix = NULL;    /* Prepare format structure */    memcpy( &chain_input_format, &p_input->input,            sizeof(audio_sample_format_t) );    memcpy( &chain_output_format, &p_aout->mixer.mixer,            sizeof(audio_sample_format_t) );    chain_output_format.i_rate = p_input->input.i_rate;    aout_FormatPrepare( &chain_output_format );    /* Now add user filters */    if( var_Type( p_aout, "visual" ) == 0 )    {        var_Create( p_aout, "visual", VLC_VAR_STRING | VLC_VAR_HASCHOICE );        text.psz_string = _("Visualizations");        var_Change( p_aout, "visual", VLC_VAR_SETTEXT, &text, NULL );        val.psz_string = (char*)""; text.psz_string = _("Disable");        var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );        val.psz_string = (char*)"spectrometer"; text.psz_string = _("Spectrometer");        var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );        val.psz_string = (char*)"scope"; text.psz_string = _("Scope");        var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );        val.psz_string = (char*)"spectrum"; text.psz_string = _("Spectrum");        var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );        val.psz_string = (char*)"vuMeter"; text.psz_string = _("Vu meter");        var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );        /* Look for goom plugin */        if( module_Exists( VLC_OBJECT(p_aout), "goom" ) )        {            val.psz_string = (char*)"goom"; text.psz_string = (char*)"Goom";            var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );        }        /* Look for galaktos plugin */        if( module_Exists( VLC_OBJECT(p_aout), "galaktos" ) )        {            val.psz_string = (char*)"galaktos"; text.psz_string = (char*)"GaLaktos";            var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );        }        if( var_Get( p_aout, "effect-list", &val ) == VLC_SUCCESS )        {            var_Set( p_aout, "visual", val );            free( val.psz_string );        }        var_AddCallback( p_aout, "visual", VisualizationCallback, NULL );    }    if( var_Type( p_aout, "equalizer" ) == 0 )    {        module_config_t *p_config;        int i;        p_config = config_FindConfig( VLC_OBJECT(p_aout), "equalizer-preset" );        if( p_config && p_config->i_list )        {               var_Create( p_aout, "equalizer",                           VLC_VAR_STRING | VLC_VAR_HASCHOICE );            text.psz_string = _("Equalizer");            var_Change( p_aout, "equalizer", VLC_VAR_SETTEXT, &text, NULL );            val.psz_string = (char*)""; text.psz_string = _("Disable");            var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE, &val, &text );            for( i = 0; i < p_config->i_list; i++ )            {                val.psz_string = (char *)p_config->ppsz_list[i];                text.psz_string = (char *)p_config->ppsz_list_text[i];                var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE,                            &val, &text );            }            var_AddCallback( p_aout, "equalizer", EqualizerCallback, NULL );        }    }    if( var_Type( p_aout, "audio-filter" ) == 0 )    {        var_Create( p_aout, "audio-filter",                    VLC_VAR_STRING | VLC_VAR_DOINHERIT );        text.psz_string = _("Audio filters");        var_Change( p_aout, "audio-filter", VLC_VAR_SETTEXT, &text, NULL );    }    if( var_Type( p_aout, "audio-visual" ) == 0 )    {        var_Create( p_aout, "audio-visual",                    VLC_VAR_STRING | VLC_VAR_DOINHERIT );        text.psz_string = _("Audio visualizations");        var_Change( p_aout, "audio-visual", VLC_VAR_SETTEXT, &text, NULL );    }    if( var_Type( p_aout, "audio-replay-gain-mode" ) == 0 )    {        module_config_t *p_config;        int i;        p_config = config_FindConfig( VLC_OBJECT(p_aout), "audio-replay-gain-mode" );        if( p_config && p_config->i_list )        {            var_Create( p_aout, "audio-replay-gain-mode",                        VLC_VAR_STRING | VLC_VAR_DOINHERIT );            text.psz_string = _("Replay gain");            var_Change( p_aout, "audio-replay-gain-mode", VLC_VAR_SETTEXT, &text, NULL );            for( i = 0; i < p_config->i_list; i++ )            {                val.psz_string = (char *)p_config->ppsz_list[i];                text.psz_string = (char *)p_config->ppsz_list_text[i];                var_Change( p_aout, "audio-replay-gain-mode", VLC_VAR_ADDCHOICE,                            &val, &text );            }            var_AddCallback( p_aout, "audio-replay-gain-mode", ReplayGainCallback, NULL );        }    }    if( var_Type( p_aout, "audio-replay-gain-preamp" ) == 0 )    {        var_Create( p_aout, "audio-replay-gain-preamp",                    VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );    }    if( var_Type( p_aout, "audio-replay-gain-default" ) == 0 )    {        var_Create( p_aout, "audio-replay-gain-default",                    VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );    }    if( var_Type( p_aout, "audio-replay-gain-peak-protection" ) == 0 )    {        var_Create( p_aout, "audio-replay-gain-peak-protection",                    VLC_VAR_BOOL | VLC_VAR_DOINHERIT );    }    var_Get( p_aout, "audio-filter", &val );    psz_filters = val.psz_string;    var_Get( p_aout, "audio-visual", &val );    psz_visual = val.psz_string;    /* parse user filter lists */    for( i_visual = 0; i_visual < 2; i_visual++ )    {        char *psz_next = NULL;        char *psz_parser = i_visual ? psz_visual : psz_filters;        if( psz_parser == NULL || !*psz_parser )            continue;        while( psz_parser && *psz_parser )        {            aout_filter_t * p_filter = NULL;            if( p_input->i_nb_filters >= AOUT_MAX_FILTERS )            {                msg_Dbg( p_aout, "max filters reached (%d)", AOUT_MAX_FILTERS );                break;            }            while( *psz_parser == ' ' && *psz_parser == ':' )            {                psz_parser++;            }            if( ( psz_next = strchr( psz_parser , ':'  ) ) )            {                *psz_next++ = '\0';            }            if( *psz_parser =='\0' )            {                break;            }            /* Create a VLC object */            static const char typename[] = "audio filter";            p_filter = vlc_custom_create( p_aout, sizeof(*p_filter),                                          VLC_OBJECT_GENERIC, typename );            if( p_filter == NULL )            {                msg_Err( p_aout, "cannot add user filter %s (skipped)",                         psz_parser );                psz_parser = psz_next;                continue;            }            vlc_object_attach( p_filter , p_aout );            /* try to find the requested filter */            if( i_visual == 1 ) /* this can only be a visualization module */            {                /* request format */                memcpy( &p_filter->input, &chain_output_format,                        sizeof(audio_sample_format_t) );                memcpy( &p_filter->output, &chain_output_format,                        sizeof(audio_sample_format_t) );                p_filter->p_module = module_Need( p_filter, "visualization",                                                  psz_parser, true );            }            else /* this can be a audio filter module as well as a visualization module */            {                /* request format */                memcpy( &p_filter->input, &chain_input_format,                        sizeof(audio_sample_format_t) );                memcpy( &p_filter->output, &chain_output_format,                        sizeof(audio_sample_format_t) );                p_filter->p_module = module_Need( p_filter, "audio filter",                                              psz_parser, true );                if ( p_filter->p_module == NULL )                {                    /* if the filter requested a special format, retry */                    if ( !( AOUT_FMTS_IDENTICAL( &p_filter->input,                                                 &chain_input_format )                            && AOUT_FMTS_IDENTICAL( &p_filter->output,                                                    &chain_output_format ) ) )                    {                        aout_FormatPrepare( &p_filter->input );                        aout_FormatPrepare( &p_filter->output );                        p_filter->p_module = module_Need( p_filter,                                                          "audio filter",                                                          psz_parser, true );                    }                    /* try visual filters */                    else                    {                        memcpy( &p_filter->input, &chain_output_format,                                sizeof(audio_sample_format_t) );                        memcpy( &p_filter->output, &chain_output_format,                                sizeof(audio_sample_format_t) );                        p_filter->p_module = module_Need( p_filter,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -