Ticket #3028: passthrough_toggle-patch.diff

File passthrough_toggle-patch.diff, 10.3 KB (added by maillists@…, 17 years ago)

proposed patch

  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    274274    m_DeintSetting   = gContext->GetNumSetting("Deinterlace", 0);
    275275    decode_extra_audio=gContext->GetNumSetting("DecodeExtraAudio", 0);
    276276    itvEnabled       = gContext->GetNumSetting("EnableMHEG", 0);
     277    passthru_enabled  = gContext->GetNumSetting("InitPassThrough", 1);
    277278
    278279    lastIgnoredManualSkip = QDateTime::currentDateTime().addSecs(-10);
    279280
     
    37793780    paused = actuallypaused = true;
    37803781}
    37813782
     3783
     3784bool NuppelVideoPlayer::ToggleAudioPassThrough(void)
     3785{
     3786    passthru_enabled = !passthru_enabled;
     3787    if (decoder) {
     3788        bool disabled = DoSetDisableAudioPassThrough();
     3789
     3790        VERBOSE(VB_IMPORTANT, QString("PassThrough: %1").arg(disabled ? "Disabled" : "Enabled"));
     3791    }
     3792    return passthru_enabled;
     3793}
     3794
     3795
     3796bool NuppelVideoPlayer::AudioPassThroughAvailable(void)
     3797{
     3798    return (play_speed == 1.00f) && decoder && decoder->CouldPassThrough();
     3799}
     3800
     3801
     3802bool NuppelVideoPlayer::DoSetDisableAudioPassThrough()
     3803{
     3804    bool disabled = !passthru_enabled;
     3805   
     3806    if (!disabled) {
     3807        disabled = !AudioPassThroughAvailable();
     3808    }
     3809    if (decoder) {
     3810        decoder->SetDisablePassThrough(disabled);
     3811    }
     3812    return disabled;
     3813}
     3814
     3815
    37823816void NuppelVideoPlayer::DoPlay(void)
    37833817{
    37843818    bool skip_changed;
     
    38743908        audio_stretchfactor = play_speed;
    38753909        if (decoder)
    38763910        {
    3877             bool disable = (play_speed < 0.99f) || (play_speed > 1.01f);
     3911            bool disable = DoSetDisableAudioPassThrough();
     3912
    38783913            VERBOSE(VB_PLAYBACK, LOC +
    38793914                    QString("Stretch Factor %1, %2 passthru ")
    38803915                    .arg(audio_stretchfactor)
    38813916                    .arg((disable) ? "disable" : "allow"));
    3882             decoder->SetDisablePassThrough(disable);
    38833917        }
    38843918        if (audioOutput)
    38853919        {
     
    64506484        decoder = dec;
    64516485        delete d;
    64526486    }
     6487    DoSetDisableAudioPassThrough();
    64536488}
    64546489
    64556490/** \fn NuppelVideoPlayer::LoadExternalSubtitles(const QString&)
  • libs/libmythtv/decoderbase.h

     
    6868    void SetLowBuffers(bool low) { lowbuffers = low; }
    6969    /// Disables AC3/DTS pass through
    7070    virtual void SetDisablePassThrough(bool disable) { (void)disable; }
     71    // Checks if could potentially passthrough (ignoring disable flag)
     72    virtual bool CouldPassThrough(void) { return false; }
    7173
    7274    virtual void setWatchingRecording(bool mode);
    7375    virtual bool GetFrame(int onlyvideo) = 0;
  • libs/libmythtv/avformatdecoder.cpp

     
    33973397    }
    33983398}
    33993399
     3400
     3401bool AvFormatDecoder::CouldPassThrough(void)
     3402{
     3403    bool could_passthru = false;
     3404    AVStream *curstream = NULL;
     3405
     3406    if ((currentTrack[kTrackTypeAudio] >= 0) &&
     3407        (selectedTrack[kTrackTypeAudio].av_stream_index <= ic->nb_streams) &&
     3408        (curstream = ic->streams[selectedTrack[kTrackTypeAudio]
     3409                                 .av_stream_index]))
     3410    {
     3411        could_passthru = DoCheckPassThrough(curstream->codec);       
     3412    }
     3413    return could_passthru;
     3414}
     3415
     3416
     3417bool AvFormatDecoder::DoCheckPassThrough(AVCodecContext *codec_ctx)
     3418{
     3419    bool could_passthru = false;
     3420
     3421    if (codec_ctx && !transcoding)
     3422    {
     3423        could_passthru = (allow_ac3_passthru &&
     3424                                (codec_ctx->codec_id == CODEC_ID_AC3));
     3425        could_passthru |= (allow_dts_passthru &&
     3426                                (codec_ctx->codec_id == CODEC_ID_DTS));
     3427    }
     3428    return could_passthru;
     3429}
     3430
     3431
    34003432/** \fn AvFormatDecoder::SetupAudioStream(void)
    34013433 *  \brief Reinitializes audio if it needs to be reinitialized.
    34023434 *
     
    34203452        assert(curstream);
    34213453        assert(curstream->codec);
    34223454        codec_ctx = curstream->codec;       
    3423         bool do_ac3_passthru = (allow_ac3_passthru && !transcoding &&
    3424                                 !disable_passthru &&
    3425                                 (codec_ctx->codec_id == CODEC_ID_AC3));
    3426         bool do_dts_passthru = (allow_dts_passthru && !transcoding &&
    3427                                 !disable_passthru &&
    3428                                 (codec_ctx->codec_id == CODEC_ID_DTS));
    34293455        info = AudioInfo(codec_ctx->codec_id,
    34303456                         codec_ctx->sample_rate, codec_ctx->channels,
    3431                          do_ac3_passthru || do_dts_passthru);
     3457                         !disable_passthru && DoCheckPassThrough(codec_ctx));
    34323458    }
    34333459
    34343460    if (info == audioIn)
  • libs/libmythtv/tv_play.h

     
    235235    void ToggleMute(void);
    236236    void ToggleLetterbox(int letterboxMode = -1);
    237237
     238    void ToggleAudioPassThrough();
     239
    238240    bool FillMenuTracks(OSDGenericTree*, uint type);
    239241    void ChangeTrack(uint type, int dir);
    240242    void SetTrack(uint type, int trackNo);
  • libs/libmythtv/NuppelVideoPlayer.h

     
    390390        hidedvdbutton = hide;
    391391    }
    392392
     393    bool ToggleAudioPassThrough(void);
     394    bool AudioPassThroughAvailable(void);
     395
    393396  protected:
    394397    void DisplayPauseFrame(void);
    395398    void DisplayNormalFrame(void);
     
    502505    long long GetDVDBookmark(void) const;
    503506    void SetDVDBookmark(long long frames);
    504507
     508    bool DoSetDisableAudioPassThrough(void);
     509
    505510  private:
    506511    VideoOutputType forceVideoOutput;
    507512
     
    776781
    777782    // Debugging variables
    778783    Jitterometer *output_jmeter;
     784
     785    bool passthru_enabled;
    779786};
    780787
    781788#endif
  • libs/libmythtv/tv_play.cpp

     
    326326    REG_KEY("TV Playback", "JUMPTODVDROOTMENU", "Jump to the DVD Root Menu", "");
    327327    REG_KEY("TV Playback", "EXITSHOWNOPROMPTS","Exit Show without any prompts", "");
    328328
     329    REG_KEY("TV Playback", "TOGGLEPASSTHRU", "Toggle Audio PassThrough","");
     330
    329331    /* Editing keys */
    330332    REG_KEY("TV Editing", "CLEARMAP", "Clear editing cut points", "C,Q,Home");
    331333    REG_KEY("TV Editing", "INVERTMAP", "Invert Begin/End cut points", "I");
     
    22372239                ToggleRecord();
    22382240            else if (action == "VOLUMEDOWN" || action == "VOLUMEUP" ||
    22392241                     action == "STRETCHINC" || action == "STRETCHDEC" ||
    2240                      action == "MUTE" || action == "TOGGLEASPECT")
     2242                     action == "MUTE" || action == "TOGGLEASPECT" ||
     2243                     action == "TOGGLEPASSTHRU")
    22412244            {
    22422245                passThru = 1;
    22432246                handled = false;
     
    22882291            else if (action == "VOLUMEDOWN" || action == "VOLUMEUP" ||
    22892292                     action == "STRETCHINC" || action == "STRETCHDEC" ||
    22902293                     action == "MUTE" || action == "PAUSE" ||
    2291                      action == "CLEAROSD")
     2294                     action == "CLEAROSD" || action == "TOGGLEPASSTHRU")
    22922295            {
    22932296                passThru = 1;
    22942297                handled = false;
     
    28112814            ChangeVolume(true);
    28122815        else if (action == "MUTE")
    28132816            ToggleMute();
     2817        else if (action == "TOGGLEPASSTHRU")
     2818            ToggleAudioPassThrough();
    28142819        else if (action == "STRETCHINC")
    28152820            ChangeTimeStretch(1);
    28162821        else if (action == "STRETCHDEC")
     
    48914896    tHrsMin.sprintf("%d:%02d", hours, min);
    48924897}
    48934898
    4894 
    48954899void TV::ShowLCDDVDInfo(void)
    48964900{
    48974901    class LCD * lcd = LCD::Get();
     
    53865390        GetOSD()->SetSettingsText(text, 5);
    53875391}
    53885392
     5393
     5394void TV::ToggleAudioPassThrough(void)
     5395{
     5396    QString text;
     5397    if (nvp->AudioPassThroughAvailable()) {
     5398        bool passThr = nvp->ToggleAudioPassThrough();
     5399
     5400        text = tr("PassThrough: %1").arg(passThr ? tr("Enabled") :
     5401                                                   tr("Disabled"));
     5402       
     5403        if (GetOSD() && !browsemode)
     5404            GetOSD()->SetSettingsText(text, 5);
     5405    }
     5406}
     5407
     5408
     5409
    53895410void TV::ToggleSleepTimer(void)
    53905411{
    53915412    QString text;
     
    65406561            DoQueueTranscode("Medium Quality");
    65416562        else if (action == "QUEUETRANSCODE_LOW")
    65426563            DoQueueTranscode("Low Quality");
     6564        else if (action == "TOGGLEPASSTHRU")
     6565            ToggleAudioPassThrough();
    65436566        else if (action.left(8) == "JUMPPROG")
    65446567        {
    65456568            SetJumpToProgram(action.section(" ",1,-2),
     
    67016724    FillMenuTracks(treeMenu, kTrackTypeSubtitle);
    67026725    FillMenuTracks(treeMenu, kTrackTypeCC708);
    67036726
     6727    if (nvp->AudioPassThroughAvailable())
     6728        item = new OSDGenericTree(treeMenu, tr("Toggle Audio PassThrough"),
     6729                                  "TOGGLEPASSTHRU");
     6730
    67046731    if (VBIMode::NTSC_CC == vbimode)
    67056732        FillMenuTracks(treeMenu, kTrackTypeCC608);
    67066733    else if (VBIMode::PAL_TT == vbimode)
  • libs/libmythtv/avformatdecoder.h

     
    123123    MythCodecID GetVideoCodecID() const { return video_codec_id; }
    124124
    125125    virtual void SetDisablePassThrough(bool disable);
     126    virtual bool CouldPassThrough(void);
    126127    void AddTextData(unsigned char *buf, int len, long long timecode, char type);
    127128
    128129    virtual QString GetTrackDesc(uint type, uint trackNo) const;
     
    186187                        int width, int height);
    187188
    188189    void SeekReset(long long, uint skipFrames, bool doFlush, bool discardFrames);
     190    bool DoCheckPassThrough(AVCodecContext *codec_ctx);
    189191
    190192    bool SetupAudioStream(void);
    191193    void SetupAudioStreamSubIndexes(int streamIndex);
     
    259261    bool dvd_xvmc_enabled;
    260262    bool dvd_video_codec_changed;
    261263
     264
    262265};
    263266
    264267#endif