| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 MEDIA_AUDIO_VIRTUAL_AUDIO_OUTPUT_STREAM_H_ | 5 #ifndef MEDIA_AUDIO_VIRTUAL_AUDIO_OUTPUT_STREAM_H_ |
| 6 #define MEDIA_AUDIO_VIRTUAL_AUDIO_OUTPUT_STREAM_H_ | 6 #define MEDIA_AUDIO_VIRTUAL_AUDIO_OUTPUT_STREAM_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| 11 #include "media/audio/audio_io.h" | 11 #include "media/audio/audio_io.h" |
| 12 #include "media/audio/audio_parameters.h" | 12 #include "media/audio/audio_parameters.h" |
| 13 #include "media/base/audio_converter.h" | 13 #include "media/base/audio_converter.h" |
| 14 #include "media/base/audio_shifter.h" |
| 14 | 15 |
| 15 namespace media { | 16 namespace media { |
| 16 | 17 |
| 17 class VirtualAudioInputStream; | 18 class VirtualAudioInputStream; |
| 18 | 19 |
| 19 // VirtualAudioOutputStream attaches to a VirtualAudioInputStream when Start() | 20 // VirtualAudioOutputStream attaches to a VirtualAudioInputStream when Start() |
| 20 // is called and is used as an audio source. VirtualAudioOutputStream also | 21 // is called and is used as an audio source. VirtualAudioOutputStream also |
| 21 // implements an interface so it can be used as an input to AudioConverter so | 22 // implements an interface so it can be used as an input to AudioConverter so |
| 22 // that we can get audio frames that match the AudioParameters that | 23 // that we can get audio frames that match the AudioParameters that |
| 23 // VirtualAudioInputStream expects. | 24 // VirtualAudioInputStream expects. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 AfterCloseCallback after_close_cb_; | 60 AfterCloseCallback after_close_cb_; |
| 60 | 61 |
| 61 AudioSourceCallback* callback_; | 62 AudioSourceCallback* callback_; |
| 62 double volume_; | 63 double volume_; |
| 63 | 64 |
| 64 base::ThreadChecker thread_checker_; | 65 base::ThreadChecker thread_checker_; |
| 65 | 66 |
| 66 DISALLOW_COPY_AND_ASSIGN(VirtualAudioOutputStream); | 67 DISALLOW_COPY_AND_ASSIGN(VirtualAudioOutputStream); |
| 67 }; | 68 }; |
| 68 | 69 |
| 70 class MEDIA_EXPORT AudioPushSink : public AudioInputStream::AudioInputCallback { |
| 71 public: |
| 72 virtual void Start() = 0; |
| 73 virtual void Stop() = 0; |
| 74 virtual void Close() = 0; |
| 75 }; |
| 76 |
| 77 class MEDIA_EXPORT LoopbackSink : public AudioPushSink, |
| 78 public AudioConverter::InputCallback { |
| 79 public: |
| 80 typedef base::Callback<void(LoopbackSink* sink)> AfterCloseCallback; |
| 81 |
| 82 LoopbackSink(AudioParameters param, |
| 83 VirtualAudioInputStream* target, |
| 84 AfterCloseCallback callback); |
| 85 ~LoopbackSink() override; |
| 86 |
| 87 // AudioPushSink |
| 88 void Start() override; |
| 89 void Stop() override; |
| 90 void Close() override; |
| 91 void OnData(AudioInputStream* stream, |
| 92 const AudioBus* source, |
| 93 uint32_t hardware_delay_bytes, |
| 94 double volume) override; |
| 95 void OnError(AudioInputStream* stream) override; |
| 96 |
| 97 // AudioConverter::InputCallback |
| 98 double ProvideInput(AudioBus* audio_bus, |
| 99 base::TimeDelta buffer_delay) override; |
| 100 |
| 101 private: |
| 102 bool started_; |
| 103 AudioParameters params_; |
| 104 VirtualAudioInputStream* target_; |
| 105 std::unique_ptr<AudioShifter> shifter_; |
| 106 AfterCloseCallback after_close_callback_; |
| 107 }; |
| 108 |
| 69 } // namespace media | 109 } // namespace media |
| 70 | 110 |
| 71 #endif // MEDIA_AUDIO_VIRTUAL_AUDIO_OUTPUT_STREAM_H_ | 111 #endif // MEDIA_AUDIO_VIRTUAL_AUDIO_OUTPUT_STREAM_H_ |
| OLD | NEW |