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

Unified Diff: media/audio/audio_manager_base.cc

Issue 2867443002: Remove ScopedVector from media/audio/ (Closed)
Patch Set: Addressed review comments Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_manager_base.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_manager_base.cc
diff --git a/media/audio/audio_manager_base.cc b/media/audio/audio_manager_base.cc
index 498aa1feb8ad8e1be955d0caad93b6a5d0d1c6a6..e149216e02de6e049fe778868a75e805f3e4f877 100644
--- a/media/audio/audio_manager_base.cc
+++ b/media/audio/audio_manager_base.cc
@@ -68,7 +68,8 @@ class AudioManagerBase::CompareByParams {
public:
explicit CompareByParams(const DispatcherParams* dispatcher)
: dispatcher_(dispatcher) {}
- bool operator()(DispatcherParams* dispatcher_in) const {
+ bool operator()(
+ const std::unique_ptr<DispatcherParams>& dispatcher_in) const {
// We will reuse the existing dispatcher when:
// 1) Unified IO is not used, input_params and output_params of the
// existing dispatcher are the same as the requested dispatcher.
@@ -277,16 +278,14 @@ AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy(
}
}
- DispatcherParams* dispatcher_params =
- new DispatcherParams(params, output_params, output_device_id);
+ std::unique_ptr<DispatcherParams> dispatcher_params =
+ base::MakeUnique<DispatcherParams>(params, output_params,
+ output_device_id);
- AudioOutputDispatchers::iterator it =
- std::find_if(output_dispatchers_.begin(), output_dispatchers_.end(),
- CompareByParams(dispatcher_params));
- if (it != output_dispatchers_.end()) {
- delete dispatcher_params;
+ auto it = std::find_if(output_dispatchers_.begin(), output_dispatchers_.end(),
+ CompareByParams(dispatcher_params.get()));
+ if (it != output_dispatchers_.end())
return (*it)->dispatcher->CreateStreamProxy();
- }
const base::TimeDelta kCloseDelay =
base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds);
@@ -308,8 +307,8 @@ AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy(
}
dispatcher_params->dispatcher = std::move(dispatcher);
- output_dispatchers_.push_back(dispatcher_params);
- return dispatcher_params->dispatcher->CreateStreamProxy();
+ output_dispatchers_.push_back(std::move(dispatcher_params));
+ return output_dispatchers_.back()->dispatcher->CreateStreamProxy();
}
void AudioManagerBase::ShowAudioInputSettings() {
« no previous file with comments | « media/audio/audio_manager_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698