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

Side by Side Diff: chromecast/media/audio/cast_audio_mixer.h

Issue 2879703003: [chromecast] Moves CastAudioOutputStream::Backend to CMA thread. (Closed)
Patch Set: addressed comments Created 3 years, 6 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef CHROMECAST_MEDIA_AUDIO_CAST_AUDIO_MIXER_H_ 5 #ifndef CHROMECAST_MEDIA_AUDIO_CAST_AUDIO_MIXER_H_
6 #define CHROMECAST_MEDIA_AUDIO_CAST_AUDIO_MIXER_H_ 6 #define CHROMECAST_MEDIA_AUDIO_CAST_AUDIO_MIXER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <set>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "media/audio/audio_io.h" 15 #include "media/audio/audio_io.h"
16 #include "media/base/audio_converter.h" 16 #include "media/base/audio_converter.h"
17 #include "media/base/audio_parameters.h" 17 #include "media/base/audio_parameters.h"
18 18
19 namespace chromecast { 19 namespace chromecast {
20 namespace media { 20 namespace media {
21 21
22 class CastAudioManager; 22 class CastAudioManager;
23 23
24 // CastAudioMixer mixes multiple AudioOutputStreams and passes the mixed 24 // CastAudioMixer mixes multiple AudioOutputStreams and passes the mixed
25 // stream down to a single AudioOutputStream to be rendered by the CMA backend. 25 // stream down to a single AudioOutputStream to be rendered by the CMA backend.
26 class CastAudioMixer : public ::media::AudioOutputStream::AudioSourceCallback { 26 class CastAudioMixer : public ::media::AudioOutputStream::AudioSourceCallback {
27 public: 27 public:
28 using RealStreamFactory = base::Callback<::media::AudioOutputStream*( 28 explicit CastAudioMixer(CastAudioManager* audio_manager);
29 const ::media::AudioParameters&)>;
30
31 explicit CastAudioMixer(const RealStreamFactory& real_stream_factory);
32 ~CastAudioMixer() override; 29 ~CastAudioMixer() override;
33 30
34 virtual ::media::AudioOutputStream* MakeStream( 31 virtual ::media::AudioOutputStream* MakeStream(
35 const ::media::AudioParameters& params, 32 const ::media::AudioParameters& params);
36 CastAudioManager* audio_manager);
37 33
38 private: 34 private:
39 class MixerProxyStream; 35 class MixerProxyStream;
40 36
41 // ::media::AudioOutputStream::AudioSourceCallback implementation 37 // ::media::AudioOutputStream::AudioSourceCallback implementation
42 int OnMoreData(base::TimeDelta delay, 38 int OnMoreData(base::TimeDelta delay,
43 base::TimeTicks delay_timestamp, 39 base::TimeTicks delay_timestamp,
44 int prior_frames_skipped, 40 int prior_frames_skipped,
45 ::media::AudioBus* dest) override; 41 ::media::AudioBus* dest) override;
46
47 void OnError() override; 42 void OnError() override;
48 43
49 // MixedAudioOutputStreams call Register on opening and AddInput on starting. 44 // MixedAudioOutputStreams call Register on opening and AddInput on starting.
50 bool Register(MixerProxyStream* proxy_stream); 45 bool Register(MixerProxyStream* proxy_stream);
51 void Unregister(MixerProxyStream* proxy_stream); 46 void Unregister(MixerProxyStream* proxy_stream);
52 void AddInput(::media::AudioConverter::InputCallback* input_callback); 47 void AddInput(::media::AudioConverter::InputCallback* input_callback);
53 void RemoveInput(::media::AudioConverter::InputCallback* input_callback); 48 void RemoveInput(::media::AudioConverter::InputCallback* input_callback);
49 void HandleError();
54 50
55 base::ThreadChecker thread_checker_; 51 CastAudioManager* const audio_manager_;
52 bool error_;
53 std::set<MixerProxyStream*> proxy_streams_;
56 std::unique_ptr<::media::AudioConverter> mixer_; 54 std::unique_ptr<::media::AudioConverter> mixer_;
57 bool error_; 55 base::Lock mixer_lock_;
56 ::media::AudioParameters output_params_;
57 ::media::AudioOutputStream* output_stream_;
58 58
59 const RealStreamFactory real_stream_factory_; 59 THREAD_CHECKER(audio_thread_checker_);
60 ::media::AudioOutputStream* output_stream_;
61 ::media::AudioParameters output_params_;
62
63 std::vector<MixerProxyStream*> proxy_streams_;
64
65 DISALLOW_COPY_AND_ASSIGN(CastAudioMixer); 60 DISALLOW_COPY_AND_ASSIGN(CastAudioMixer);
66 }; 61 };
67 62
68 } // namespace media 63 } // namespace media
69 } // namespace chromecast 64 } // namespace chromecast
70 65
71 #endif // CHROMECAST_MEDIA_AUDIO_CAST_AUDIO_MIXER_H_ 66 #endif // CHROMECAST_MEDIA_AUDIO_CAST_AUDIO_MIXER_H_
OLDNEW
« no previous file with comments | « chromecast/media/audio/cast_audio_manager_unittest.cc ('k') | chromecast/media/audio/cast_audio_mixer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698