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

📄 input.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 3 页
字号:
                                                          "visualization",                                                          psz_parser, true );                    }                }            }            /* failure */            if ( p_filter->p_module == NULL )            {                msg_Err( p_aout, "cannot add user filter %s (skipped)",                         psz_parser );                vlc_object_detach( p_filter );                vlc_object_release( p_filter );                psz_parser = psz_next;                continue;            }            /* complete the filter chain if necessary */            if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &p_filter->input ) )            {                if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,                                                 &p_input->i_nb_filters,                                                 &chain_input_format,                                                 &p_filter->input ) < 0 )                {                    msg_Err( p_aout, "cannot add user filter %s (skipped)",                             psz_parser );                    module_Unneed( p_filter, p_filter->p_module );                    vlc_object_detach( p_filter );                    vlc_object_release( p_filter );                    psz_parser = psz_next;                    continue;                }            }            /* success */            p_filter->b_continuity = false;            p_input->pp_filters[p_input->i_nb_filters++] = p_filter;            memcpy( &chain_input_format, &p_filter->output,                    sizeof( audio_sample_format_t ) );            /* next filter if any */            psz_parser = psz_next;        }    }    free( psz_filters );    free( psz_visual );    /* complete the filter chain if necessary */    if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &chain_output_format ) )    {        if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,                                         &p_input->i_nb_filters,                                         &chain_input_format,                                         &chain_output_format ) < 0 )        {            inputFailure( p_aout, p_input, "couldn't set an input pipeline" );            return -1;        }    }    /* Prepare hints for the buffer allocator. */    p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;    p_input->input_alloc.i_bytes_per_sec = -1;    /* Create resamplers. */    if ( !AOUT_FMT_NON_LINEAR( &p_aout->mixer.mixer ) )    {        chain_output_format.i_rate = (__MAX(p_input->input.i_rate,                                            p_aout->mixer.mixer.i_rate)                                 * (100 + AOUT_MAX_RESAMPLING)) / 100;        if ( chain_output_format.i_rate == p_aout->mixer.mixer.i_rate )        {            /* Just in case... */            chain_output_format.i_rate++;        }        if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_resamplers,                                         &p_input->i_nb_resamplers,                                         &chain_output_format,                                         &p_aout->mixer.mixer ) < 0 )        {            inputFailure( p_aout, p_input, "couldn't set a resampler pipeline");            return -1;        }        aout_FiltersHintBuffers( p_aout, p_input->pp_resamplers,                                 p_input->i_nb_resamplers,                                 &p_input->input_alloc );        p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;        /* Setup the initial rate of the resampler */        p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;    }    p_input->i_resampling_type = AOUT_RESAMPLING_NONE;    p_input->p_playback_rate_filter = NULL;    for( int i = 0; i < p_input->i_nb_filters; i++ )    {        aout_filter_t *p_filter = p_input->pp_filters[i];        if( strcmp( "scaletempo", p_filter->psz_object_name ) == 0 )        {          p_input->p_playback_rate_filter = p_filter;          break;        }    }    if( ! p_input->p_playback_rate_filter && p_input->i_nb_resamplers > 0 )    {        p_input->p_playback_rate_filter = p_input->pp_resamplers[0];    }    aout_FiltersHintBuffers( p_aout, p_input->pp_filters,                             p_input->i_nb_filters,                             &p_input->input_alloc );    p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;    /* i_bytes_per_sec is still == -1 if no filters */    p_input->input_alloc.i_bytes_per_sec = __MAX(                                    p_input->input_alloc.i_bytes_per_sec,                                    (int)(p_input->input.i_bytes_per_frame                                     * p_input->input.i_rate                                     / p_input->input.i_frame_length) );    ReplayGainSelect( p_aout, p_input );    /* Success */    p_input->b_error = false;    p_input->b_restart = false;    p_input->i_last_input_rate = INPUT_RATE_DEFAULT;    return 0;}/***************************************************************************** * aout_InputDelete : delete an input ***************************************************************************** * This function must be entered with the mixer lock. *****************************************************************************/int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input ){    AOUT_ASSERT_MIXER_LOCKED;    if ( p_input->b_error ) return 0;    aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,                                 p_input->i_nb_filters );    p_input->i_nb_filters = 0;    aout_FiltersDestroyPipeline( p_aout, p_input->pp_resamplers,                                 p_input->i_nb_resamplers );    p_input->i_nb_resamplers = 0;    aout_FifoDestroy( p_aout, &p_input->fifo );    return 0;}/***************************************************************************** * aout_InputPlay : play a buffer ***************************************************************************** * This function must be entered with the input lock. *****************************************************************************//* XXX Do not activate it !! *///#define AOUT_PROCESS_BEFORE_CHEKSint aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,                    aout_buffer_t * p_buffer, int i_input_rate ){    mtime_t start_date;    AOUT_ASSERT_INPUT_LOCKED;    if( p_input->b_restart )    {        aout_fifo_t fifo, dummy_fifo;        uint8_t     *p_first_byte_to_mix;        aout_lock_mixer( p_aout );        aout_lock_input_fifos( p_aout );        /* A little trick to avoid loosing our input fifo */        aout_FifoInit( p_aout, &dummy_fifo, p_aout->mixer.mixer.i_rate );        p_first_byte_to_mix = p_input->p_first_byte_to_mix;        fifo = p_input->fifo;        p_input->fifo = dummy_fifo;        aout_InputDelete( p_aout, p_input );        aout_InputNew( p_aout, p_input );        p_input->p_first_byte_to_mix = p_first_byte_to_mix;        p_input->fifo = fifo;        aout_unlock_input_fifos( p_aout );        aout_unlock_mixer( p_aout );    }    if( i_input_rate != INPUT_RATE_DEFAULT && p_input->p_playback_rate_filter == NULL )    {        inputDrop( p_aout, p_input, p_buffer );        return 0;    }#ifdef AOUT_PROCESS_BEFORE_CHEKS    /* Run pre-filters. */    aout_FiltersPlay( p_aout, p_input->pp_filters, p_input->i_nb_filters,                      &p_buffer );    /* Actually run the resampler now. */    if ( p_input->i_nb_resamplers > 0 )    {        const mtime_t i_date = p_buffer->start_date;        aout_FiltersPlay( p_aout, p_input->pp_resamplers,                          p_input->i_nb_resamplers,                          &p_buffer );    }    if( p_buffer->i_nb_samples <= 0 )    {        aout_BufferFree( p_buffer );        return 0;    }#endif    /* Handle input rate change, but keep drift correction */    if( i_input_rate != p_input->i_last_input_rate )    {        unsigned int * const pi_rate = &p_input->p_playback_rate_filter->input.i_rate;#define F(r,ir) ( INPUT_RATE_DEFAULT * (r) / (ir) )        const int i_delta = *pi_rate - F(p_input->input.i_rate,p_input->i_last_input_rate);        *pi_rate = F(p_input->input.i_rate + i_delta, i_input_rate);#undef F        p_input->i_last_input_rate = i_input_rate;    }    /* We don't care if someone changes the start date behind our back after     * this. We'll deal with that when pushing the buffer, and compensate     * with the next incoming buffer. */    aout_lock_input_fifos( p_aout );    start_date = aout_FifoNextStart( p_aout, &p_input->fifo );    aout_unlock_input_fifos( p_aout );    if ( start_date != 0 && start_date < mdate() )    {        /* The decoder is _very_ late. This can only happen if the user         * pauses the stream (or if the decoder is buggy, which cannot         * happen :). */        msg_Warn( p_aout, "computed PTS is out of range (%"PRId64"), "                  "clearing out", mdate() - start_date );        aout_lock_input_fifos( p_aout );        aout_FifoSet( p_aout, &p_input->fifo, 0 );        p_input->p_first_byte_to_mix = NULL;        aout_unlock_input_fifos( p_aout );        if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )            msg_Warn( p_aout, "timing screwed, stopping resampling" );        inputResamplingStop( p_input );        start_date = 0;    }    if ( p_buffer->start_date < mdate() + AOUT_MIN_PREPARE_TIME )    {        /* The decoder gives us f*cked up PTS. It's its business, but we         * can't present it anyway, so drop the buffer. */        msg_Warn( p_aout, "PTS is out of range (%"PRId64"), dropping buffer",                  mdate() - p_buffer->start_date );        inputDrop( p_aout, p_input, p_buffer );        inputResamplingStop( p_input );        return 0;    }    /* If the audio drift is too big then it's not worth trying to resample     * the audio. */    mtime_t i_pts_tolerance = 3 * AOUT_PTS_TOLERANCE * i_input_rate / INPUT_RATE_DEFAULT;    if ( start_date != 0 &&         ( start_date < p_buffer->start_date - i_pts_tolerance ) )    {        msg_Warn( p_aout, "audio drift is too big (%"PRId64"), clearing out",                  start_date - p_buffer->start_date );        aout_lock_input_fifos( p_aout );        aout_FifoSet( p_aout, &p_input->fifo, 0 );        p_input->p_first_byte_to_mix = NULL;        aout_unlock_input_fifos( p_aout );        if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )            msg_Warn( p_aout, "timing screwed, stopping resampling" );        inputResamplingStop( p_input );        start_date = 0;    }    else if ( start_date != 0 &&              ( start_date > p_buffer->start_date + i_pts_tolerance) )    {        msg_Warn( p_aout, "audio drift is too big (%"PRId64"), dropping buffer",                  start_date - p_buffer->start_date );        inputDrop( p_aout, p_input, p_buffer );        return 0;    }    if ( start_date == 0 ) start_date = p_buffer->start_date;#ifndef AOUT_PROCESS_BEFORE_CHEKS    /* Run pre-filters. */    aout_FiltersPlay( p_aout, p_input->pp_filters, p_input->i_nb_filters,                      &p_buffer );#endif    /* Run the resampler if needed.     * We first need to calculate the output rate of this resampler. */    if ( ( p_input->i_resampling_type == AOUT_RESAMPLING_NONE ) &&         ( start_date < p_buffer->start_date - AOUT_PTS_TOLERANCE           || start_date > p_buffer->start_date + AOUT_PTS_TOLERANCE ) &&         p_input->i_nb_resamplers > 0 )    {        /* Can happen in several circumstances :         * 1. A problem at the input (clock drift)         * 2. A small pause triggered by the user

⌨️ 快捷键说明

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