Bug 842415 - Signaling code - replace PR_Lock calls with MutexAutoLock r=jesup

This commit is contained in:
Ethan Hugg 2013-02-19 09:38:41 -08:00
Родитель df4a6ddf5d
Коммит 8b39436934
2 изменённых файлов: 4 добавлений и 10 удалений

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

@ -162,13 +162,12 @@ PeerConnectionMedia::AddStream(nsIDOMMediaStream* aMediaStream, uint32_t *stream
// allow one of each.
// TODO(ekr@rtfm.com): remove this when multiple of each stream
// is allowed
PR_Lock(mLocalSourceStreamsLock);
mozilla::MutexAutoLock lock(mLocalSourceStreamsLock);
for (uint32_t u = 0; u < mLocalSourceStreams.Length(); u++) {
nsRefPtr<LocalSourceStreamInfo> localSourceStream = mLocalSourceStreams[u];
if (localSourceStream->GetMediaStream()->GetHintContents() & hints) {
CSFLogError(logTag, "Only one stream of any given type allowed");
PR_Unlock(mLocalSourceStreamsLock);
return NS_ERROR_FAILURE;
}
}
@ -188,7 +187,6 @@ PeerConnectionMedia::AddStream(nsIDOMMediaStream* aMediaStream, uint32_t *stream
mLocalSourceStreams.AppendElement(localSourceStream);
PR_Unlock(mLocalSourceStreamsLock);
return NS_OK;
}
@ -201,17 +199,15 @@ PeerConnectionMedia::RemoveStream(nsIDOMMediaStream* aMediaStream, uint32_t *str
CSFLogDebugS(logTag, __FUNCTION__ << ": MediaStream: " << static_cast<void*>(aMediaStream));
PR_Lock(mLocalSourceStreamsLock);
mozilla::MutexAutoLock lock(mLocalSourceStreamsLock);
for (uint32_t u = 0; u < mLocalSourceStreams.Length(); u++) {
nsRefPtr<LocalSourceStreamInfo> localSourceStream = mLocalSourceStreams[u];
if (localSourceStream->GetMediaStream() == stream) {
*stream_id = u;
PR_Unlock(mLocalSourceStreamsLock);
return NS_OK;
}
}
PR_Unlock(mLocalSourceStreamsLock);
return NS_ERROR_ILLEGAL_VALUE;
}

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

@ -238,11 +238,10 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
public:
PeerConnectionMedia(PeerConnectionImpl *parent)
: mParent(parent),
mLocalSourceStreamsLock(PR_NewLock()),
mLocalSourceStreamsLock("PeerConnectionMedia.mLocalSourceStreamsLock"),
mIceCtx(NULL) {}
~PeerConnectionMedia() {
PR_DestroyLock(mLocalSourceStreamsLock);
}
nsresult Init(const std::vector<mozilla::NrIceStunServer>& stun_servers);
@ -345,11 +344,10 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
PeerConnectionImpl *mParent;
// A list of streams returned from GetUserMedia
PRLock *mLocalSourceStreamsLock;
mozilla::Mutex mLocalSourceStreamsLock;
nsTArray<nsRefPtr<LocalSourceStreamInfo> > mLocalSourceStreams;
// A list of streams provided by the other side
PRLock *mRemoteSourceStreamsLock;
nsTArray<nsRefPtr<RemoteSourceStreamInfo> > mRemoteSourceStreams;
// ICE objects