Ticket #4262: myth_saveaudiosync_r14915_v3.diff

File myth_saveaudiosync_r14915_v3.diff, 7.8 KB (added by Mark Buechler <Mark.Buechler@…>, 11 years ago)

Forgot to initialize audiosyncSaved and set it on SaveAudiosyncToDb?().

  • libs/libmythtv/dbcheck.cpp

    diff -rup mythtv.orig/libs/libmythtv/dbcheck.cpp mythtv/libs/libmythtv/dbcheck.cpp
    old new using namespace std; 
    1111#include "datadirect.h" // for DataDirectProcessor::FixProgramIDs
    1212
    1313/// This is the DB schema version expected by the running MythTV instance.
    14 const QString currentDatabaseVersion = "1201";
     14const QString currentDatabaseVersion = "1202";
    1515
    1616static bool UpdateDBVersionNumber(const QString &newnumber);
    1717static bool performActualUpdate(const QString updates[], QString version,
    thequery, 
    32903290            return false;
    32913291    }
    32923292
     3293    if (dbver == "1201")
     3294    {
     3295        MSqlQuery query(MSqlQuery::InitCon());
     3296        const QString updates[] = {
     3297"ALTER TABLE channel ADD audiosync int(4) NULL default 0;",
     3298""
     3299};
     3300        if (!performActualUpdate(updates, "1202", dbver))
     3301            return false;
     3302    }
     3303
    32933304//"ALTER TABLE cardinput DROP COLUMN preference;" in 0.22
    32943305//"ALTER TABLE channel DROP COLUMN atscsrcid;" in 0.22
    32953306//"ALTER TABLE recordedmarkup DROP COLUMN offset;" in 0.22
  • libs/libmythtv/NuppelVideoPlayer.h

    diff -rup mythtv.orig/libs/libmythtv/NuppelVideoPlayer.h mythtv/libs/libmythtv/NuppelVideoPlayer.h
    old new class MPUBLIC NuppelVideoPlayer : public 
    374374    bool SetVideoByComponentTag(int tag);
    375375
    376376    // Time Code adjustment stuff
     377    long long SetAudioTimecodeOffset(long long v)
     378        { tc_wrap[TC_AUDIO] = v;   return tc_wrap[TC_AUDIO]; }
    377379    long long AdjustAudioTimecodeOffset(long long v)
    378380        { tc_wrap[TC_AUDIO] += v;  return tc_wrap[TC_AUDIO]; }
    379381    long long ResetAudioTimecodeOffset(void)
  • libs/libmythtv/tv_play.cpp

    diff -rup mythtv.orig/libs/libmythtv/tv_play.cpp mythtv/libs/libmythtv/tv_play.cpp
    old new void TV::InitKeys(void) 
    373373    REG_KEY("TV Playback", "TOGGLESTRETCH", "Toggle time stretch speed", "");
    374374    REG_KEY("TV Playback", "TOGGLEAUDIOSYNC",
    375375            "Turn on audio sync adjustment controls", "");
     376    REG_KEY("TV Playback", "SAVEAUDIOSYNC", "Save adjusted audio sync", "");
    376377    REG_KEY("TV Playback", "TOGGLEPICCONTROLS",
    377378            "Playback picture adjustments",                    "F");
    378379    REG_KEY("TV Playback", "TOGGLECHANCONTROLS",
    TV::TV(void) 
    491492      exitPlayer(false), paused(false), errored(false),
    492493      stretchAdjustment(false),
    493494      audiosyncAdjustment(false), audiosyncBaseline(LONG_LONG_MIN),
     495      audiosyncSaved(0),
    494496      editmode(false),     zoomMode(false),
    495497      sigMonMode(false),
    496498      update_osd_pos(false), endOfRecording(false),
    bool TV::StartPlayer(bool isWatchingReco 
    14131415        activenvp = nvp;
    14141416        activerbuffer = prbuffer;
    14151417        StartOSD();
     1418        SetAudioSyncFromDb();
    14161419        return true;
    14171420    }
    14181421    VERBOSE(VB_IMPORTANT, LOC_ERR +
    void TV::SwitchCards(uint chanid, QStrin 
    41324135        UpdateOSDInput();
    41334136
    41344137    ITVRestart(true);
     4138
     4139    SetAudioSyncFromDb();
    41354140}
    41364141
    41374142void TV::ToggleInputs(void)
    void TV::ToggleInputs(void) 
    41614166    // If activenvp is main nvp, show new input in on screen display
    41624167    if (nvp && activenvp == nvp)
    41634168        UpdateOSDInput(inputname);
     4169
     4170    SetAudioSyncFromDb();
    41644171}
    41654172
    41664173void TV::ToggleChannelFavorite(void)
    void TV::ChangeChannel(int direction) 
    42094216        muteTimer->start(kMuteTimeout * 2, true);
    42104217
    42114218    UnpauseLiveTV();
     4219
     4220    SetAudioSyncFromDb();
    42124221}
    42134222
    42144223QString TV::GetQueuedInput(void) const
    void TV::ChangeChannel(uint chanid, cons 
    45414550        muteTimer->start(kMuteTimeout * 2, true);
    45424551
    45434552    UnpauseLiveTV();
     4553
     4554    SetAudioSyncFromDb();
    45444555}
    45454556
    45464557void TV::AddPreviousChannel(void)
    void TV::ChangeAudioSync(int dir, bool a 
    54775488            val = 0;
    54785489        }
    54795490        else
     5491        {
    54805492            text = tr("Audio Sync") + text;
    54815493
     5494            if (audiosyncSaved && (newval == audiosyncSaved))
     5495                text = text + tr(" (saved)");
     5496        }
     5497
    54825498        GetOSD()->ShowStatus((val/2)+500, false, tr("Adjust Audio Sync"), text,
    54835499                             10, kOSDFunctionalType_AudioSyncAdjust);
    54845500        update_osd_pos = false;
    54855501    }
    54865502}
    54875503
     5504void TV::SaveAudioSyncToDb(void)
     5505{
     5506    if (playbackinfo->chanid.isEmpty())
     5507        return;
     5508
     5509    MSqlQuery query(MSqlQuery::InitCon());
     5510    query.prepare("UPDATE channel SET audiosync = :AUDIOSYNC WHERE "
     5511                  "chanid = :CHANID ;");
     5512    query.bindValue(":AUDIOSYNC", activenvp->GetAudioTimecodeOffset());
     5513    query.bindValue(":CHANID", playbackinfo->chanid);
     5514
     5515    if(!query.exec() || !query.isActive())
     5516    {
     5517        MythContext::DBError("Audio sync adjustment save", query);
     5518        GetOSD()->SetSettingsText("Adjustment save failed", 3);
     5519        return;
     5520    }
     5521
     5522    GetOSD()->SetSettingsText("Audio Sync saved", 3);
     5523
     5524    audiosyncSaved = activenvp->GetAudioTimecodeOffset();
     5525}
     5526
     5527void TV::SetAudioSyncFromDb(void)
     5528{
     5529    if (playbackinfo->chanid.isEmpty())
     5530        return;
     5531
     5532    long long audiosync;
     5533
     5534    MSqlQuery query(MSqlQuery::InitCon());
     5535    query.prepare("SELECT audiosync FROM channel WHERE chanid = :CHANID ;");
     5536    query.bindValue(":CHANID", playbackinfo->chanid);
     5537
     5538    if (query.exec() && query.isActive() && query.size() > 0)
     5539    {
     5540        query.next();
     5541        audiosync = query.value(0).toLongLong();
     5542    }
     5543    else
     5544    {
     5545        MythContext::DBError("Retrieve audio sync adjustment", query);
     5546        return;
     5547    }
     5548
     5549    long long newval = activenvp->SetAudioTimecodeOffset(audiosync);
     5550    activenvp->SaveAudioTimecodeOffset(audiosync);
     5551
     5552    audiosyncSaved = newval;
     5553    audiosyncBaseline = 0;
     5554
     5555    VERBOSE(VB_PLAYBACK, LOC + QString("Set audio sync adjustment to %1")
     5556                                                       .arg(newval));
     5557}
     5558
    54885559void TV::ToggleMute(void)
    54895560{
    54905561    kMuteState mute_status;
    void TV::TreeMenuSelected(OSDListTreeTyp 
    67126783            BrowseStart();
    67136784        else if (action == "PREVCHAN")
    67146785            PreviousChannel();
     6786        else if (action == "SAVEAUDIOSYNC")
     6787            SaveAudioSyncToDb();
    67156788        else
    67166789        {
    67176790            VERBOSE(VB_IMPORTANT, LOC_ERR +
    void TV::BuildOSDTreeMenu(void) 
    69617034                             "TOGGLEMANUALZOOM");
    69627035
    69637036    item = new OSDGenericTree(treeMenu, tr("Adjust Audio Sync"), "TOGGLEAUDIOSYNC");
     7037    subitem = new OSDGenericTree(item, tr("Adjust Audio Sync"), "TOGGLEAUDIOSYNC");
     7038    subitem = new OSDGenericTree(item, tr("Save Adjustment"), "SAVEAUDIOSYNC");
    69647039
    69657040    int speedX100 = (int)(round(normal_speed * 100));
    69667041
  • libs/libmythtv/tv_play.h

    diff -rup mythtv.orig/libs/libmythtv/tv_play.h mythtv/libs/libmythtv/tv_play.h
    old new class MPUBLIC TV : public QObject 
    286286    void ToggleTimeStretch(void);
    287287    void ChangeTimeStretch(int dir, bool allowEdit = true);
    288288    void ChangeAudioSync(int dir, bool allowEdit = true);
     289    void SaveAudioSyncToDb(void);
     290    void SetAudioSyncFromDb(void);
    289291    float StopFFRew(void);
    290292    void ChangeFFRew(int direction);
    291293    void SetFFRew(int index);
    class MPUBLIC TV : public QObject 
    433435    bool stretchAdjustment; ///< True if time stretch is turned on
    434436    bool audiosyncAdjustment; ///< True if audiosync is turned on
    435437    long long audiosyncBaseline;
     438    long long audiosyncSaved;
    436439    bool editmode;          ///< Are we in video editing mode
    437440    bool zoomMode;
    438441    bool sigMonMode;     ///< Are we in signal monitoring mode?