Ticket #6581: lipsync_patch.txt

File lipsync_patch.txt, 4.5 KB (added by andreas.dey, 11 years ago)
Line 
1Index: /home/andreas/devel/mythtv/mythtv/libs/libmythtv/NuppelVideoPlayer.cpp
2===================================================================
3--- /home/andreas/devel/mythtv/mythtv/libs/libmythtv/NuppelVideoPlayer.cpp      (revision 20635)
4+++ /home/andreas/devel/mythtv/mythtv/libs/libmythtv/NuppelVideoPlayer.cpp      (working copy)
5@@ -297,6 +297,13 @@
6     text_size = 8 * (sizeof(teletextsubtitle) + VT_WIDTH);
7     for (int i = 0; i < MAXTBUFFER; i++)
8         txtbuffers[i].buffer = new unsigned char[text_size + 1];
9+   
10+    // Read the global audio sync (lipsync) settings
11+    db_audio_sync = gContext->GetNumSettingOnHost(
12+               "AudioSync", gContext->GetHostName(), 0);
13+    SaveAudioTimecodeOffset(db_audio_sync);
14+
15+
16 }
17 
18 NuppelVideoPlayer::~NuppelVideoPlayer(void)
19Index: /home/andreas/devel/mythtv/mythtv/libs/libmythtv/NuppelVideoPlayer.h
20===================================================================
21--- /home/andreas/devel/mythtv/mythtv/libs/libmythtv/NuppelVideoPlayer.h        (revision 20635)
22+++ /home/andreas/devel/mythtv/mythtv/libs/libmythtv/NuppelVideoPlayer.h        (working copy)
23@@ -803,6 +803,7 @@
24     bool       decode_extra_audio;
25     float      m_stored_audio_stretchfactor;
26     bool       audio_paused;
27+    long long  db_audio_sync;
28 
29     // Audio warping stuff
30     bool       usevideotimebase;
31Index: /home/andreas/devel/mythtv/mythtv/libs/libmythtv/tv_play.cpp
32===================================================================
33--- /home/andreas/devel/mythtv/mythtv/libs/libmythtv/tv_play.cpp        (revision 20635)
34+++ /home/andreas/devel/mythtv/mythtv/libs/libmythtv/tv_play.cpp        (working copy)
35@@ -8001,7 +8001,7 @@
36 // dir in 10ms jumps
37 void TV::ChangeAudioSync(PlayerContext *ctx, int dir, bool allowEdit)
38 {
39-    long long newval;
40+    long long newval = 0;
41 
42     ctx->LockDeleteNVP(__FILE__, __LINE__);
43     if (!ctx->nvp)
44@@ -8009,10 +8009,14 @@
45         ctx->UnlockDeleteNVP(__FILE__, __LINE__);
46         return;
47     }
48-
49+   
50+    VERBOSE(VB_PLAYBACK, LOC + "ChangeAudioSync("<<audiosyncBaseline<<", "<<audiosyncAdjustment<<")");
51+   
52     if (!audiosyncAdjustment && LONG_LONG_MIN == audiosyncBaseline)
53-        audiosyncBaseline = ctx->nvp->GetAudioTimecodeOffset();
54-
55+       audiosyncBaseline = ctx->nvp->GetAudioTimecodeOffset();
56+   
57+    VERBOSE(VB_PLAYBACK, LOC + "ChangeAudioSync("<<audiosyncBaseline<<", "<<audiosyncAdjustment<<", " <<dir<< ")");
58+   
59     audiosyncAdjustment = allowEdit;
60 
61     if (dir == 1000000)
62@@ -8027,11 +8031,14 @@
63                  audiosyncBaseline;
64         audiosyncBaseline = ctx->nvp->GetAudioTimecodeOffset();
65     }
66-    else
67+    else if (dir != 0)
68     {
69         newval = ctx->nvp->AdjustAudioTimecodeOffset(dir*10) -
70                  audiosyncBaseline;
71-    }
72+    }   
73+   
74+    VERBOSE(VB_PLAYBACK, LOC + "ChangeAudioSync - newval: "<<newval<<"");
75+   
76     ctx->UnlockDeleteNVP(__FILE__, __LINE__);
77 
78     OSD *osd = GetOSDLock(ctx);
79@@ -8037,7 +8044,7 @@
80     OSD *osd = GetOSDLock(ctx);
81     if (osd && !browsemode)
82     {
83-        QString text = QString(" %1 ms").arg(newval);
84+        QString text = QString(" %1 ms (+ %2 ms)").arg(newval).arg(audiosyncBaseline);
85         int val = (int)newval;
86         if (dir == 1000000 || dir == -1000000)
87         {
88Index: /home/andreas/devel/mythtv/mythtv/programs/mythfrontend/globalsettings.cpp
89===================================================================
90--- /home/andreas/devel/mythtv/mythtv/programs/mythfrontend/globalsettings.cpp  (revision 20635)
91+++ /home/andreas/devel/mythtv/mythtv/programs/mythfrontend/globalsettings.cpp  (working copy)
92@@ -2728,7 +2728,6 @@
93 
94 static HostCheckBox *UseFixedWindowSize()
95 {
96-{
97     HostCheckBox *gc = new HostCheckBox("UseFixedWindowSize");
98     gc->setLabel(QObject::tr("Use fixed window size"));
99     gc->setValue(true);
100@@ -2737,7 +2736,6 @@
101                         "window can be resized"));
102     return gc;
103 }
104-}
105 
106 
107 static HostCheckBox *RandomTheme()
108@@ -2872,6 +2870,16 @@
109     return gc;
110 }
111 
112+static HostSpinBox *AudioSync()
113+{
114+    HostSpinBox *gs = new HostSpinBox("AudioSync", -1600, 1600, 8, true);
115+    gs->setLabel(QObject::tr("Audio sync offset"));
116+    gs->setValue(0);
117+    gs->setHelpText(QObject::tr("The global offset for audio synchronization "
118+                    "(Lipsync)"));
119+    return gs;
120+}
121+
122 ThemeSelector::ThemeSelector(QString label):
123     HostImageSelect(label) {
124 
125@@ -3446,6 +3454,7 @@
126 
127         addChild(MaxAudioChannels());
128         addChild(AudioUpmixType());
129+        addChild(AudioSync());
130 
131         // General boolean settings
132         addChild(AC3PassThrough());