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

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

Issue 2101303004: Pass delay and timestamp to AudioSourceCallback::OnMoreData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fix Mac CQ errors. Created 4 years, 2 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 <vector> 9 #include <vector>
9 10
10 #include "base/callback.h" 11 #include "base/callback.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
14 #include "base/time/time.h"
13 #include "media/audio/audio_io.h" 15 #include "media/audio/audio_io.h"
14 #include "media/base/audio_converter.h" 16 #include "media/base/audio_converter.h"
15 #include "media/base/audio_parameters.h" 17 #include "media/base/audio_parameters.h"
16 18
17 namespace chromecast { 19 namespace chromecast {
18 namespace media { 20 namespace media {
19 21
20 class CastAudioManager; 22 class CastAudioManager;
21 class CastAudioOutputStream; 23 class CastAudioOutputStream;
22 24
23 // CastAudioMixer mixes multiple AudioOutputStreams and passes the mixed 25 // CastAudioMixer mixes multiple AudioOutputStreams and passes the mixed
24 // stream down to a single AudioOutputStream to be rendered by the CMA backend. 26 // stream down to a single AudioOutputStream to be rendered by the CMA backend.
25 class CastAudioMixer : public ::media::AudioOutputStream::AudioSourceCallback { 27 class CastAudioMixer : public ::media::AudioOutputStream::AudioSourceCallback {
26 public: 28 public:
27 using RealStreamFactory = base::Callback<::media::AudioOutputStream*( 29 using RealStreamFactory = base::Callback<::media::AudioOutputStream*(
28 const ::media::AudioParameters&)>; 30 const ::media::AudioParameters&)>;
29 31
30 CastAudioMixer(const RealStreamFactory& real_stream_factory); 32 explicit CastAudioMixer(const RealStreamFactory& real_stream_factory);
31 ~CastAudioMixer() override; 33 ~CastAudioMixer() override;
32 34
33 virtual ::media::AudioOutputStream* MakeStream( 35 virtual ::media::AudioOutputStream* MakeStream(
34 const ::media::AudioParameters& params, 36 const ::media::AudioParameters& params,
35 CastAudioManager* audio_manager); 37 CastAudioManager* audio_manager);
36 38
37 private: 39 private:
38 class MixerProxyStream; 40 class MixerProxyStream;
39 41
40 // ::media::AudioOutputStream::AudioSourceCallback implementation 42 // ::media::AudioOutputStream::AudioSourceCallback implementation
41 int OnMoreData(::media::AudioBus* dest, 43 int OnMoreData(base::TimeDelta delay,
42 uint32_t total_bytes_delay, 44 base::TimeTicks delay_timestamp,
43 uint32_t frames_skipped) override; 45 int prior_frames_skipped,
46 ::media::AudioBus* dest) override;
47
44 void OnError(::media::AudioOutputStream* stream) override; 48 void OnError(::media::AudioOutputStream* stream) override;
45 49
46 // MixedAudioOutputStreams call Register on opening and AddInput on starting. 50 // MixedAudioOutputStreams call Register on opening and AddInput on starting.
47 bool Register(MixerProxyStream* proxy_stream); 51 bool Register(MixerProxyStream* proxy_stream);
48 void Unregister(MixerProxyStream* proxy_stream); 52 void Unregister(MixerProxyStream* proxy_stream);
49 void AddInput(::media::AudioConverter::InputCallback* input_callback); 53 void AddInput(::media::AudioConverter::InputCallback* input_callback);
50 void RemoveInput(::media::AudioConverter::InputCallback* input_callback); 54 void RemoveInput(::media::AudioConverter::InputCallback* input_callback);
51 55
52 base::ThreadChecker thread_checker_; 56 base::ThreadChecker thread_checker_;
53 std::unique_ptr<::media::AudioConverter> mixer_; 57 std::unique_ptr<::media::AudioConverter> mixer_;
54 bool error_; 58 bool error_;
55 59
56 const RealStreamFactory real_stream_factory_; 60 const RealStreamFactory real_stream_factory_;
57 ::media::AudioOutputStream* output_stream_; 61 ::media::AudioOutputStream* output_stream_;
58 ::media::AudioParameters output_params_; 62 ::media::AudioParameters output_params_;
59 63
60 std::vector<MixerProxyStream*> proxy_streams_; 64 std::vector<MixerProxyStream*> proxy_streams_;
61 65
62 DISALLOW_COPY_AND_ASSIGN(CastAudioMixer); 66 DISALLOW_COPY_AND_ASSIGN(CastAudioMixer);
63 }; 67 };
64 68
65 } // namespace media 69 } // namespace media
66 } // namespace chromecast 70 } // namespace chromecast
67 71
68 #endif // CHROMECAST_MEDIA_AUDIO_CAST_AUDIO_MIXER_H_ 72 #endif // CHROMECAST_MEDIA_AUDIO_CAST_AUDIO_MIXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698