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

Unified Diff: media/audio/audio_system_impl.cc

Issue 2692203003: Switching AudioOutputAuthorizationHandler from using AudioManager interface to AudioSystem one. (Closed)
Patch Set: Created 3 years, 10 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
Index: media/audio/audio_system_impl.cc
diff --git a/media/audio/audio_system_impl.cc b/media/audio/audio_system_impl.cc
index fdffa70fda0f70cbce1e60457eb2044e9287a254..bde76d5f2a1a192b1611e0c9e94e15d4388e9c96 100644
--- a/media/audio/audio_system_impl.cc
+++ b/media/audio/audio_system_impl.cc
@@ -7,6 +7,7 @@
#include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h"
#include "base/task_runner_util.h"
+#include "media/audio/audio_device_description.h"
#include "media/audio/audio_manager.h"
// Using base::Unretained for |audio_manager_| is safe since it is deleted after
@@ -28,6 +29,22 @@ AudioParameters GetInputParametersOnDeviceThread(AudioManager* audio_manager,
return audio_manager->GetInputStreamParameters(device_id);
}
+AudioParameters GetOutputParametersOnDeviceThread(
+ AudioManager* audio_manager,
+ const std::string& device_id) {
+ DCHECK(audio_manager->GetTaskRunner()->BelongsToCurrentThread());
+
+ // TODO(olka): remove this when
+ // AudioManager::Get[Default]OutputStreamParameters() works this way on all
+ // the platforms.
tommi (sloooow) - chröme 2017/02/14 12:14:26 This covers a particular set of cases but not when
o1ka 2017/02/14 15:00:49 TabAudioCapture are input devices, not output ones
tommi (sloooow) - chröme 2017/02/14 15:30:32 I am aware of that and I didn't say it was output.
o1ka 2017/02/14 15:47:12 You haven't said that you meant both Input and Out
tommi (sloooow) - chröme 2017/02/14 16:30:48 I wasn't talking specifically about either input o
+ if (!audio_manager->HasAudioOutputDevices())
+ return AudioParameters();
+
+ return media::AudioDeviceDescription::IsDefaultDevice(device_id)
o1ka 2017/02/14 11:37:03 guidou@: it seems that all the usecases make this
tommi (sloooow) - chröme 2017/02/14 12:14:26 Doesn't GetOutputStreamParameters already handle t
o1ka 2017/02/14 15:00:49 No, it does not. One
tommi (sloooow) - chröme 2017/02/14 15:30:32 Uhm, ok, time for fact checking! :) On Mac and Wi
o1ka 2017/02/14 15:47:12 No, it does not :) Take a look here: AudioParamete
tommi (sloooow) - chröme 2017/02/14 16:30:48 Windows: https://cs.chromium.org/chromium/src/medi
+ ? audio_manager->GetDefaultOutputStreamParameters()
+ : audio_manager->GetOutputStreamParameters(device_id);
+}
+
} // namespace
AudioSystemImpl::AudioSystemImpl(AudioManager* audio_manager)
@@ -62,6 +79,22 @@ void AudioSystemImpl::GetInputStreamParameters(
std::move(on_params_cb));
}
+void AudioSystemImpl::GetOutputStreamParameters(
+ const std::string& device_id,
+ OnAudioParamsCallback on_params_cb) const {
+ if (GetTaskRunner()->BelongsToCurrentThread()) {
+ GetTaskRunner()->PostTask(
+ FROM_HERE, base::Bind(on_params_cb, GetOutputParametersOnDeviceThread(
+ audio_manager_, device_id)));
+ return;
+ }
+ base::PostTaskAndReplyWithResult(
+ GetTaskRunner(), FROM_HERE,
+ base::Bind(&GetOutputParametersOnDeviceThread,
+ base::Unretained(audio_manager_), device_id),
+ std::move(on_params_cb));
+}
+
void AudioSystemImpl::HasInputDevices(OnBoolCallback on_has_devices_cb) const {
if (GetTaskRunner()->BelongsToCurrentThread()) {
GetTaskRunner()->PostTask(

Powered by Google App Engine
This is Rietveld 408576698