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

Unified Diff: chrome/renderer/media/cast_receiver_audio_valve.h

Issue 1714593003: Introduce media::AudioPushFifo and a couple of use cases (and clean-ups). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unittest compile breakage caused by recent method rename. Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/renderer/media/cast_receiver_audio_valve.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « no previous file | chrome/renderer/media/cast_receiver_audio_valve.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698