OSDN Git Service

Increase polling frequency again temporarily to fix A/V issues
authorAndreas Huber <andih@google.com>
Wed, 3 Oct 2012 16:01:11 +0000 (09:01 -0700)
committerThe Android Automerger <android-build@android.com>
Wed, 3 Oct 2012 23:14:07 +0000 (16:14 -0700)
Fixes a bug in the silence detection and increases the timeout after which
we enter "silent mode" to 10 secs.

Change-Id: I802b058f054becd5c377186664437f7b3970193f
related-to-bug: 7248248

media/libstagefright/wifi-display/source/Converter.cpp
media/libstagefright/wifi-display/source/PlaybackSession.cpp

index 6f336c7..f044666 100644 (file)
@@ -242,16 +242,18 @@ void Converter::onMessageReceived(const sp<AMessage> &msg) {
 #if ENABLE_SILENCE_DETECTION
                 if (!mIsVideo) {
                     if (IsSilence(accessUnit)) {
-                        if (!mInSilentMode) {
-                            int64_t nowUs = ALooper::GetNowUs();
-
-                            if (mFirstSilentFrameUs < 0ll) {
-                                mFirstSilentFrameUs = nowUs;
-                            } else if (nowUs >= mFirstSilentFrameUs + 1000000ll) {
-                                mInSilentMode = true;
-                                ALOGI("audio in silent mode now.");
-                                break;
-                            }
+                        if (mInSilentMode) {
+                            break;
+                        }
+
+                        int64_t nowUs = ALooper::GetNowUs();
+
+                        if (mFirstSilentFrameUs < 0ll) {
+                            mFirstSilentFrameUs = nowUs;
+                        } else if (nowUs >= mFirstSilentFrameUs + 10000000ll) {
+                            mInSilentMode = true;
+                            ALOGI("audio in silent mode now.");
+                            break;
                         }
                     } else {
                         if (mInSilentMode) {
@@ -326,7 +328,7 @@ void Converter::scheduleDoMoreWork() {
     }
 
     mDoMoreWorkPending = true;
-    (new AMessage(kWhatDoMoreWork, id()))->post(mIsVideo ? 10000ll : 5000ll);
+    (new AMessage(kWhatDoMoreWork, id()))->post(1000ll);
 }
 
 status_t Converter::feedEncoderInputBuffers() {
@@ -404,9 +406,8 @@ status_t Converter::doMoreWork() {
             sp<ABuffer> buffer = new ABuffer(size);
             buffer->meta()->setInt64("timeUs", timeUs);
 
-            if (!mIsVideo) {
-                ALOGV("audio time %lld us (%.2f secs)", timeUs, timeUs / 1E6);
-            }
+            ALOGV("[%s] time %lld us (%.2f secs)",
+                  mIsVideo ? "video" : "audio", timeUs, timeUs / 1E6);
 
             memcpy(buffer->data(),
                    mEncoderOutputBuffers.itemAt(bufferIndex)->base() + offset,
index c91b4c8..ffdafed 100644 (file)
@@ -919,13 +919,22 @@ status_t WifiDisplaySource::PlaybackSession::addVideoSource() {
 
     source->setUseAbsoluteTimestamps();
 
+#if 1
     sp<RepeaterSource> videoSource =
         new RepeaterSource(source, 30.0 /* rateHz */);
+#endif
 
+#if 1
     size_t numInputBuffers;
     status_t err = addSource(
             true /* isVideo */, videoSource, true /* isRepeaterSource */,
             &numInputBuffers);
+#else
+    size_t numInputBuffers;
+    status_t err = addSource(
+            true /* isVideo */, source, false /* isRepeaterSource */,
+            &numInputBuffers);
+#endif
 
     if (err != OK) {
         return err;