RealtimeOutgoingAudioSource should use the source sample rate
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 May 2017 19:07:55 +0000 (19:07 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 May 2017 19:07:55 +0000 (19:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172297

Patch by Youenn Fablet <youenn@apple.com> on 2017-05-18
Reviewed by Eric Carlson.

Covered by manual tests.

* platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::audioSamplesAvailable): Using the audio source sample rate so that the converter does the right conversion.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217058 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp

index 4a6da9b..342044c 100644 (file)
@@ -1,3 +1,15 @@
+2017-05-18  Youenn Fablet  <youenn@apple.com>
+
+        RealtimeOutgoingAudioSource should use the source sample rate
+        https://bugs.webkit.org/show_bug.cgi?id=172297
+
+        Reviewed by Eric Carlson.
+
+        Covered by manual tests.
+
+        * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp:
+        (WebCore::RealtimeOutgoingAudioSource::audioSamplesAvailable): Using the audio source sample rate so that the converter does the right conversion.
+
 2017-05-18  Andy Estes  <aestes@apple.com>
 
         Add "countryCode" to ApplePayErrorContactField
index fa89fe8..8cd8262 100644 (file)
@@ -93,8 +93,10 @@ void RealtimeOutgoingAudioSource::audioSamplesAvailable(const MediaTime&, const
         status = m_sampleConverter->setOutputFormat(m_outputStreamDescription.streamDescription());
         ASSERT(!status);
     }
-
-    m_sampleConverter->pushSamples(MediaTime(m_writeCount, LibWebRTCAudioFormat::sampleRate), audioData, sampleCount);
+    
+    // If we change the audio track or its sample rate changes, the timestamp based on m_writeCount may be wrong.
+    // FIXME: We should update m_writeCount to be valid according the new sampleRate.
+    m_sampleConverter->pushSamples(MediaTime(m_writeCount, static_cast<uint32_t>(m_inputStreamDescription.sampleRate())), audioData, sampleCount);
     m_writeCount += sampleCount;
 
     LibWebRTCProvider::callOnWebRTCSignalingThread([protectedThis = makeRef(*this)] {