Ticket #13294: 20181012_1730_musicchoice.patch

File 20181012_1730_musicchoice.patch, 5.0 KB (added by Peter Bennett, 4 years ago)

Fixes problem of regular interruptions in music choice audio.

  • mythtv/libs/libmythtv/mythplayer.cpp

    diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
    index 7f354bedecd..99e826e62b1 100644
    a b void MythPlayer::AVSync(VideoFrame *buffer, bool limit_delay) 
    19151915        }
    19161916        else
    19171917        {
    1918             dropframe = true;
     1918            dropframe = !FlagIsSet(kMusicChoice);
    19191919            dbg = QString("A/V predict drop frame, refreshrate %1, avsync_predictor %2, diverge %3, ")
    19201920            .arg(refreshrate).arg(avsync_predictor).arg(diverge);
    19211921        }
    void MythPlayer::AVSync(VideoFrame *buffer, bool limit_delay) 
    19231923
    19241924    if (max_video_behind)
    19251925    {
    1926         dropframe = true;
     1926        dropframe = !FlagIsSet(kMusicChoice);
    19271927        // If video is way behind of audio, adjust for it...
    19281928        dbg = QString("Video is %1 frames behind audio (too slow), ")
    19291929            .arg(-diverge);
    bool MythPlayer::PrebufferEnoughFrames(int min_buffers) 
    22362236        {
    22372237            float current   = ComputeSecs(framesPlayed, true);
    22382238            float length    = ComputeSecs(totalFrames, true);
    2239             if (length > current && length - current < 1.5)
     2239            if (length > current && length - current < 1.5
     2240                && !FlagIsSet(kMusicChoice))
    22402241            {
    22412242                LOG(VB_PLAYBACK, LOG_NOTICE, LOC +
    22422243                    QString("Pause to allow live tv catch up. Position in sec. Current: %2, Total: %3")
    bool MythPlayer::PrebufferEnoughFrames(int min_buffers) 
    22492250        usleep(frame_interval >> 3);
    22502251        int waited_for = buffering_start.msecsTo(QTime::currentTime());
    22512252        int last_msg = buffering_last_msg.msecsTo(QTime::currentTime());
    2252         if (last_msg > 100)
     2253        if (last_msg > 100 && !FlagIsSet(kMusicChoice))
    22532254        {
    22542255            if (++bufferingCounter == 10)
    22552256                LOG(VB_GENERAL, LOG_NOTICE, LOC +
    bool MythPlayer::PrebufferEnoughFrames(int min_buffers) 
    22632264                    QString("Waited %1ms for video buffers %2")
    22642265                        .arg(waited_for).arg(videoOutput->GetFrameStatus()));
    22652266            buffering_last_msg = QTime::currentTime();
    2266             // music choice only sends a frame every 6 seconds
    2267             // so wait 7 seconds before doing this reset
    2268             if (waited_for > 7000 && audio.IsBufferAlmostFull())
     2267            if (audio.GetAudioBufferedTime() > 2000 && framesPlayed < 5
     2268                && gCoreContext->GetNumSetting("MusicChoiceEnabled", 0))
     2269            {
     2270                playerFlags = (PlayerFlags)(playerFlags | kMusicChoice);
     2271                LOG(VB_GENERAL, LOG_NOTICE, LOC +
     2272                    "Music Choice program detected - disabling AV Sync.");
     2273            }
     2274            if (waited_for > 7000 && audio.IsBufferAlmostFull()
     2275                && !FlagIsSet(kMusicChoice))
    22692276            {
    22702277                // We are likely to enter this condition
    22712278                // if the audio buffer was too full during GetFrame in AVFD
  • mythtv/libs/libmythtv/mythplayer.h

    diff --git a/mythtv/libs/libmythtv/mythplayer.h b/mythtv/libs/libmythtv/mythplayer.h
    index fd4741e1db7..b6352005e37 100644
    a b enum PlayerFlags 
    9999    kVideoIsNull          = 0x000100,
    100100    kAudioMuted           = 0x010000,
    101101    kNoITV                = 0x020000,
     102    kMusicChoice          = 0x040000,
    102103};
    103104
    104105#define FlagIsSet(arg) (playerFlags & arg)
  • mythtv/programs/mythfrontend/globalsettings.cpp

    diff --git a/mythtv/programs/mythfrontend/globalsettings.cpp b/mythtv/programs/mythfrontend/globalsettings.cpp
    index b3810d8b4a0..2e3ac3fe2f5 100644
    a b static HostCheckBoxSetting *EndOfRecordingExitPrompt() 
    16811681    return gc;
    16821682}
    16831683
     1684static HostCheckBoxSetting *MusicChoiceEnabled()
     1685{
     1686    HostCheckBoxSetting *gc = new HostCheckBoxSetting("MusicChoiceEnabled");
     1687
     1688    gc->setLabel(PlaybackSettings::tr("Enable Music Choice"));
     1689
     1690    gc->setValue(false);
     1691
     1692    gc->setHelpText(PlaybackSettings::tr("Enable this to improve playing of Music Choice channels "
     1693                                         "or recordings from those channels. "
     1694                                         "These are audio channels with slide show "
     1695                                         "from some cable providers. "
     1696                                         "In unusual situations this could cause lip sync problems "
     1697                                         "watching normal videos or TV shows."));
     1698    return gc;
     1699}
     1700
    16841701static HostCheckBoxSetting *JumpToProgramOSD()
    16851702{
    16861703    HostCheckBoxSetting *gc = new HostCheckBoxSetting("JumpToProgramOSD");
    void PlaybackSettings::Load(void) 
    41044121    general->addChild(PIPLocationComboBox());
    41054122    general->addChild(PlaybackExitPrompt());
    41064123    general->addChild(EndOfRecordingExitPrompt());
     4124    general->addChild(MusicChoiceEnabled());
    41074125    addChild(general);
    41084126
    41094127    m_playbackProfiles = CurrentPlaybackProfile();