зеркало из https://github.com/mozilla/pjs.git
Bug 693095 - Fix audio stream position estimation for remoted streams. Also resurrect audio thread wait removed in bug 669556 when using remoted audio streams. r=cpearce
This commit is contained in:
Родитель
8479e44104
Коммит
deda03e217
|
@ -166,4 +166,10 @@ void ScaleDisplayByAspectRatio(nsIntSize& aDisplay, float aAspectRatio);
|
|||
#define MEDIA_THREAD_STACK_SIZE nsIThreadManager::DEFAULT_STACK_SIZE
|
||||
#endif
|
||||
|
||||
// Android's audio backend is not available in content processes, so audio must
|
||||
// be remoted to the parent chrome process.
|
||||
#if defined(ANDROID)
|
||||
#define REMOTE_AUDIO 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -66,12 +66,6 @@ using namespace mozilla;
|
|||
#define SA_PER_STREAM_VOLUME 1
|
||||
#endif
|
||||
|
||||
// Android's audio backend is not available in content processes, so audio must
|
||||
// be remoted to the parent chrome process.
|
||||
#if defined(ANDROID)
|
||||
#define REMOTE_AUDIO 1
|
||||
#endif
|
||||
|
||||
using mozilla::TimeStamp;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
|
@ -80,6 +74,9 @@ PRLogModuleInfo* gAudioStreamLog = nsnull;
|
|||
|
||||
static const PRUint32 FAKE_BUFFER_SIZE = 176400;
|
||||
|
||||
// Number of milliseconds per second.
|
||||
static const PRInt64 MS_PER_S = 1000;
|
||||
|
||||
class nsNativeAudioStream : public nsAudioStream
|
||||
{
|
||||
public:
|
||||
|
@ -752,9 +749,9 @@ nsRemotedAudioStream::GetPositionInFrames()
|
|||
return 0;
|
||||
|
||||
PRInt64 time = mAudioChild->GetLastKnownPositionTimestamp();
|
||||
PRInt64 result = position + (mRate * (PR_IntervalNow() - time) / USECS_PER_S);
|
||||
PRInt64 dt = PR_IntervalToMilliseconds(PR_IntervalNow() - time);
|
||||
|
||||
return result;
|
||||
return position + (mRate * dt / MS_PER_S);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -635,6 +635,29 @@ void nsBuiltinDecoderStateMachine::AudioLoop()
|
|||
NS_WARNING("Int overflow calculating audio end time");
|
||||
break;
|
||||
}
|
||||
|
||||
// The remoted audio stream does not block writes when the other end's buffers
|
||||
// are full, so this sleep is necessary to stop the audio thread spinning its
|
||||
// wheels. When bug 695612 is fixed, this block of code can be removed.
|
||||
#if defined(REMOTE_AUDIO)
|
||||
PRInt64 audioAhead = mAudioEndTime - GetMediaTime();
|
||||
if (audioAhead > AMPLE_AUDIO_USECS &&
|
||||
framesWritten > minWriteFrames)
|
||||
{
|
||||
// We've pushed enough audio onto the hardware that we've queued up a
|
||||
// significant amount ahead of the playback position. The decode
|
||||
// thread will be going to sleep, so we won't get any new audio
|
||||
// anyway, so sleep until we need to push to the hardware again.
|
||||
Wait(AMPLE_AUDIO_USECS / 2);
|
||||
// Kick the decode thread; since above we only do a NotifyAll when
|
||||
// we pop an audio chunk of the queue, the decoder won't wake up if
|
||||
// we've got no more decoded chunks to push to the hardware. We can
|
||||
// hit this condition if the last frame in the stream doesn't have
|
||||
// it's EOS flag set, and the decode thread sleeps just after decoding
|
||||
// that packet, but before realising there's no more packets.
|
||||
mon.NotifyAll();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (mReader->mAudioQueue.AtEndOfStream() &&
|
||||
|
|
Загрузка…
Ссылка в новой задаче