зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1023947 - Part 1 - Drop frame instead of buffering them when we are swiching device. r=jesup
--HG-- extra : rebase_source : 9e5f70c2c8aa9bc826e8bee561285da5220bf895
This commit is contained in:
Родитель
8c440dbba5
Коммит
637f84f99a
|
@ -253,6 +253,7 @@ AudioStream::AudioStream()
|
|||
, mBytesPerFrame(0)
|
||||
, mState(INITIALIZED)
|
||||
, mNeedsStart(false)
|
||||
, mShouldDropFrames(false)
|
||||
{
|
||||
// keep a ref in case we shut down later than nsLayoutStatics
|
||||
mLatencyLog = AsyncLatencyLogger::Get(true);
|
||||
|
@ -591,6 +592,7 @@ void AudioStream::PanOutputIfNeeded(bool aMicrophoneActive)
|
|||
void AudioStream::DeviceChangedCallback() {
|
||||
MonitorAutoLock mon(mMonitor);
|
||||
PanOutputIfNeeded(mMicrophoneActive);
|
||||
mShouldDropFrames = true;
|
||||
}
|
||||
|
||||
// This code used to live inside AudioStream::Init(), but on Mac (others?)
|
||||
|
@ -712,6 +714,10 @@ nsresult
|
|||
AudioStream::Write(const AudioDataValue* aBuf, uint32_t aFrames, TimeStamp *aTime)
|
||||
{
|
||||
MonitorAutoLock mon(mMonitor);
|
||||
if (mShouldDropFrames) {
|
||||
mBuffer.ContractTo(0);
|
||||
return NS_OK;
|
||||
}
|
||||
if (mState == ERRORED) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1113,6 +1119,8 @@ AudioStream::DataCallback(void* aBuffer, long aFrames)
|
|||
uint32_t servicedFrames = 0;
|
||||
int64_t insertTime;
|
||||
|
||||
mShouldDropFrames = false;
|
||||
|
||||
// NOTE: wasapi (others?) can call us back *after* stop()/Shutdown() (mState == SHUTDOWN)
|
||||
// Bug 996162
|
||||
|
||||
|
|
|
@ -407,6 +407,10 @@ private:
|
|||
bool mIsFirst;
|
||||
// True if a microphone is active.
|
||||
bool mMicrophoneActive;
|
||||
// When we are in the process of changing the output device, and the callback
|
||||
// is not going to be called for a little while, simply drop incoming frames.
|
||||
// This is only on OSX for now, because other systems handle this gracefully.
|
||||
bool mShouldDropFrames;
|
||||
|
||||
// This mutex protects the static members below.
|
||||
static StaticMutex sMutex;
|
||||
|
|
Загрузка…
Ссылка в новой задаче