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

Unified Diff: media/audio/audio_output_device.h

Issue 1122393004: Add support for switching the audio output device for HTMLMediaElements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes to MediaPlayers so that they invoke callbacks in the correct threads. First complete implem… Created 5 years, 7 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: media/audio/audio_output_device.h
diff --git a/media/audio/audio_output_device.h b/media/audio/audio_output_device.h
index ca11b80d9900dfc0d52ac00d621522aa18abf9d0..be60af1ea8bd8838efb018303f678ff09b0898c6 100644
--- a/media/audio/audio_output_device.h
+++ b/media/audio/audio_output_device.h
@@ -58,8 +58,12 @@
#ifndef MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_
#define MEDIA_AUDIO_AUDIO_OUTPUT_DEVICE_H_
+#include <map>
+#include <string>
+
#include "base/basictypes.h"
#include "base/bind.h"
+#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/shared_memory.h"
#include "media/audio/audio_device_thread.h"
@@ -95,6 +99,9 @@ class MEDIA_EXPORT AudioOutputDevice
void Play() override;
void Pause() override;
bool SetVolume(double volume) override;
+ void SwitchOutputDevice(const std::string& device_id,
+ const GURL& security_origin,
+ const base::Callback<void(int)>& callback) override;
// Methods called on IO thread ----------------------------------------------
// AudioOutputIPCDelegate methods.
@@ -102,6 +109,8 @@ class MEDIA_EXPORT AudioOutputDevice
void OnStreamCreated(base::SharedMemoryHandle handle,
base::SyncSocket::Handle socket_handle,
int length) override;
+ void OnDeviceSwitched(int request_id,
+ AudioOutputIPCDelegate::DeviceSwitchResult) override;
void OnIPCClosed() override;
protected:
@@ -129,6 +138,9 @@ class MEDIA_EXPORT AudioOutputDevice
void PauseOnIOThread();
void ShutDownOnIOThread();
void SetVolumeOnIOThread(double volume);
+ void SwitchOutputDeviceOnIOThread(const std::string& device_id,
+ const GURL& security_origin,
+ const base::Callback<void(int)>& callback);
// base::MessageLoop::DestructionObserver implementation for the IO loop.
// If the IO loop dies before we do, we shut down the audio thread from here.
@@ -171,6 +183,11 @@ class MEDIA_EXPORT AudioOutputDevice
// the callback via Start(). See http://crbug.com/151051 for details.
bool stopping_hack_;
+ // Pending SwitchOutputDevice requests
+ std::map<int, base::Callback<void(int)>> switch_requests_;
miu 2015/06/03 21:01:01 When is it appropriate to have multiple switch req
+ int next_switch_request_id_;
+ int AddSwitchRequest(const base::Callback<void(int)>& callback);
+
DISALLOW_COPY_AND_ASSIGN(AudioOutputDevice);
};

Powered by Google App Engine
This is Rietveld 408576698