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

Side by Side Diff: content/browser/renderer_host/media/audio_input_device_manager.h

Issue 8677012: Refactor the AudioInputDeviceManager by removing the device thread. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: update Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/renderer_host/media/audio_input_device_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // AudioInputDeviceManager manages the audio input devices. In particular it 5 // AudioInputDeviceManager manages the audio input devices. In particular it
6 // communicates with MediaStreamManager and AudioInputRendererHost on the 6 // communicates with MediaStreamManager and AudioInputRendererHost on the
7 // browser IO thread, handles queries like enumerate/open/close from 7 // browser IO thread, handles queries like enumerate/open/close from
8 // MediaStreamManager and start/stop from AudioInputRendererHost. 8 // MediaStreamManager and start/stop from AudioInputRendererHost.
9 9
10 // All the queries come from the IO thread, while the work to enumerate devices 10 // All the queries and work are handled on the IO thread.
11 // is done on its own thread.
12 11
13 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ 12 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_
14 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ 13 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_
15 14
16 #include <map> 15 #include <map>
17 16
18 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
19 #include "content/browser/renderer_host/media/media_stream_provider.h" 18 #include "content/browser/renderer_host/media/media_stream_provider.h"
20 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
21 #include "content/common/media/media_stream_options.h" 20 #include "content/common/media/media_stream_options.h"
(...skipping 23 matching lines...) Expand all
45 virtual int Open(const StreamDeviceInfo& device) OVERRIDE; 44 virtual int Open(const StreamDeviceInfo& device) OVERRIDE;
46 virtual void Close(int session_id) OVERRIDE; 45 virtual void Close(int session_id) OVERRIDE;
47 46
48 // Functions used by AudioInputRenderHost, called on IO thread. 47 // Functions used by AudioInputRenderHost, called on IO thread.
49 // Start the device referenced by the session id. 48 // Start the device referenced by the session id.
50 void Start(int session_id, 49 void Start(int session_id,
51 AudioInputDeviceManagerEventHandler* event_handler); 50 AudioInputDeviceManagerEventHandler* event_handler);
52 // Stop the device referenced by the session id. 51 // Stop the device referenced by the session id.
53 void Stop(int session_id); 52 void Stop(int session_id);
54 53
55 // Function used for testing to mock platform dependent device code.
56 MessageLoop* message_loop();
57
58 private: 54 private:
59 // Executed on audio_input_device_thread_.
60 void EnumerateOnDeviceThread();
61 void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& device);
62 void CloseOnDeviceThread(int session_id);
63 void StartOnDeviceThread(int session_id);
64 void StopOnDeviceThread(int session_id);
65
66 // Executed on IO thread to call Listener. 55 // Executed on IO thread to call Listener.
67 void DevicesEnumeratedOnIOThread(const StreamDeviceInfoArray& devices); 56 void DevicesEnumeratedOnIOThread(StreamDeviceInfoArray* devices);
68 void OpenedOnIOThread(int session_id); 57 void OpenedOnIOThread(int session_id);
69 void ClosedOnIOThread(int session_id); 58 void ClosedOnIOThread(int session_id);
70 void ErrorOnIOThread(int session_id, MediaStreamProviderError error); 59 void ErrorOnIOThread(int session_id, MediaStreamProviderError error);
71 60
72 // Executed on IO thread to call the event handler.
73 void StartedOnIOThread(int session_id, const std::string& device_id);
74 void StoppedOnIOThread(int session_id);
75
76 // Executed on audio_input_device_thread_ to make sure
77 // MediaStreamProviderListener is called from IO thread.
78 void SignalError(int session_id, MediaStreamProviderError error);
79
80 // Helpers.
81 bool IsOnCaptureDeviceThread() const;
82 void UnregisterEventHandler(int session_id);
83 bool HasEventHandler(int session_id);
84
85 // Thread for all calls to AudioInputDeviceManager.
86 base::Thread audio_input_device_thread_;
87
88 // Only accessed on Browser::IO thread.
89 MediaStreamProviderListener* listener_; 61 MediaStreamProviderListener* listener_;
90 int next_capture_session_id_; 62 int next_capture_session_id_;
91 typedef std::map<int, AudioInputDeviceManagerEventHandler*> EventHandlerMap; 63 typedef std::map<int, AudioInputDeviceManagerEventHandler*> EventHandlerMap;
92 EventHandlerMap event_handlers_; 64 EventHandlerMap event_handlers_;
93
94 // Only accessed from audio_input_device_thread_.
95 typedef std::map<int, media::AudioDeviceName> AudioInputDeviceMap; 65 typedef std::map<int, media::AudioDeviceName> AudioInputDeviceMap;
96 AudioInputDeviceMap devices_; 66 AudioInputDeviceMap devices_;
97 67
98 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); 68 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager);
99 }; 69 };
100 70
101 } // namespace media_stream 71 } // namespace media_stream
102 72
103 DISABLE_RUNNABLE_METHOD_REFCOUNT(media_stream::AudioInputDeviceManager); 73 DISABLE_RUNNABLE_METHOD_REFCOUNT(media_stream::AudioInputDeviceManager);
104 74
105 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ 75 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/media/audio_input_device_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698