OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa.h" | 5 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <unordered_set> | 10 #include <unordered_set> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/numerics/saturated_arithmetic.h" | 18 #include "base/numerics/saturated_arithmetic.h" |
19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
20 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
21 #include "base/threading/platform_thread.h" | 21 #include "base/threading/platform_thread.h" |
22 #include "base/threading/thread_task_runner_handle.h" | 22 #include "base/threading/thread_task_runner_handle.h" |
23 #include "base/time/time.h" | 23 #include "base/time/time.h" |
24 #include "chromecast/base/chromecast_switches.h" | 24 #include "chromecast/base/chromecast_switches.h" |
25 #include "chromecast/media/base/audio_device_ids.h" | 25 #include "chromecast/media/base/audio_device_ids.h" |
26 #include "chromecast/media/cma/backend/alsa/alsa_wrapper.h" | 26 #include "chromecast/media/cma/backend/alsa/alsa_wrapper.h" |
| 27 #include "chromecast/media/cma/backend/alsa/cast_audio_json.h" |
27 #include "chromecast/media/cma/backend/alsa/filter_group.h" | 28 #include "chromecast/media/cma/backend/alsa/filter_group.h" |
28 #include "chromecast/media/cma/backend/alsa/post_processing_pipeline_parser.h" | 29 #include "chromecast/media/cma/backend/alsa/post_processing_pipeline_parser.h" |
29 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.h" | 30 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.h" |
30 #include "chromecast/public/media/audio_post_processor_shlib.h" | 31 #include "chromecast/public/media/audio_post_processor_shlib.h" |
31 #include "media/audio/audio_device_description.h" | 32 #include "media/audio/audio_device_description.h" |
32 #include "media/base/audio_bus.h" | 33 #include "media/base/audio_bus.h" |
33 #include "media/base/audio_sample_types.h" | 34 #include "media/base/audio_sample_types.h" |
34 #include "media/base/media_switches.h" | 35 #include "media/base/media_switches.h" |
35 | 36 |
36 #define RETURN_REPORT_ERROR(snd_func, ...) \ | 37 #define RETURN_REPORT_ERROR(snd_func, ...) \ |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 std::unordered_set<std::string> used_streams; | 271 std::unordered_set<std::string> used_streams; |
271 for (auto& stream_pipeline : pipeline_parser->GetStreamPipelines()) { | 272 for (auto& stream_pipeline : pipeline_parser->GetStreamPipelines()) { |
272 const auto& device_ids = stream_pipeline.stream_types; | 273 const auto& device_ids = stream_pipeline.stream_types; |
273 for (const std::string& stream_type : device_ids) { | 274 for (const std::string& stream_type : device_ids) { |
274 CHECK(IsOutputDeviceId(stream_type)) | 275 CHECK(IsOutputDeviceId(stream_type)) |
275 << stream_type << " is not a stream type. Stream types are listed " | 276 << stream_type << " is not a stream type. Stream types are listed " |
276 << "in chromecast/media/base/audio_device_ids.cc and " | 277 << "in chromecast/media/base/audio_device_ids.cc and " |
277 << "media/audio/audio_device_description.cc"; | 278 << "media/audio/audio_device_description.cc"; |
278 CHECK(used_streams.insert(stream_type).second) | 279 CHECK(used_streams.insert(stream_type).second) |
279 << "Multiple instances of stream type '" << stream_type << "' in " | 280 << "Multiple instances of stream type '" << stream_type << "' in " |
280 << pipeline_parser->GetFilePath() << "."; | 281 << kCastAudioJsonFilePath << "."; |
281 } | 282 } |
282 filter_groups_.push_back(base::MakeUnique<FilterGroup>( | 283 filter_groups_.push_back(base::MakeUnique<FilterGroup>( |
283 kNumInputChannels, false /* mono_mixer */, | 284 kNumInputChannels, false /* mono_mixer */, |
284 *device_ids.begin() /* name */, stream_pipeline.pipeline, device_ids, | 285 *device_ids.begin() /* name */, stream_pipeline.pipeline, device_ids, |
285 std::vector<FilterGroup*>() /* mixed_inputs */)); | 286 std::vector<FilterGroup*>() /* mixed_inputs */)); |
286 if (device_ids.find(::media::AudioDeviceDescription::kDefaultDeviceId) != | 287 if (device_ids.find(::media::AudioDeviceDescription::kDefaultDeviceId) != |
287 device_ids.end()) { | 288 device_ids.end()) { |
288 default_filter_ = filter_groups_.back().get(); | 289 default_filter_ = filter_groups_.back().get(); |
289 } | 290 } |
290 } | 291 } |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 } | 1080 } |
1080 for (auto&& input : inputs_) { | 1081 for (auto&& input : inputs_) { |
1081 // Volume limits don't apply to effects streams. | 1082 // Volume limits don't apply to effects streams. |
1082 if (input->primary() && input->content_type() == type) { | 1083 if (input->primary() && input->content_type() == type) { |
1083 input->SetContentTypeVolume(effective_volume, fade_ms); | 1084 input->SetContentTypeVolume(effective_volume, fade_ms); |
1084 } | 1085 } |
1085 } | 1086 } |
1086 } | 1087 } |
1087 | 1088 |
1088 void StreamMixerAlsa::SetPostProcessorConfig(const std::string& name, | 1089 void StreamMixerAlsa::SetPostProcessorConfig(const std::string& name, |
1089 const std::string& message) { | 1090 const std::string& config) { |
1090 RUN_ON_MIXER_THREAD(&StreamMixerAlsa::SetPostProcessorConfig, name, message); | 1091 RUN_ON_MIXER_THREAD(&StreamMixerAlsa::SetPostProcessorConfig, name, config); |
1091 for (auto&& filter_group : filter_groups_) { | 1092 for (auto&& filter_group : filter_groups_) { |
1092 filter_group->SetPostProcessorConfig(name, message); | 1093 filter_group->SetPostProcessorConfig(name, config); |
1093 } | 1094 } |
1094 } | 1095 } |
1095 | 1096 |
1096 } // namespace media | 1097 } // namespace media |
1097 } // namespace chromecast | 1098 } // namespace chromecast |
OLD | NEW |