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

Unified Diff: content/browser/renderer_host/media/audio_input_device_manager.h

Issue 10662049: Move the device enumerate/open/close work to device thread from IO thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Magnus' comments. Created 8 years, 6 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/browser/renderer_host/media/audio_input_device_manager.h
diff --git a/content/browser/renderer_host/media/audio_input_device_manager.h b/content/browser/renderer_host/media/audio_input_device_manager.h
index 96bff65679102dd59554b1e2d057e1223cf1c2c6..d871bca9f202fc39be4cbdcf400e0c61486ce229 100644
--- a/content/browser/renderer_host/media/audio_input_device_manager.h
+++ b/content/browser/renderer_host/media/audio_input_device_manager.h
@@ -6,8 +6,8 @@
// communicates with MediaStreamManager and AudioInputRendererHost on the
// browser IO thread, handles queries like enumerate/open/close from
// MediaStreamManager and start/stop from AudioInputRendererHost.
-
-// All the queries and work are handled on the IO thread.
+// The work for enumerate/open/close is handled asynchronously on Media Stream
+// device thread, while start/stop are synchronous API on IO thread.
tommi (sloooow) - chröme 2012/07/02 13:36:36 are synchronous on the IO thread.
no longer working on chromium 2012/07/04 12:35:25 Done.
#ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_
#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_
@@ -21,10 +21,6 @@
#include "content/common/media/media_stream_options.h"
#include "media/audio/audio_device_name.h"
-namespace media {
-class AudioManager;
-}
-
namespace media_stream {
class AudioInputDeviceManagerEventHandler;
@@ -41,7 +37,8 @@ class CONTENT_EXPORT AudioInputDeviceManager
static const int kInvalidSessionId;
static const char kInvalidDeviceId[];
- explicit AudioInputDeviceManager(media::AudioManager* audio_manager);
+ explicit AudioInputDeviceManager(
+ scoped_refptr<base::MessageLoopProxy> message_loop);
tommi (sloooow) - chröme 2012/07/02 13:36:36 why scoped_refptr<> here? instead just do: explic
tommi (sloooow) - chröme 2012/07/02 13:36:36 add a comment here about what message loop this is
no longer working on chromium 2012/07/04 12:35:25 Done with changing the name to device_loop. I hav
no longer working on chromium 2012/07/04 12:35:25 Done.
// MediaStreamProvider implementation, called on IO thread.
virtual void Register(MediaStreamProviderListener* listener) OVERRIDE;
@@ -61,20 +58,32 @@ class CONTENT_EXPORT AudioInputDeviceManager
friend class base::RefCountedThreadSafe<AudioInputDeviceManager>;
virtual ~AudioInputDeviceManager();
+ // Executed on media stream device thread.
+ void EnumerateOnDeviceThread();
+ void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& device);
+ void CloseOnDeviceThread(int session_id);
+
// Executed on IO thread to call Listener.
void DevicesEnumeratedOnIOThread(StreamDeviceInfoArray* devices);
void OpenedOnIOThread(int session_id);
void ClosedOnIOThread(int session_id);
void ErrorOnIOThread(int session_id, MediaStreamProviderError error);
+ // Helpers.
tommi (sloooow) - chröme 2012/07/02 13:36:36 this comment doesn't really add anything so just r
no longer working on chromium 2012/07/04 12:35:25 Done.
+ bool IsOnDeviceThread() const;
+
+ // Only accessed on Browser::IO thread.
MediaStreamProviderListener* listener_;
int next_capture_session_id_;
typedef std::map<int, AudioInputDeviceManagerEventHandler*> EventHandlerMap;
EventHandlerMap event_handlers_;
+
+ // Only accessed from media stream device thread.
typedef std::map<int, media::AudioDeviceName> AudioInputDeviceMap;
AudioInputDeviceMap devices_;
- // TODO(tommi): Is it necessary to store this as a member?
- media::AudioManager* audio_manager_;
+
+ // The message loop of media stream device thread that this object runs on.
+ scoped_refptr<base::MessageLoopProxy> message_loop_;
tommi (sloooow) - chröme 2012/07/02 13:36:36 device_loop_ or media_stream_loop_?
no longer working on chromium 2012/07/04 12:35:25 Done.
DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager);
};

Powered by Google App Engine
This is Rietveld 408576698