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

Side by Side Diff: chromecast/media/audio/cast_audio_manager.cc

Issue 1105803002: Exposes a shlib interface for media/audio path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates to interfacesa and impls to coordinate with CMA CL Created 5 years, 4 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chromecast/media/audio/cast_audio_manager.h"
6
7 #include "base/logging.h"
8 #include "chromecast/base/task_runner_impl.h"
9 #include "chromecast/media/audio/chromecast_device_audio_output_stream.h"
10 #include "chromecast/media/base/converters.h"
11 #include "chromecast/public/cast_audio_output_device.h"
12 #include "chromecast/public/cast_audio_output_stream.h"
13
14 namespace chromecast {
15 namespace media {
16
17 namespace {
18
19 // Default parameters to provide for input stream.
20 const int kDefaultBitsPerSample = 16;
21 const int kDefaultInputBufferSize = 1024;
22 const int kDefaultSampleRate = 32000;
23
24 } // namespace
25
26 CastAudioManager::CastAudioManager(::media::AudioLogFactory* audio_log_factory,
27 CastAudioOutputDevice* output_device)
28 : ::media::AudioManagerBase(audio_log_factory),
29 audio_output_device_(output_device) {
30 CHECK(audio_output_device_);
31 SetMaxOutputStreamsAllowed(
32 audio_output_device_->GetMaximumOutputStreamsAllowed());
33 }
34
35 CastAudioManager::~CastAudioManager() {
36 Shutdown();
37 }
38
39 bool CastAudioManager::HasAudioOutputDevices() {
40 return true;
41 }
42
43 bool CastAudioManager::HasAudioInputDevices() {
44 return false;
45 }
46
47 void CastAudioManager::ShowAudioInputSettings() {
48 LOG(WARNING) << "No support for input audio devices.";
49 }
50
51 void CastAudioManager::GetAudioInputDeviceNames(
52 ::media::AudioDeviceNames* device_names) {
53 LOG(WARNING) << "No support for input audio devices.";
54 }
55
56 ::media::AudioParameters CastAudioManager::GetInputStreamParameters(
57 const std::string& device_id) {
58 // TODO(slan): Providing the invalid parameters impacts also the output
59 // parameter selection during WebAudio playback (and it fails). (b/20630187).
60 LOG(WARNING) << "No support for input audio devices.";
61 return ::media::AudioParameters(
62 ::media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
63 ::media::CHANNEL_LAYOUT_STEREO,
64 kDefaultSampleRate,
65 kDefaultBitsPerSample,
66 kDefaultInputBufferSize);
67 }
68
69 ::media::AudioInputStream* CastAudioManager::MakeLinearInputStream(
70 const ::media::AudioParameters& params,
71 const std::string& device_id) {
72 LOG(WARNING) << "No support for input audio devices";
73 return nullptr;
74 }
75
76 ::media::AudioInputStream* CastAudioManager::MakeLowLatencyInputStream(
77 const ::media::AudioParameters& params,
78 const std::string& device_id) {
79 LOG(WARNING) << "No support for input audio devices";
80 return nullptr;
81 }
82
83 ::media::AudioOutputStream* CastAudioManager::MakeLinearOutputStream(
84 const ::media::AudioParameters& params) {
85 DCHECK_EQ(::media::AudioParameters::AUDIO_PCM_LINEAR, params.format());
86 return MakeCastOutputStream(params);
87 }
88
89 ::media::AudioOutputStream* CastAudioManager::MakeLowLatencyOutputStream(
90 const ::media::AudioParameters& params,
91 const std::string& device_id) {
92 DCHECK_EQ(::media::AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format());
93 return MakeCastOutputStream(params);
94 }
95
96 ::media::AudioParameters CastAudioManager::GetPreferredOutputStreamParameters(
97 const std::string& output_device_id,
98 const ::media::AudioParameters& suggested) {
99 // Convert the suggested params into the chromecast variety.
100 AudioParameters params = FromChromiumParams(suggested);
101
102 // Get the preferences. Convert them back to Chromium params and return.
103 params = audio_output_device_->GetPreferredOutputStreamParameters(params);
104 return FromChromecastParams(params);
105 }
106
107 ::media::AudioOutputStream* CastAudioManager::MakeCastOutputStream(
108 const ::media::AudioParameters& params) {
109 // Get the Cast output stream.
110 AudioParameters chromecast_params = FromChromiumParams(params);
111 CastAudioOutputStream* stream = audio_output_device_->MakeOutputStream(
112 chromecast_params, new chromecast::TaskRunnerImpl());
halliwell 2015/07/29 15:06:57 nit: chromecast:: unnecessary.
slan 2015/07/29 19:51:55 Removed.
113 if (!stream)
114 return nullptr;
115
116 // Note: The caller of this method does not own the returned instance of the
117 // stream. The stream MUST call AudioManagerBase::ReleaseOutputStream() as
118 // the last line of its Close() method to avoid a leak. This pattern is not
119 // favorable, but is currently required by AudioManagerBase. Please see
120 // ChromecastDeviceAudioOutputStream::Close() before changing this behavior.
121 return new ChromecastDeviceAudioOutputStream(stream, chromecast_params, this);
122 }
123
124 } // namespace media
125 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698