Bug 1186358. Part 1 - Remove dependency on MediaDecoderStateMachine from AudioSink. r=kinetik.

This commit is contained in:
JW Wang 2015-07-23 19:57:58 +08:00
Родитель a75608405a
Коммит 5e7af1298a
4 изменённых файлов: 22 добавлений и 30 удалений

Просмотреть файл

@ -4,7 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AudioSink.h"
#include "MediaDecoderStateMachine.h"
#include "AudioStream.h"
#include "prenv.h"
@ -19,9 +18,11 @@ extern PRLogModuleInfo* gMediaDecoderLog;
// The amount of audio frames that is used to fuzz rounding errors.
static const int64_t AUDIO_FUZZ_FRAMES = 1;
AudioSink::AudioSink(MediaDecoderStateMachine* aStateMachine,
AudioSink::AudioSink(MediaQueue<AudioData>& aAudioQueue,
ReentrantMonitor& aMonitor,
int64_t aStartTime, AudioInfo aInfo, dom::AudioChannel aChannel)
: mStateMachine(aStateMachine)
: mAudioQueue(aAudioQueue)
, mDecoderMonitor(aMonitor)
, mStartTime(aStartTime)
, mWritten(0)
, mLastGoodPosition(0)
@ -391,24 +392,6 @@ AudioSink::GetEndTime() const
return playedUsecs.value();
}
MediaQueue<AudioData>&
AudioSink::AudioQueue()
{
return mStateMachine->AudioQueue();
}
ReentrantMonitor&
AudioSink::GetReentrantMonitor()
{
return mStateMachine->mDecoder->GetReentrantMonitor();
}
void
AudioSink::AssertCurrentThreadInMonitor()
{
return mStateMachine->AssertCurrentThreadInMonitor();
}
void
AudioSink::AssertOnAudioThread()
{

Просмотреть файл

@ -15,13 +15,13 @@
namespace mozilla {
class AudioStream;
class MediaDecoderStateMachine;
class AudioSink {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AudioSink)
AudioSink(MediaDecoderStateMachine* aStateMachine,
AudioSink(MediaQueue<AudioData>& aAudioQueue,
ReentrantMonitor& aMonitor,
int64_t aStartTime, AudioInfo aInfo, dom::AudioChannel aChannel);
// Return a promise which will be resolved when AudioSink finishes playing,
@ -92,13 +92,22 @@ private:
void StartAudioStreamPlaybackIfNeeded();
void WriteSilence(uint32_t aFrames);
MediaQueue<AudioData>& AudioQueue();
MediaQueue<AudioData>& AudioQueue() const {
return mAudioQueue;
}
ReentrantMonitor& GetReentrantMonitor() const {
return mDecoderMonitor;
}
void AssertCurrentThreadInMonitor() const {
GetReentrantMonitor().AssertCurrentThreadIn();
}
ReentrantMonitor& GetReentrantMonitor();
void AssertCurrentThreadInMonitor();
void AssertOnAudioThread();
nsRefPtr<MediaDecoderStateMachine> mStateMachine;
MediaQueue<AudioData>& mAudioQueue;
ReentrantMonitor& mDecoderMonitor;
// Thread for pushing audio onto the audio hardware.
// The "audio push thread".

Просмотреть файл

@ -1794,8 +1794,9 @@ MediaDecoderStateMachine::StartAudioThread()
if (HasAudio() && !mAudioSink) {
mAudioCompleted = false;
mAudioSink = new AudioSink(this, GetMediaTime(),
mInfo.mAudio, mDecoder->GetAudioChannel());
mAudioSink = new AudioSink(mAudioQueue, mDecoder->GetReentrantMonitor(),
GetMediaTime(), mInfo.mAudio,
mDecoder->GetAudioChannel());
mAudioSinkPromise.Begin(
mAudioSink->Init()->Then(

Просмотреть файл

@ -119,7 +119,6 @@ extern PRLogModuleInfo* gMediaSampleLog;
*/
class MediaDecoderStateMachine
{
friend class AudioSink;
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderStateMachine)
public:
typedef MediaDecoderReader::AudioDataPromise AudioDataPromise;