Ticket #798: auto-ac3-disable.diff

File auto-ac3-disable.diff, 4.2 KB (added by doug@…, 20 years ago)
  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    27842784#ifdef USING_DIRECTX
    27852785        audioOutput->Reset();
    27862786#endif
     2787        if (decoder)
     2788        {
     2789            bool disable = audio_stretchfactor < 0.99 ||
     2790                audio_stretchfactor > 1.01;
     2791            decoder->DisableAC3PassThrough(disable);
     2792            VERBOSE(VB_IMPORTANT, QString("stretchfactor %1 disable %2")
     2793                    .arg(audio_stretchfactor)
     2794                    .arg(disable));
     2795        }
    27872796    }
    27882797
    27892798    //cout << "setting unpaused" << endl << endl;
  • libs/libmythtv/avformatdecoder.cpp

     
    177177      ccd(new CCDecoder(this)),
    178178      // Audio
    179179      audioSamples(new short int[AVCODEC_MAX_AUDIO_FRAME_SIZE]),
    180       allow_ac3_passthru(false),
     180      disable_ac3_passthru(false), allow_ac3_passthru(false),
    181181      // Audio selection
    182182      wantedAudioStream(),    selectedAudioStream(),
    183183      // Subtitle selection
     
    449449#endif
    450450}
    451451
     452void AvFormatDecoder::DisableAC3PassThrough(bool disable)
     453{
     454    AVStream *curstream = NULL;
     455    AVCodecContext *codec_ctx = NULL;
     456    curstream = ic->streams[selectedAudioStream.av_stream_index];
     457    if (!curstream)
     458        return;
     459    codec_ctx = curstream->codec;       
     460    if (!codec_ctx)
     461        return;
     462
     463    bool do_ac3_passthru = (allow_ac3_passthru && !transcoding &&
     464                            !disable_ac3_passthru &&
     465                            (codec_ctx->codec_id == CODEC_ID_AC3));
     466
     467    disable_ac3_passthru = disable;
     468
     469    if (disable_ac3_passthru == do_ac3_passthru)
     470    {
     471        // Force ac3_passthru state to be reanalyzed
     472        VERBOSE(VB_AUDIO, QString("DisableAC3PassThrough: %1")
     473                .arg(disable_ac3_passthru));
     474
     475        setCurrentAudioTrack(currentAudioTrack);
     476    }
     477}
     478
    452479bool AvFormatDecoder::CanHandle(char testbuf[2048], const QString &filename)
    453480{
    454481    av_register_all();
     
    24672494        assert(curstream->codec);
    24682495        codec_ctx = curstream->codec;       
    24692496        bool do_ac3_passthru = (allow_ac3_passthru && !transcoding &&
     2497                                !disable_ac3_passthru &&
    24702498                                (codec_ctx->codec_id == CODEC_ID_AC3));
    24712499        info = AudioInfo(codec_ctx->codec_id,
    24722500                         codec_ctx->sample_rate, codec_ctx->channels,
  • libs/libmythtv/avformatdecoder.h

     
    8383    void CloseContext();
    8484    void Reset(void);
    8585    void Reset(bool reset_video_data = true, bool seek_reset = true);
     86    void DisableAC3PassThrough(bool disable);
    8687
    8788    /// Perform an av_probe_input_format on the passed data to see if we
    8889    /// can decode it with this class.
     
    232233
    233234    // Audio
    234235    short int        *audioSamples;
     236    bool              disable_ac3_passthru;
    235237    bool              allow_ac3_passthru;
    236238
    237239    AudioInfo         audioIn;
  • libs/libmythtv/decoderbase.cpp

     
    6262    ateof = false;
    6363}
    6464
     65void DecoderBase::DisableAC3PassThrough(bool disable)
     66{
     67    (void)disable;
     68}
     69
    6570void DecoderBase::SeekReset(long long newKey, int skipFrames, bool needFlush)
    6671{
    6772    (void)newKey, (void)skipFrames, (void)needFlush;
  • libs/libmythtv/decoderbase.h

     
    1818    virtual ~DecoderBase();
    1919
    2020    virtual void Reset(void);
     21    virtual void DisableAC3PassThrough(bool disable);
    2122
    2223    virtual int OpenFile(RingBuffer *rbuffer, bool novideo,
    2324                         char testbuf[2048]) = 0;