Index: chrome/renderer/media/cast_receiver_audio_valve.h |
diff --git a/chrome/renderer/media/cast_receiver_audio_valve.h b/chrome/renderer/media/cast_receiver_audio_valve.h |
index ebc1209ff25d241fecca24cc2efc692c9a196e77..f6c09a74a26c125268962b6c5d90a31df508e5e7 100644 |
--- a/chrome/renderer/media/cast_receiver_audio_valve.h |
+++ b/chrome/renderer/media/cast_receiver_audio_valve.h |
@@ -6,37 +6,53 @@ |
#define CHROME_RENDERER_MEDIA_CAST_RECEIVER_AUDIO_VALVE_H_ |
#include "base/synchronization/lock.h" |
+#include "base/time/time.h" |
#include "media/base/audio_capturer_source.h" |
+#include "media/base/audio_push_fifo.h" |
namespace media { |
class AudioBus; |
} |
-// Forwards calls to |cb| until Stop is called. |
+// Forwards calls to |cb| until Stop is called. If the client requested a |
+// different buffer size than that provided by the Cast Receiver, AudioPushFifo |
+// is used to rectify that. |
+// |
// Thread-safe. |
// All functions may block depending on contention. |
class CastReceiverAudioValve : |
- public media::AudioCapturerSource::CaptureCallback, |
public base::RefCountedThreadSafe<CastReceiverAudioValve> { |
public: |
- explicit CastReceiverAudioValve( |
- media::AudioCapturerSource::CaptureCallback* cb); |
+ CastReceiverAudioValve(const media::AudioParameters& params, |
+ media::AudioCapturerSource::CaptureCallback* cb); |
- // AudioCapturerSource::CaptureCallback implementation. |
- void Capture(const media::AudioBus* audio_source, |
- int audio_delay_milliseconds, |
- double volume, |
- bool key_pressed) override; |
- void OnCaptureError(const std::string& message) override; |
+ // Called on an unknown thread to provide more decoded audio data from the |
+ // Cast Receiver. |
+ void DeliverDecodedAudio(const media::AudioBus* audio_bus, |
+ base::TimeTicks playout_time); |
// When this returns, no more calls will be forwarded to |cb|. |
void Stop(); |
private: |
friend class base::RefCountedThreadSafe<CastReceiverAudioValve>; |
- ~CastReceiverAudioValve() override; |
+ |
+ ~CastReceiverAudioValve(); |
+ |
+ // Called by AudioPushFifo zero or more times during the call to Capture(). |
+ // Delivers audio data in the required buffer size to |cb_|. |
+ void DeliverRebufferedAudio(const media::AudioBus& audio_bus, |
+ int frame_delay); |
+ |
media::AudioCapturerSource::CaptureCallback* cb_; |
base::Lock lock_; |
+ |
+ media::AudioPushFifo fifo_; |
+ const int sample_rate_; |
+ |
+ // Used to pass the current playout time between DeliverDecodedAudio() and |
+ // DeviliverRebufferedAudio(). |
+ base::TimeTicks current_playout_time_; |
}; |
#endif // CHROME_RENDERER_MEDIA_CAST_RECEIVER_AUDIO_VALVE_H_ |