Backed out changeset 5454dcaa31ff (bug 1208373)

This commit is contained in:
Carsten "Tomcat" Book 2016-06-09 15:18:42 +02:00
Родитель 2c32e5b3ad
Коммит 79d88f89e8
6 изменённых файлов: 21 добавлений и 73 удалений

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

@ -98,10 +98,10 @@ DOMMediaStream::TrackPort::GetSourceTrackId() const
}
already_AddRefed<Pledge<bool>>
DOMMediaStream::TrackPort::BlockSourceTrackId(TrackID aTrackId, BlockingMode aBlockingMode)
DOMMediaStream::TrackPort::BlockSourceTrackId(TrackID aTrackId)
{
if (mInputPort) {
return mInputPort->BlockSourceTrackId(aTrackId, aBlockingMode);
return mInputPort->BlockSourceTrackId(aTrackId);
}
RefPtr<Pledge<bool>> rejected = new Pledge<bool>();
rejected->Reject(NS_ERROR_FAILURE);
@ -1040,10 +1040,8 @@ DOMMediaStream::CloneDOMTrack(MediaStreamTrack& aTrack,
if (aTrack.Ended()) {
// For extra suspenders, make sure that we don't forward data by mistake
// to the clone when the original has already ended.
// We only block END_EXISTING to allow any pending clones to end.
RefPtr<Pledge<bool, nsresult>> blockingPledge =
inputPort->BlockSourceTrackId(inputTrackID,
BlockingMode::END_EXISTING);
inputPort->BlockSourceTrackId(inputTrackID);
Unused << blockingPledge;
}
@ -1251,9 +1249,7 @@ DOMMediaStream::BlockPlaybackTrack(TrackPort* aTrack)
{
MOZ_ASSERT(aTrack);
++mTracksPendingRemoval;
RefPtr<Pledge<bool>> p =
aTrack->BlockSourceTrackId(aTrack->GetTrack()->mTrackID,
BlockingMode::CREATION);
RefPtr<Pledge<bool>> p = aTrack->BlockSourceTrackId(aTrack->GetTrack()->mTrackID);
RefPtr<DOMMediaStream> self = this;
p->Then([self] (const bool& aIgnore) { self->NotifyPlaybackTrackBlocked(); },
[] (const nsresult& aIgnore) { NS_ERROR("Could not remove track from MSG"); }

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

@ -33,8 +33,6 @@ class MediaStreamDirectListener;
class MediaStreamGraph;
class ProcessedMediaStream;
enum class BlockingMode;
namespace dom {
class AudioNode;
class HTMLCanvasElement;
@ -305,8 +303,7 @@ public:
* destroyed. Returns a pledge that gets resolved when the MediaStreamGraph
* has applied the block in the playback stream.
*/
already_AddRefed<media::Pledge<bool, nsresult>>
BlockSourceTrackId(TrackID aTrackId, BlockingMode aBlockingMode);
already_AddRefed<media::Pledge<bool, nsresult>> BlockSourceTrackId(TrackID aTrackId);
private:
RefPtr<MediaInputPort> mInputPort;

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

@ -3136,26 +3136,24 @@ MediaInputPort::SetGraphImpl(MediaStreamGraphImpl* aGraph)
}
void
MediaInputPort::BlockSourceTrackIdImpl(TrackID aTrackId, BlockingMode aBlockingMode)
MediaInputPort::BlockSourceTrackIdImpl(TrackID aTrackId)
{
mBlockedTracks.AppendElement(Pair<TrackID, BlockingMode>(aTrackId, aBlockingMode));
mBlockedTracks.AppendElement(aTrackId);
}
already_AddRefed<Pledge<bool>>
MediaInputPort::BlockSourceTrackId(TrackID aTrackId, BlockingMode aBlockingMode)
MediaInputPort::BlockSourceTrackId(TrackID aTrackId)
{
class Message : public ControlMessage {
public:
explicit Message(MediaInputPort* aPort,
TrackID aTrackId,
BlockingMode aBlockingMode,
already_AddRefed<nsIRunnable> aRunnable)
: ControlMessage(aPort->GetDestination()),
mPort(aPort), mTrackId(aTrackId), mBlockingMode(aBlockingMode),
mRunnable(aRunnable) {}
mPort(aPort), mTrackId(aTrackId), mRunnable(aRunnable) {}
void Run() override
{
mPort->BlockSourceTrackIdImpl(mTrackId, mBlockingMode);
mPort->BlockSourceTrackIdImpl(mTrackId);
if (mRunnable) {
mStream->Graph()->DispatchToMainThreadAfterStreamStateUpdate(mRunnable.forget());
}
@ -3166,7 +3164,6 @@ MediaInputPort::BlockSourceTrackId(TrackID aTrackId, BlockingMode aBlockingMode)
}
RefPtr<MediaInputPort> mPort;
TrackID mTrackId;
BlockingMode mBlockingMode;
nsCOMPtr<nsIRunnable> mRunnable;
};
@ -3179,7 +3176,7 @@ MediaInputPort::BlockSourceTrackId(TrackID aTrackId, BlockingMode aBlockingMode)
pledge->Resolve(true);
return NS_OK;
});
GraphImpl()->AppendMessage(MakeUnique<Message>(this, aTrackId, aBlockingMode, runnable.forget()));
GraphImpl()->AppendMessage(MakeUnique<Message>(this, aTrackId, runnable.forget()));
return pledge.forget();
}
@ -3222,7 +3219,7 @@ ProcessedMediaStream::AllocateInputPort(MediaStream* aStream, TrackID aTrackID,
aInputNumber, aOutputNumber);
if (aBlockedTracks) {
for (TrackID trackID : *aBlockedTracks) {
port->BlockSourceTrackIdImpl(trackID, BlockingMode::CREATION);
port->BlockSourceTrackIdImpl(trackID);
}
}
port->SetGraphImpl(GraphImpl());

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

@ -1176,23 +1176,6 @@ protected:
bool mNeedsMixing;
};
/**
* The blocking mode decides how a track should be blocked in a MediaInputPort.
*/
enum class BlockingMode
{
/**
* BlockingMode CREATION blocks the source track from being created
* in the destination. It'll end if it already exists.
*/
CREATION,
/**
* BlockingMode END_EXISTING allows a track to be created in the destination
* but will end it before any data has been passed through.
*/
END_EXISTING,
};
/**
* Represents a connection between a ProcessedMediaStream and one of its
* input streams.
@ -1274,39 +1257,16 @@ public:
* Returns a pledge that resolves on the main thread after the track block has
* been applied by the MSG.
*/
already_AddRefed<media::Pledge<bool, nsresult>> BlockSourceTrackId(TrackID aTrackId,
BlockingMode aBlockingMode);
already_AddRefed<media::Pledge<bool, nsresult>> BlockSourceTrackId(TrackID aTrackId);
private:
void BlockSourceTrackIdImpl(TrackID aTrackId, BlockingMode aBlockingMode);
void BlockSourceTrackIdImpl(TrackID aTrackId);
public:
// Returns true if aTrackId has not been blocked for any reason and this port
// has not been locked to another track.
// Returns true if aTrackId has not been blocked and this port has not
// been locked to another track.
bool PassTrackThrough(TrackID aTrackId) {
bool blocked = false;
for (auto pair : mBlockedTracks) {
if (pair.first() == aTrackId &&
(pair.second() == BlockingMode::CREATION ||
pair.second() == BlockingMode::END_EXISTING)) {
blocked = true;
break;
}
}
return !blocked && (mSourceTrack == TRACK_ANY || mSourceTrack == aTrackId);
}
// Returns true if aTrackId has not been blocked for track creation and this
// port has not been locked to another track.
bool AllowCreationOf(TrackID aTrackId) {
bool blocked = false;
for (auto pair : mBlockedTracks) {
if (pair.first() == aTrackId &&
pair.second() == BlockingMode::CREATION) {
blocked = true;
break;
}
}
return !blocked && (mSourceTrack == TRACK_ANY || mSourceTrack == aTrackId);
return !mBlockedTracks.Contains(aTrackId) &&
(mSourceTrack == TRACK_ANY || mSourceTrack == aTrackId);
}
uint16_t InputNumber() const { return mInputNumber; }
@ -1361,9 +1321,7 @@ private:
// Web Audio.
const uint16_t mInputNumber;
const uint16_t mOutputNumber;
typedef Pair<TrackID, BlockingMode> BlockedTrack;
nsTArray<BlockedTrack> mBlockedTracks;
nsTArray<TrackID> mBlockedTracks;
// Our media stream graph
MediaStreamGraphImpl* mGraph;

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

@ -237,7 +237,7 @@ MediaStreamTrack::Stop()
MOZ_ASSERT(mOwningStream, "Every MediaStreamTrack needs an owning DOMMediaStream");
DOMMediaStream::TrackPort* port = mOwningStream->FindOwnedTrackPort(*this);
MOZ_ASSERT(port, "A MediaStreamTrack must exist in its owning DOMMediaStream");
RefPtr<Pledge<bool>> p = port->BlockSourceTrackId(mInputTrackID, BlockingMode::CREATION);
RefPtr<Pledge<bool>> p = port->BlockSourceTrackId(mInputTrackID);
Unused << p;
mReadyState = MediaStreamTrackState::Ended;

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

@ -107,7 +107,7 @@ TrackUnionStream::TrackUnionStream(DOMMediaStream* aWrapper) :
break;
}
}
if (!found && mInputs[i]->AllowCreationOf(tracks->GetID())) {
if (!found && mInputs[i]->PassTrackThrough(tracks->GetID())) {
bool trackFinished = false;
trackAdded = true;
uint32_t mapIndex = AddTrack(mInputs[i], tracks.get(), aFrom);