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

Unified Diff: media/audio/audio_manager_base.cc

Issue 2867443002: Remove ScopedVector from media/audio/ (Closed)
Patch Set: 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..968642b3fd21791568ac4589e336b538a5f1ca22 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,14 +278,16 @@ AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy(
}
}
- DispatcherParams* dispatcher_params =
- new DispatcherParams(params, output_params, output_device_id);
+ std::unique_ptr<DispatcherParams> dispatcher_params_ptr =
+ base::MakeUnique<DispatcherParams>(params, output_params,
+ output_device_id);
- AudioOutputDispatchers::iterator it =
- std::find_if(output_dispatchers_.begin(), output_dispatchers_.end(),
- CompareByParams(dispatcher_params));
+ DispatcherParams* dispatcher_params = dispatcher_params_ptr.get();
tommi (sloooow) - chröme 2017/05/05 08:58:43 nit: just remove this variable and pass dispatcher
Chandan 2017/05/05 09:19:32 Done.
+
+ auto it = std::find_if(output_dispatchers_.begin(), output_dispatchers_.end(),
+ CompareByParams(dispatcher_params));
if (it != output_dispatchers_.end()) {
- delete dispatcher_params;
+ dispatcher_params_ptr.reset();
tommi (sloooow) - chröme 2017/05/05 08:58:43 necessary? dispatcher_params_ptr is about to go ou
Chandan 2017/05/05 09:19:32 Right. This can be dropped.
return (*it)->dispatcher->CreateStreamProxy();
}
@@ -307,8 +310,8 @@ AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy(
this, output_params, output_device_id, kCloseDelay);
}
- dispatcher_params->dispatcher = std::move(dispatcher);
- output_dispatchers_.push_back(dispatcher_params);
+ dispatcher_params_ptr->dispatcher = std::move(dispatcher);
+ output_dispatchers_.push_back(std::move(dispatcher_params_ptr));
return dispatcher_params->dispatcher->CreateStreamProxy();
tommi (sloooow) - chröme 2017/05/05 08:58:43 If we're removing |dispatcher_params|, you'd have
Chandan 2017/05/05 09:19:32 Intention was to avoid accessing the vector. Initi
}
« 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