|
Lines 43-48
a/Source/WebKit/GPUProcess/media/RemoteAudioDestinationManager.cpp_sec1
|
| 43 |
|
43 |
|
| 44 |
namespace WebKit { |
44 |
namespace WebKit { |
| 45 |
|
45 |
|
|
|
46 |
static constexpr unsigned defaultNumberOfQuantumsToWriteAhead = 2; |
| 47 |
static constexpr unsigned maxNumberOfQuantumsToWriteAhead = 10; |
| 48 |
|
| 46 |
class RemoteAudioDestination final |
49 |
class RemoteAudioDestination final |
| 47 |
#if PLATFORM(COCOA) |
50 |
#if PLATFORM(COCOA) |
| 48 |
: public WebCore::AudioUnitRenderer |
51 |
: public WebCore::AudioUnitRenderer |
|
Lines 107-119
private:
a/Source/WebKit/GPUProcess/media/RemoteAudioDestinationManager.cpp_sec2
|
| 107 |
{ |
110 |
{ |
| 108 |
ASSERT(!isMainRunLoop()); |
111 |
ASSERT(!isMainRunLoop()); |
| 109 |
|
112 |
|
|
|
113 |
unsigned numberOfFramesToRequestFromRemote = numberOfFrames; |
| 110 |
OSStatus status = -1; |
114 |
OSStatus status = -1; |
| 111 |
if (m_ringBuffer->fetchIfHasEnoughData(ioData, numberOfFrames, m_startFrame)) { |
115 |
uint64_t remainingFramesInRingBuffer = 0; |
|
|
116 |
if (m_ringBuffer->fetchIfHasEnoughData(ioData, numberOfFrames, m_startFrame, WebCore::CARingBuffer::Copy, &remainingFramesInRingBuffer)) { |
| 112 |
m_startFrame += numberOfFrames; |
117 |
m_startFrame += numberOfFrames; |
| 113 |
status = noErr; |
118 |
status = noErr; |
|
|
119 |
|
| 120 |
if (remainingFramesInRingBuffer >= numberOfFrames * m_numberOfQuantumsToWriteAhead) |
| 121 |
numberOfFramesToRequestFromRemote = 0; // Do not let the writer get more than |m_numberOfQuantumsToWriteAhead| quantums ahead. |
| 122 |
} else if (m_startFrame) { |
| 123 |
// It seems we hit a case where the WebProcess is not filling in the ring buffer fast enough to keep up with the reader |
| 124 |
// so we allow the writer to write ahead an extra rendering quantum. |
| 125 |
m_numberOfQuantumsToWriteAhead = std::min(m_numberOfQuantumsToWriteAhead + 1, maxNumberOfQuantumsToWriteAhead); |
| 114 |
} |
126 |
} |
| 115 |
|
127 |
|
| 116 |
for (unsigned i = 0; i < numberOfFrames; i += WebCore::AudioUtilities::renderQuantumSize) { |
128 |
for (unsigned i = 0; i < numberOfFramesToRequestFromRemote; i += WebCore::AudioUtilities::renderQuantumSize) { |
| 117 |
// Ask the audio thread in the WebContent process to render a quantum. |
129 |
// Ask the audio thread in the WebContent process to render a quantum. |
| 118 |
m_renderSemaphore.signal(); |
130 |
m_renderSemaphore.signal(); |
| 119 |
} |
131 |
} |
|
Lines 133-138
private:
a/Source/WebKit/GPUProcess/media/RemoteAudioDestinationManager.cpp_sec3
|
| 133 |
IPC::Semaphore m_renderSemaphore; |
145 |
IPC::Semaphore m_renderSemaphore; |
| 134 |
|
146 |
|
| 135 |
bool m_isPlaying { false }; |
147 |
bool m_isPlaying { false }; |
|
|
148 |
unsigned m_numberOfQuantumsToWriteAhead { defaultNumberOfQuantumsToWriteAhead }; |
| 136 |
}; |
149 |
}; |
| 137 |
|
150 |
|
| 138 |
RemoteAudioDestinationManager::RemoteAudioDestinationManager(GPUConnectionToWebProcess& connection) |
151 |
RemoteAudioDestinationManager::RemoteAudioDestinationManager(GPUConnectionToWebProcess& connection) |