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

Unified Diff: content/renderer/media/media_stream_audio_track.h

Issue 2777583002: Move getUserMedia finish to "when audio track configured". (Closed)
Patch Set: Fix error introduced when addressing review Created 3 years, 8 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
Index: content/renderer/media/media_stream_audio_track.h
diff --git a/content/renderer/media/media_stream_audio_track.h b/content/renderer/media/media_stream_audio_track.h
index f5fa754787f80b3ec34b8651276e49d3dd054678..8e049c1e228a2ff6b8f72899353e6f7fcfd11b54 100644
--- a/content/renderer/media/media_stream_audio_track.h
+++ b/content/renderer/media/media_stream_audio_track.h
@@ -8,6 +8,7 @@
#include <memory>
#include "base/atomicops.h"
+#include "base/bind.h"
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
@@ -72,6 +73,11 @@ class CONTENT_EXPORT MediaStreamAudioTrack : public MediaStreamTrack {
// method to provide safe down-casting to their type.
virtual void* GetClassIdentifier() const;
+ void SetFormatConfiguredCallback(base::OnceCallback<void()> callback) {
+ base::AutoLock guard(format_set_guard_);
+ format_set_callback_ = std::move(callback);
+ }
+
private:
friend class MediaStreamAudioSource;
friend class MediaStreamAudioDeliverer<MediaStreamAudioTrack>;
@@ -95,6 +101,8 @@ class CONTENT_EXPORT MediaStreamAudioTrack : public MediaStreamTrack {
void getSettings(blink::WebMediaStreamTrack::Settings& settings) override;
private:
+ bool format_is_set();
+
// In debug builds, check that all methods that could cause object graph
// or data flow changes are being called on the main thread.
base::ThreadChecker thread_checker_;
@@ -111,6 +119,11 @@ class CONTENT_EXPORT MediaStreamAudioTrack : public MediaStreamTrack {
// Buffer used to deliver silent audio data while this track is disabled.
std::unique_ptr<media::AudioBus> silent_bus_;
+ // True if the track knows its configuration (OnSetFormat has been called).
+ bool format_is_set_ = false;
+ base::OnceCallback<void()> format_set_callback_;
+ base::Lock format_set_guard_;
+
// Provides weak pointers that are valid until Stop() is called.
base::WeakPtrFactory<MediaStreamAudioTrack> weak_factory_;

Powered by Google App Engine
This is Rietveld 408576698