Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: third_party/WebKit/Source/platform/mediastream/MediaStreamSource.cpp

Issue 2762413004: Revert of Revert "Pull AudioDestinationConsumer off the Blink GC heap." (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/mediastream/MediaStreamSource.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 void MediaStreamSource::addAudioConsumer(AudioDestinationConsumer* consumer) { 78 void MediaStreamSource::addAudioConsumer(AudioDestinationConsumer* consumer) {
79 ASSERT(m_requiresConsumer); 79 ASSERT(m_requiresConsumer);
80 MutexLocker locker(m_audioConsumersLock); 80 MutexLocker locker(m_audioConsumersLock);
81 m_audioConsumers.insert(consumer); 81 m_audioConsumers.insert(consumer);
82 } 82 }
83 83
84 bool MediaStreamSource::removeAudioConsumer( 84 bool MediaStreamSource::removeAudioConsumer(
85 AudioDestinationConsumer* consumer) { 85 AudioDestinationConsumer* consumer) {
86 ASSERT(m_requiresConsumer); 86 ASSERT(m_requiresConsumer);
87 MutexLocker locker(m_audioConsumersLock); 87 MutexLocker locker(m_audioConsumersLock);
88 HeapHashSet<Member<AudioDestinationConsumer>>::iterator it = 88 auto it = m_audioConsumers.find(consumer);
89 m_audioConsumers.find(consumer);
90 if (it == m_audioConsumers.end()) 89 if (it == m_audioConsumers.end())
91 return false; 90 return false;
92 m_audioConsumers.erase(it); 91 m_audioConsumers.erase(it);
93 return true; 92 return true;
94 } 93 }
95 94
96 void MediaStreamSource::getSettings(WebMediaStreamTrack::Settings& settings) { 95 void MediaStreamSource::getSettings(WebMediaStreamTrack::Settings& settings) {
97 settings.deviceId = id(); 96 settings.deviceId = id();
98 } 97 }
99 98
100 void MediaStreamSource::setAudioFormat(size_t numberOfChannels, 99 void MediaStreamSource::setAudioFormat(size_t numberOfChannels,
101 float sampleRate) { 100 float sampleRate) {
102 ASSERT(m_requiresConsumer); 101 ASSERT(m_requiresConsumer);
103 MutexLocker locker(m_audioConsumersLock); 102 MutexLocker locker(m_audioConsumersLock);
104 for (HeapHashSet<Member<AudioDestinationConsumer>>::iterator it = 103 for (AudioDestinationConsumer* consumer : m_audioConsumers)
105 m_audioConsumers.begin(); 104 consumer->setFormat(numberOfChannels, sampleRate);
106 it != m_audioConsumers.end(); ++it)
107 (*it)->setFormat(numberOfChannels, sampleRate);
108 } 105 }
109 106
110 void MediaStreamSource::consumeAudio(AudioBus* bus, size_t numberOfFrames) { 107 void MediaStreamSource::consumeAudio(AudioBus* bus, size_t numberOfFrames) {
111 ASSERT(m_requiresConsumer); 108 ASSERT(m_requiresConsumer);
112 MutexLocker locker(m_audioConsumersLock); 109 MutexLocker locker(m_audioConsumersLock);
113 // Prevent GCs from going ahead while this iteration runs, attempting to 110 // Prevent GCs from going ahead while this iteration runs, attempting to
114 // pinpoint crbug.com/682945 failures. 111 // pinpoint crbug.com/682945 failures.
115 ThreadState::MainThreadGCForbiddenScope scope; 112 ThreadState::MainThreadGCForbiddenScope scope;
116 for (HeapHashSet<Member<AudioDestinationConsumer>>::iterator it = 113 for (AudioDestinationConsumer* consumer : m_audioConsumers)
117 m_audioConsumers.begin(); 114 consumer->consumeAudio(bus, numberOfFrames);
118 it != m_audioConsumers.end(); ++it)
119 (*it)->consumeAudio(bus, numberOfFrames);
120 } 115 }
121 116
122 DEFINE_TRACE(MediaStreamSource) { 117 DEFINE_TRACE(MediaStreamSource) {
123 visitor->trace(m_observers); 118 visitor->trace(m_observers);
124 visitor->trace(m_audioConsumers);
125 } 119 }
126 120
127 } // namespace blink 121 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/mediastream/MediaStreamSource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698