зеркало из https://github.com/mozilla/gecko-dev.git
Bug 519136. Clean up media-related logging. r=doublec
--HG-- extra : rebase_source : 2321054271a8726d17da1c58b876e2a7eb88883c
This commit is contained in:
Родитель
c4dfa44933
Коммит
ab84f5ebd3
|
@ -35,6 +35,7 @@
|
|||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIDOMHTMLMediaElement.h"
|
||||
#include "nsIDOMHTMLSourceElement.h"
|
||||
#include "nsHTMLMediaElement.h"
|
||||
|
@ -85,6 +86,15 @@
|
|||
#include "nsWaveDecoder.h"
|
||||
#endif
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
static PRLogModuleInfo* gMediaElementLog;
|
||||
static PRLogModuleInfo* gMediaElementEventsLog;
|
||||
#define LOG(type, msg) PR_LOG(gMediaElementLog, type, msg)
|
||||
#define LOG_EVENT(type, msg) PR_LOG(gMediaElementEventsLog, type, msg)
|
||||
#else
|
||||
#define LOG(type, msg)
|
||||
#define LOG_EVENT(type, msg)
|
||||
#endif
|
||||
|
||||
class nsMediaEvent : public nsRunnable
|
||||
{
|
||||
|
@ -474,6 +484,7 @@ void nsHTMLMediaElement::SelectResource()
|
|||
if (GetAttr(kNameSpaceID_None, nsGkAtoms::src, src)) {
|
||||
nsresult rv = NewURIFromString(src, getter_AddRefs(uri));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
LOG(PR_LOG_DEBUG, ("%p Trying load from src=%s", this, NS_ConvertUTF16toUTF8(src).get()));
|
||||
mIsLoadingFromSrcAttribute = PR_TRUE;
|
||||
rv = LoadResource(uri);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
@ -682,15 +693,21 @@ NS_IMETHODIMP nsHTMLMediaElement::SetCurrentTime(float aCurrentTime)
|
|||
{
|
||||
StopSuspendingAfterFirstFrame();
|
||||
|
||||
if (!mDecoder)
|
||||
if (!mDecoder) {
|
||||
LOG(PR_LOG_DEBUG, ("%p SetCurrentTime(%f) failed: no decoder", this, aCurrentTime));
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
}
|
||||
|
||||
if (mReadyState == nsIDOMHTMLMediaElement::HAVE_NOTHING)
|
||||
if (mReadyState == nsIDOMHTMLMediaElement::HAVE_NOTHING) {
|
||||
LOG(PR_LOG_DEBUG, ("%p SetCurrentTime(%f) failed: no source", this, aCurrentTime));
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
}
|
||||
|
||||
// Detect for a NaN and invalid values.
|
||||
if (aCurrentTime != aCurrentTime)
|
||||
if (aCurrentTime != aCurrentTime) {
|
||||
LOG(PR_LOG_DEBUG, ("%p SetCurrentTime(%f) failed: bad time", this, aCurrentTime));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Clamp the time to [0, duration] as required by the spec
|
||||
float clampedTime = PR_MAX(0, aCurrentTime);
|
||||
|
@ -702,6 +719,7 @@ NS_IMETHODIMP nsHTMLMediaElement::SetCurrentTime(float aCurrentTime)
|
|||
mPlayingBeforeSeek = IsPotentiallyPlaying();
|
||||
// The media backend is responsible for dispatching the timeupdate
|
||||
// event if it changes the playback position as a result of the seek.
|
||||
LOG(PR_LOG_DEBUG, ("%p SetCurrentTime(%f) starting seek", this, aCurrentTime));
|
||||
nsresult rv = mDecoder->Seek(clampedTime);
|
||||
return rv;
|
||||
}
|
||||
|
@ -820,6 +838,15 @@ nsHTMLMediaElement::nsHTMLMediaElement(nsINodeInfo *aNodeInfo, PRBool aFromParse
|
|||
mAllowSuspendAfterFirstFrame(PR_TRUE),
|
||||
mHasPlayedOrSeeked(PR_FALSE)
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
if (!gMediaElementLog) {
|
||||
gMediaElementLog = PR_NewLogModule("nsMediaElement");
|
||||
}
|
||||
if (!gMediaElementEventsLog) {
|
||||
gMediaElementEventsLog = PR_NewLogModule("nsMediaElementEvents");
|
||||
}
|
||||
#endif
|
||||
|
||||
RegisterFreezableElement();
|
||||
}
|
||||
|
||||
|
@ -1230,6 +1257,8 @@ nsresult nsHTMLMediaElement::InitializeDecoderAsClone(nsMediaDecoder* aOriginal)
|
|||
if (!mDecoder)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
LOG(PR_LOG_DEBUG, ("%p Cloned decoder %p from %p", this, mDecoder.get(), aOriginal));
|
||||
|
||||
if (!mDecoder->Init(this)) {
|
||||
mDecoder = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1261,6 +1290,8 @@ nsresult nsHTMLMediaElement::InitializeDecoderForChannel(nsIChannel *aChannel,
|
|||
if (!CreateDecoder(mimeType))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
LOG(PR_LOG_DEBUG, ("%p Created decoder %p for type %s", this, mDecoder.get(), mimeType.get()));
|
||||
|
||||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_LOADING;
|
||||
|
||||
nsMediaStream* stream = nsMediaStream::Create(mDecoder, aChannel);
|
||||
|
@ -1479,7 +1510,7 @@ void nsHTMLMediaElement::UpdateReadyStateForData(NextFrameStatus aNextFrame)
|
|||
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_FUTURE_DATA);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef PR_LOGGING
|
||||
static const char* gReadyStateToString[] = {
|
||||
"HAVE_NOTHING",
|
||||
"HAVE_METADATA",
|
||||
|
@ -1499,7 +1530,7 @@ void nsHTMLMediaElement::ChangeReadyState(nsMediaReadyState aState)
|
|||
return;
|
||||
}
|
||||
|
||||
LOG(PR_LOG_DEBUG, ("Ready state changed to %s", gReadyStateToString[aState]));
|
||||
LOG(PR_LOG_DEBUG, ("%p Ready state changed to %s", this, gReadyStateToString[aState]));
|
||||
|
||||
// Handle raising of "waiting" event during seek (see 4.8.10.9)
|
||||
if (mPlayingBeforeSeek &&
|
||||
|
@ -1565,6 +1596,9 @@ void nsHTMLMediaElement::Paint(gfxContext* aContext,
|
|||
|
||||
nsresult nsHTMLMediaElement::DispatchSimpleEvent(const nsAString& aName)
|
||||
{
|
||||
LOG_EVENT(PR_LOG_DEBUG, ("%p Dispatching simple event %s", this,
|
||||
NS_ConvertUTF16toUTF8(aName).get()));
|
||||
|
||||
return nsContentUtils::DispatchTrustedEvent(GetOwnerDoc(),
|
||||
static_cast<nsIContent*>(this),
|
||||
aName,
|
||||
|
@ -1574,6 +1608,8 @@ nsresult nsHTMLMediaElement::DispatchSimpleEvent(const nsAString& aName)
|
|||
|
||||
nsresult nsHTMLMediaElement::DispatchAsyncSimpleEvent(const nsAString& aName)
|
||||
{
|
||||
LOG_EVENT(PR_LOG_DEBUG, ("%p Queuing simple event %s", this, NS_ConvertUTF16toUTF8(aName).get()));
|
||||
|
||||
nsCOMPtr<nsIRunnable> event = new nsAsyncEventRunner(aName, this, PR_FALSE);
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||
return NS_OK;
|
||||
|
@ -1581,6 +1617,8 @@ nsresult nsHTMLMediaElement::DispatchAsyncSimpleEvent(const nsAString& aName)
|
|||
|
||||
nsresult nsHTMLMediaElement::DispatchAsyncProgressEvent(const nsAString& aName)
|
||||
{
|
||||
LOG_EVENT(PR_LOG_DEBUG, ("%p Queuing progress event %s", this, NS_ConvertUTF16toUTF8(aName).get()));
|
||||
|
||||
nsCOMPtr<nsIRunnable> event = new nsAsyncEventRunner(aName, this, PR_TRUE);
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||
return NS_OK;
|
||||
|
@ -1610,6 +1648,9 @@ nsresult nsHTMLMediaElement::DispatchProgressEvent(const nsAString& aName)
|
|||
totalBytes >= 0, downloadPosition, totalBytes);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
LOG_EVENT(PR_LOG_DEBUG, ("%p Dispatching progress event %s", this,
|
||||
NS_ConvertUTF16toUTF8(aName).get()));
|
||||
|
||||
PRBool dummy;
|
||||
return target->DispatchEvent(event, &dummy);
|
||||
}
|
||||
|
@ -1771,6 +1812,8 @@ already_AddRefed<nsIURI> nsHTMLMediaElement::GetNextSource()
|
|||
GetCanPlay(type) == CANPLAY_NO)
|
||||
continue;
|
||||
|
||||
LOG(PR_LOG_DEBUG, ("%p Trying load from <source>=%s type=%s", this,
|
||||
NS_ConvertUTF16toUTF8(src).get(), NS_ConvertUTF16toUTF8(type).get()));
|
||||
NewURIFromString(src, getter_AddRefs(uri));
|
||||
return uri.forget();
|
||||
}
|
||||
|
@ -1783,17 +1826,18 @@ void nsHTMLMediaElement::ChangeDelayLoadStatus(PRBool aDelay) {
|
|||
if (mDelayingLoadEvent == aDelay)
|
||||
return;
|
||||
|
||||
LOG(PR_LOG_DEBUG, ("ChangeDelayLoadStatus(%d) doc=0x%p", aDelay, mLoadBlockedDoc.get()));
|
||||
mDelayingLoadEvent = aDelay;
|
||||
|
||||
if (aDelay) {
|
||||
mLoadBlockedDoc = GetOwnerDoc();
|
||||
mLoadBlockedDoc->BlockOnload();
|
||||
LOG(PR_LOG_DEBUG, ("%p ChangeDelayLoadStatus(%d) doc=0x%p", this, aDelay, mLoadBlockedDoc.get()));
|
||||
} else {
|
||||
if (mDecoder) {
|
||||
mDecoder->MoveLoadsToBackground();
|
||||
}
|
||||
NS_ASSERTION(mLoadBlockedDoc, "Need a doc to block on");
|
||||
LOG(PR_LOG_DEBUG, ("%p ChangeDelayLoadStatus(%d) doc=0x%p", this, aDelay, mLoadBlockedDoc.get()));
|
||||
mLoadBlockedDoc->UnblockOnload(PR_FALSE);
|
||||
mLoadBlockedDoc = nsnull;
|
||||
}
|
||||
|
|
|
@ -1401,6 +1401,7 @@ nsMediaCache::OpenStream(nsMediaCacheStream* aStream)
|
|||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
LOG(PR_LOG_DEBUG, ("Stream %p opened", aStream));
|
||||
mStreams.AppendElement(aStream);
|
||||
aStream->mResourceID = mNextResourceID++;
|
||||
}
|
||||
|
@ -1411,6 +1412,7 @@ nsMediaCache::ReleaseStream(nsMediaCacheStream* aStream)
|
|||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
LOG(PR_LOG_DEBUG, ("Stream %p closed", aStream));
|
||||
mStreams.RemoveElement(aStream);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsMediaDecoder.h"
|
||||
|
||||
#include "prlog.h"
|
||||
#include "prmem.h"
|
||||
#include "nsIFrame.h"
|
||||
|
@ -50,7 +53,6 @@
|
|||
#include "gfxContext.h"
|
||||
#include "gfxImageSurface.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsMediaDecoder.h"
|
||||
#include "nsDOMError.h"
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
|
@ -63,11 +65,6 @@
|
|||
// Number of milliseconds of no data before a stall event is fired as defined by spec
|
||||
#define STALL_MS 3000
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
// Logging object for decoder
|
||||
PRLogModuleInfo* gVideoDecoderLog = nsnull;
|
||||
#endif
|
||||
|
||||
nsMediaDecoder::nsMediaDecoder() :
|
||||
mElement(0),
|
||||
mRGBWidth(-1),
|
||||
|
@ -110,13 +107,6 @@ nsHTMLMediaElement* nsMediaDecoder::GetMediaElement()
|
|||
{
|
||||
return mElement;
|
||||
}
|
||||
nsresult nsMediaDecoder::InitLogger()
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
gVideoDecoderLog = PR_NewLogModule("nsMediaDecoder");
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static PRInt32 ConditionDimension(float aValue, PRInt32 aDefault)
|
||||
{
|
||||
|
|
|
@ -47,15 +47,9 @@
|
|||
#include "gfxRect.h"
|
||||
#include "nsITimer.h"
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
extern PRLogModuleInfo* gVideoDecoderLog;
|
||||
#define LOG(type, msg) PR_LOG(gVideoDecoderLog, type, msg)
|
||||
#else
|
||||
#define LOG(type, msg)
|
||||
#endif
|
||||
|
||||
class nsHTMLMediaElement;
|
||||
class nsMediaStream;
|
||||
class nsIStreamListener;
|
||||
|
||||
// All methods of nsMediaDecoder must be called from the main thread only
|
||||
// with the exception of SetRGBData and GetStatistics, which can be
|
||||
|
@ -72,9 +66,6 @@ public:
|
|||
// Create a new decoder of the same type as this one.
|
||||
virtual nsMediaDecoder* Clone() = 0;
|
||||
|
||||
// Initialize the logging object
|
||||
static nsresult InitLogger();
|
||||
|
||||
// Perform any initialization required for the decoder.
|
||||
// Return PR_TRUE on successful initialisation, PR_FALSE
|
||||
// on failure.
|
||||
|
|
|
@ -35,8 +35,10 @@
|
|||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsOggDecoder.h"
|
||||
|
||||
#include <limits>
|
||||
#include "prlog.h"
|
||||
#include "prmem.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIDocument.h"
|
||||
|
@ -51,11 +53,17 @@
|
|||
#include "nsAutoLock.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsOggDecoder.h"
|
||||
|
||||
using mozilla::TimeDuration;
|
||||
using mozilla::TimeStamp;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
static PRLogModuleInfo* gOggDecoderLog;
|
||||
#define LOG(type, msg) PR_LOG(gOggDecoderLog, type, msg)
|
||||
#else
|
||||
#define LOG(type, msg)
|
||||
#endif
|
||||
|
||||
/*
|
||||
The maximum height and width of the video. Used for
|
||||
sanitizing the memory allocation of the RGB buffer
|
||||
|
@ -938,7 +946,7 @@ void nsOggDecodeStateMachine::PlayFrame() {
|
|||
|
||||
// Skip frames up to the one we should be showing.
|
||||
while (!mDecodedFrames.IsEmpty() && time >= mDecodedFrames.Peek()->mTime) {
|
||||
LOG(PR_LOG_DEBUG, ("Skipping frame time %f with audio at time %f", mDecodedFrames.Peek()->mTime, time));
|
||||
LOG(PR_LOG_DEBUG, ("%p Skipping frame time %f with audio at time %f", mDecoder, mDecodedFrames.Peek()->mTime, time));
|
||||
PlayAudio(frame);
|
||||
delete frame;
|
||||
frame = mDecodedFrames.Peek();
|
||||
|
@ -1021,7 +1029,7 @@ void nsOggDecodeStateMachine::OpenAudioStream()
|
|||
PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mDecoder->GetMonitor());
|
||||
mAudioStream = new nsAudioStream();
|
||||
if (!mAudioStream) {
|
||||
LOG(PR_LOG_ERROR, ("Could not create audio stream"));
|
||||
LOG(PR_LOG_ERROR, ("%p Could not create audio stream", mDecoder));
|
||||
}
|
||||
else {
|
||||
mAudioStream->Init(mAudioChannels, mAudioRate, nsAudioStream::FORMAT_FLOAT32);
|
||||
|
@ -1199,7 +1207,7 @@ void nsOggDecodeStateMachine::Shutdown()
|
|||
|
||||
// Change state before issuing shutdown request to threads so those
|
||||
// threads can start exiting cleanly during the Shutdown call.
|
||||
LOG(PR_LOG_DEBUG, ("Changed state to SHUTDOWN"));
|
||||
LOG(PR_LOG_DEBUG, ("%p Changed state to SHUTDOWN", mDecoder));
|
||||
mState = DECODER_STATE_SHUTDOWN;
|
||||
mon.NotifyAll();
|
||||
|
||||
|
@ -1217,7 +1225,7 @@ void nsOggDecodeStateMachine::Decode()
|
|||
// we are currently buffering.
|
||||
nsAutoMonitor mon(mDecoder->GetMonitor());
|
||||
if (mState == DECODER_STATE_BUFFERING) {
|
||||
LOG(PR_LOG_DEBUG, ("Changed state from BUFFERING to DECODING"));
|
||||
LOG(PR_LOG_DEBUG, ("%p Changed state from BUFFERING to DECODING", mDecoder));
|
||||
mState = DECODER_STATE_DECODING;
|
||||
mon.NotifyAll();
|
||||
}
|
||||
|
@ -1234,7 +1242,7 @@ void nsOggDecodeStateMachine::Seek(float aTime)
|
|||
float duration = static_cast<float>(mDuration) / 1000.0;
|
||||
NS_ASSERTION(mSeekTime >= 0 && mSeekTime <= duration,
|
||||
"Can only seek in range [0,duration]");
|
||||
LOG(PR_LOG_DEBUG, ("Changed state to SEEKING (to %f)", aTime));
|
||||
LOG(PR_LOG_DEBUG, ("%p Changed state to SEEKING (to %f)", mDecoder, aTime));
|
||||
mState = DECODER_STATE_SEEKING;
|
||||
}
|
||||
|
||||
|
@ -1274,7 +1282,7 @@ static void GetBufferedBytes(nsMediaStream* aStream, nsTArray<ByteRange>& aRange
|
|||
|
||||
nsresult nsOggDecodeStateMachine::Seek(float aTime, nsChannelReader* aReader)
|
||||
{
|
||||
LOG(PR_LOG_DEBUG, ("About to seek OggPlay to %fms", aTime));
|
||||
LOG(PR_LOG_DEBUG, ("%p About to seek OggPlay to %fms", mDecoder, aTime));
|
||||
nsMediaStream* stream = aReader->Stream();
|
||||
nsAutoTArray<ByteRange, 16> ranges;
|
||||
stream->Pin();
|
||||
|
@ -1297,7 +1305,7 @@ nsresult nsOggDecodeStateMachine::Seek(float aTime, nsChannelReader* aReader)
|
|||
stream->GetLength());
|
||||
}
|
||||
|
||||
LOG(PR_LOG_DEBUG, ("Finished seeking OggPlay"));
|
||||
LOG(PR_LOG_DEBUG, ("%p Finished seeking OggPlay", mDecoder));
|
||||
|
||||
return (rv < 0) ? NS_ERROR_FAILURE : NS_OK;
|
||||
}
|
||||
|
@ -1460,7 +1468,7 @@ nsresult nsOggDecodeStateMachine::Run()
|
|||
NS_DispatchToMainThread(metadataLoadedEvent, NS_DISPATCH_NORMAL);
|
||||
|
||||
if (mState == DECODER_STATE_DECODING_METADATA) {
|
||||
LOG(PR_LOG_DEBUG, ("Changed state from DECODING_METADATA to DECODING"));
|
||||
LOG(PR_LOG_DEBUG, ("%p Changed state from DECODING_METADATA to DECODING", mDecoder));
|
||||
mState = DECODER_STATE_DECODING;
|
||||
}
|
||||
}
|
||||
|
@ -1499,7 +1507,7 @@ nsresult nsOggDecodeStateMachine::Run()
|
|||
continue;
|
||||
|
||||
if (mDecodingCompleted) {
|
||||
LOG(PR_LOG_DEBUG, ("Changed state from DECODING to COMPLETED"));
|
||||
LOG(PR_LOG_DEBUG, ("%p Changed state from DECODING to COMPLETED", mDecoder));
|
||||
mState = DECODER_STATE_COMPLETED;
|
||||
StopStepDecodeThread(&mon);
|
||||
continue;
|
||||
|
@ -1544,7 +1552,7 @@ nsresult nsOggDecodeStateMachine::Run()
|
|||
if (mPlaying) {
|
||||
PausePlayback();
|
||||
}
|
||||
LOG(PR_LOG_DEBUG, ("Changed state from DECODING to BUFFERING"));
|
||||
LOG(PR_LOG_DEBUG, ("%p Changed state from DECODING to BUFFERING", mDecoder));
|
||||
} else {
|
||||
if (mBufferExhausted) {
|
||||
// This will wake up the step decode thread and force it to
|
||||
|
@ -1629,7 +1637,7 @@ nsresult nsOggDecodeStateMachine::Run()
|
|||
// Change state to DECODING now. SeekingStopped will call
|
||||
// nsOggDecodeStateMachine::Seek to reset our state to SEEKING
|
||||
// if we need to seek again.
|
||||
LOG(PR_LOG_DEBUG, ("Changed state from SEEKING (to %f) to DECODING", seekTime));
|
||||
LOG(PR_LOG_DEBUG, ("%p Changed state from SEEKING (to %f) to DECODING", mDecoder, seekTime));
|
||||
mState = DECODER_STATE_DECODING;
|
||||
nsCOMPtr<nsIRunnable> stopEvent;
|
||||
if (mDecodedFrames.GetCount() > 1) {
|
||||
|
@ -1655,14 +1663,14 @@ nsresult nsOggDecodeStateMachine::Run()
|
|||
!mDecoder->mReader->Stream()->IsDataCachedToEndOfStream(mDecoder->mDecoderPosition) &&
|
||||
!mDecoder->mReader->Stream()->IsSuspendedByCache()) {
|
||||
LOG(PR_LOG_DEBUG,
|
||||
("In buffering: buffering data until %d bytes available or %f seconds",
|
||||
("%p In buffering: buffering data until %d bytes available or %f seconds", mDecoder,
|
||||
PRUint32(mBufferingEndOffset - mDecoder->mReader->Stream()->GetCachedDataEnd(mDecoder->mDecoderPosition)),
|
||||
BUFFERING_WAIT - (now - mBufferingStart).ToSeconds()));
|
||||
mon.Wait(PR_MillisecondsToInterval(1000));
|
||||
if (mState == DECODER_STATE_SHUTDOWN)
|
||||
continue;
|
||||
} else {
|
||||
LOG(PR_LOG_DEBUG, ("Changed state from BUFFERING to DECODING"));
|
||||
LOG(PR_LOG_DEBUG, ("%p Changed state from BUFFERING to DECODING", mDecoder));
|
||||
mState = DECODER_STATE_DECODING;
|
||||
}
|
||||
|
||||
|
@ -1707,9 +1715,9 @@ nsresult nsOggDecodeStateMachine::Run()
|
|||
|
||||
if (mAudioStream) {
|
||||
mon.Exit();
|
||||
LOG(PR_LOG_DEBUG, ("Begin nsAudioStream::Drain"));
|
||||
LOG(PR_LOG_DEBUG, ("%p Begin nsAudioStream::Drain", mDecoder));
|
||||
mAudioStream->Drain();
|
||||
LOG(PR_LOG_DEBUG, ("End nsAudioStream::Drain"));
|
||||
LOG(PR_LOG_DEBUG, ("%p End nsAudioStream::Drain", mDecoder));
|
||||
mon.Enter();
|
||||
|
||||
// After the drain call the audio stream is unusable. Close it so that
|
||||
|
@ -1749,13 +1757,13 @@ nsresult nsOggDecodeStateMachine::Run()
|
|||
|
||||
void nsOggDecodeStateMachine::LoadOggHeaders(nsChannelReader* aReader)
|
||||
{
|
||||
LOG(PR_LOG_DEBUG, ("Loading Ogg Headers"));
|
||||
LOG(PR_LOG_DEBUG, ("%p Loading Ogg Headers", mDecoder));
|
||||
mPlayer = oggplay_open_with_reader(aReader);
|
||||
if (mPlayer) {
|
||||
LOG(PR_LOG_DEBUG, ("There are %d tracks", oggplay_get_num_tracks(mPlayer)));
|
||||
LOG(PR_LOG_DEBUG, ("%p There are %d tracks", mDecoder, oggplay_get_num_tracks(mPlayer)));
|
||||
|
||||
for (int i = 0; i < oggplay_get_num_tracks(mPlayer); ++i) {
|
||||
LOG(PR_LOG_DEBUG, ("Tracks %d: %s", i, oggplay_get_track_typename(mPlayer, i)));
|
||||
LOG(PR_LOG_DEBUG, ("%p Tracks %d: %s", mDecoder, i, oggplay_get_track_typename(mPlayer, i)));
|
||||
if (mVideoTrack == -1 && oggplay_get_track_type(mPlayer, i) == OGGZ_CONTENT_THEORA) {
|
||||
oggplay_set_callback_num_frames(mPlayer, i, 1);
|
||||
mVideoTrack = i;
|
||||
|
@ -1764,7 +1772,7 @@ void nsOggDecodeStateMachine::LoadOggHeaders(nsChannelReader* aReader)
|
|||
oggplay_get_video_fps(mPlayer, i, &fpsd, &fpsn);
|
||||
mFramerate = fpsd == 0 ? 0.0 : float(fpsn)/float(fpsd);
|
||||
mCallbackPeriod = 1.0 / mFramerate;
|
||||
LOG(PR_LOG_DEBUG, ("Frame rate: %f", mFramerate));
|
||||
LOG(PR_LOG_DEBUG, ("%p Frame rate: %f", mDecoder, mFramerate));
|
||||
|
||||
int aspectd, aspectn;
|
||||
// this can return E_OGGPLAY_UNINITIALISED if the video has
|
||||
|
@ -1784,7 +1792,7 @@ void nsOggDecodeStateMachine::LoadOggHeaders(nsChannelReader* aReader)
|
|||
oggplay_set_offset(mPlayer, i, OGGPLAY_AUDIO_OFFSET);
|
||||
oggplay_get_audio_samplerate(mPlayer, i, &mAudioRate);
|
||||
oggplay_get_audio_channels(mPlayer, i, &mAudioChannels);
|
||||
LOG(PR_LOG_DEBUG, ("samplerate: %d, channels: %d", mAudioRate, mAudioChannels));
|
||||
LOG(PR_LOG_DEBUG, ("%p samplerate: %d, channels: %d", mDecoder, mAudioRate, mAudioChannels));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1800,7 +1808,7 @@ void nsOggDecodeStateMachine::LoadOggHeaders(nsChannelReader* aReader)
|
|||
oggplay_set_callback_num_frames(mPlayer, mAudioTrack, OGGPLAY_FRAMES_PER_CALLBACK);
|
||||
mCallbackPeriod = 1.0 / (float(mAudioRate) / OGGPLAY_FRAMES_PER_CALLBACK);
|
||||
}
|
||||
LOG(PR_LOG_DEBUG, ("Callback Period: %f", mCallbackPeriod));
|
||||
LOG(PR_LOG_DEBUG, ("%p Callback Period: %f", mDecoder, mCallbackPeriod));
|
||||
|
||||
oggplay_use_buffer(mPlayer, OGGPLAY_BUFFER_SIZE);
|
||||
|
||||
|
@ -1838,12 +1846,12 @@ void nsOggDecodeStateMachine::SetTracksActive()
|
|||
{
|
||||
if (mVideoTrack != -1 &&
|
||||
oggplay_set_track_active(mPlayer, mVideoTrack) < 0) {
|
||||
LOG(PR_LOG_ERROR, ("Could not set track %d active", mVideoTrack));
|
||||
LOG(PR_LOG_ERROR, ("%p Could not set track %d active", mDecoder, mVideoTrack));
|
||||
}
|
||||
|
||||
if (mAudioTrack != -1 &&
|
||||
oggplay_set_track_active(mPlayer, mAudioTrack) < 0) {
|
||||
LOG(PR_LOG_ERROR, ("Could not set track %d active", mAudioTrack));
|
||||
LOG(PR_LOG_ERROR, ("%p Could not set track %d active", mDecoder, mAudioTrack));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1896,6 +1904,12 @@ nsOggDecoder::nsOggDecoder() :
|
|||
mIgnoreProgressData(PR_FALSE)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsOggDecoder);
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (!gOggDecoderLog) {
|
||||
gOggDecoderLog = PR_NewLogModule("nsOggDecoder");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
PRBool nsOggDecoder::Init(nsHTMLMediaElement* aElement)
|
||||
|
|
|
@ -257,6 +257,8 @@ when destroying the nsOggDecoder object.
|
|||
#if !defined(nsOggDecoder_h_)
|
||||
#define nsOggDecoder_h_
|
||||
|
||||
#include "nsMediaDecoder.h"
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIThread.h"
|
||||
|
@ -271,7 +273,6 @@ when destroying the nsOggDecoder object.
|
|||
#include "gfxContext.h"
|
||||
#include "gfxRect.h"
|
||||
#include "oggplay/oggplay.h"
|
||||
#include "nsMediaDecoder.h"
|
||||
|
||||
class nsAudioStream;
|
||||
class nsOggDecodeStateMachine;
|
||||
|
|
|
@ -54,6 +54,13 @@
|
|||
using mozilla::TimeDuration;
|
||||
using mozilla::TimeStamp;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
static PRLogModuleInfo* gWaveDecoderLog;
|
||||
#define LOG(type, msg) PR_LOG(gWaveDecoderLog, type, msg)
|
||||
#else
|
||||
#define LOG(type, msg)
|
||||
#endif
|
||||
|
||||
// Maximum number of seconds to wait when buffering.
|
||||
#define BUFFERING_TIMEOUT 3
|
||||
|
||||
|
@ -1160,6 +1167,12 @@ nsWaveDecoder::nsWaveDecoder()
|
|||
mResourceLoadedReported(PR_FALSE)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsWaveDecoder);
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (!gWaveDecoderLog) {
|
||||
gWaveDecoderLog = PR_NewLogModule("nsWaveDecoder");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
nsWaveDecoder::~nsWaveDecoder()
|
||||
|
|
|
@ -271,12 +271,6 @@ nsLayoutStatics::Initialize()
|
|||
}
|
||||
|
||||
#ifdef MOZ_MEDIA
|
||||
rv = nsMediaDecoder::InitLogger();
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Could not initialize nsMediaDecoder");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsHTMLMediaElement::InitMediaTypes();
|
||||
#endif
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче