toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
dnicoara@chromium.org | 9f2a6f0 | 2014-01-03 21:25:00 +0000 | [diff] [blame] | 5 | #ifndef MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ |
| 6 | #define MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 7 | |
agoode@chromium.org | 2522751 | 2014-06-08 05:12:05 +0000 | [diff] [blame] | 8 | #include <alsa/asoundlib.h> |
| 9 | #include <map> |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 10 | #include <vector> |
| 11 | |
| 12 | #include "base/basictypes.h" |
agoode | 55a8b52 | 2015-03-08 12:40:17 -0700 | [diff] [blame] | 13 | #include "base/gtest_prod_util.h" |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 14 | #include "base/memory/scoped_ptr.h" |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 15 | #include "base/memory/scoped_vector.h" |
| 16 | #include "base/stl_util.h" |
agoode@chromium.org | 2522751 | 2014-06-08 05:12:05 +0000 | [diff] [blame] | 17 | #include "base/synchronization/lock.h" |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 18 | #include "base/threading/thread.h" |
agoode | f212b2a | 2015-03-19 12:53:23 -0700 | [diff] [blame] | 19 | #include "base/values.h" |
agoode | 7de413f | 2015-04-24 00:13:39 -0700 | [diff] [blame] | 20 | #include "device/udev_linux/scoped_udev.h" |
brettw | 49ff017 | 2015-05-05 12:43:04 -0700 | [diff] [blame] | 21 | #include "media/midi/midi_export.h" |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 22 | #include "media/midi/midi_manager.h" |
| 23 | |
| 24 | namespace media { |
toyoshim | e147c5e | 2015-05-07 21:58:31 -0700 | [diff] [blame] | 25 | namespace midi { |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 26 | |
brettw | 49ff017 | 2015-05-05 12:43:04 -0700 | [diff] [blame] | 27 | class MIDI_EXPORT MidiManagerAlsa final : public MidiManager { |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 28 | public: |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 29 | MidiManagerAlsa(); |
dcheng | 9e8524d | 2014-10-27 15:18:50 -0700 | [diff] [blame] | 30 | ~MidiManagerAlsa() override; |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 31 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 32 | // MidiManager implementation. |
dcheng | 9e8524d | 2014-10-27 15:18:50 -0700 | [diff] [blame] | 33 | void StartInitialization() override; |
| 34 | void DispatchSendMidiData(MidiManagerClient* client, |
| 35 | uint32 port_index, |
| 36 | const std::vector<uint8>& data, |
| 37 | double timestamp) override; |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 38 | |
| 39 | private: |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 40 | friend class MidiManagerAlsaTest; |
agoode | 55a8b52 | 2015-03-08 12:40:17 -0700 | [diff] [blame] | 41 | FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ExtractManufacturer); |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 42 | FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ToMidiPortState); |
agoode | 55a8b52 | 2015-03-08 12:40:17 -0700 | [diff] [blame] | 43 | |
agoode | b09423b | 2015-05-11 11:39:57 -0700 | [diff] [blame] | 44 | class AlsaCard; |
| 45 | typedef std::map<int, AlsaCard*> AlsaCardMap; |
| 46 | |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 47 | class MidiPort { |
agoode | f212b2a | 2015-03-19 12:53:23 -0700 | [diff] [blame] | 48 | public: |
| 49 | enum class Type { kInput, kOutput }; |
| 50 | |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 51 | MidiPort(const std::string& path, |
| 52 | const std::string& id, |
| 53 | int client_id, |
| 54 | int port_id, |
| 55 | int midi_device, |
| 56 | const std::string& client_name, |
| 57 | const std::string& port_name, |
| 58 | const std::string& manufacturer, |
| 59 | const std::string& version, |
| 60 | Type type); |
| 61 | ~MidiPort(); |
agoode | f212b2a | 2015-03-19 12:53:23 -0700 | [diff] [blame] | 62 | |
| 63 | // Gets a Value representation of this object, suitable for serialization. |
| 64 | scoped_ptr<base::Value> Value() const; |
| 65 | |
| 66 | // Gets a string version of Value in JSON format. |
| 67 | std::string JSONValue() const; |
| 68 | |
| 69 | // Gets an opaque identifier for this object, suitable for using as the id |
| 70 | // field in MidiPort.id on the web. Note that this string does not store |
| 71 | // the full state. |
| 72 | std::string OpaqueKey() const; |
| 73 | |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 74 | // Checks for equality for connected ports. |
| 75 | bool MatchConnected(const MidiPort& query) const; |
| 76 | // Checks for equality for kernel cards with id, pass 1. |
| 77 | bool MatchCardPass1(const MidiPort& query) const; |
| 78 | // Checks for equality for kernel cards with id, pass 2. |
| 79 | bool MatchCardPass2(const MidiPort& query) const; |
| 80 | // Checks for equality for non-card clients, pass 1. |
| 81 | bool MatchNoCardPass1(const MidiPort& query) const; |
| 82 | // Checks for equality for non-card clients, pass 2. |
| 83 | bool MatchNoCardPass2(const MidiPort& query) const; |
agoode | f212b2a | 2015-03-19 12:53:23 -0700 | [diff] [blame] | 84 | |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 85 | // accessors |
| 86 | std::string path() const { return path_; } |
| 87 | std::string id() const { return id_; } |
| 88 | std::string client_name() const { return client_name_; } |
| 89 | std::string port_name() const { return port_name_; } |
| 90 | std::string manufacturer() const { return manufacturer_; } |
| 91 | std::string version() const { return version_; } |
| 92 | int client_id() const { return client_id_; } |
| 93 | int port_id() const { return port_id_; } |
| 94 | int midi_device() const { return midi_device_; } |
| 95 | Type type() const { return type_; } |
| 96 | uint32 web_port_index() const { return web_port_index_; } |
| 97 | bool connected() const { return connected_; } |
| 98 | |
| 99 | // mutators |
| 100 | void set_web_port_index(uint32 web_port_index) { |
| 101 | web_port_index_ = web_port_index; |
| 102 | } |
| 103 | void set_connected(bool connected) { connected_ = connected; } |
| 104 | void Update(const std::string& path, |
| 105 | int client_id, |
| 106 | int port_id, |
| 107 | const std::string& client_name, |
| 108 | const std::string& port_name, |
| 109 | const std::string& manufacturer, |
| 110 | const std::string& version) { |
| 111 | path_ = path; |
| 112 | client_id_ = client_id; |
| 113 | port_id_ = port_id; |
| 114 | client_name_ = client_name; |
| 115 | port_name_ = port_name; |
| 116 | manufacturer_ = manufacturer; |
| 117 | version_ = version; |
| 118 | } |
| 119 | |
| 120 | private: |
| 121 | // Immutable properties. |
agoode | f212b2a | 2015-03-19 12:53:23 -0700 | [diff] [blame] | 122 | const std::string id_; |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 123 | const int midi_device_; |
| 124 | |
agoode | f212b2a | 2015-03-19 12:53:23 -0700 | [diff] [blame] | 125 | const Type type_; |
| 126 | |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 127 | // Mutable properties. These will get updated as ports move around or |
| 128 | // drivers change. |
| 129 | std::string path_; |
| 130 | int client_id_; |
| 131 | int port_id_; |
| 132 | std::string client_name_; |
| 133 | std::string port_name_; |
| 134 | std::string manufacturer_; |
| 135 | std::string version_; |
| 136 | |
| 137 | // Index for MidiManager. |
| 138 | uint32 web_port_index_; |
| 139 | |
| 140 | // Port is present in the ALSA system. |
| 141 | bool connected_; |
| 142 | |
| 143 | DISALLOW_COPY_AND_ASSIGN(MidiPort); |
agoode | 55a8b52 | 2015-03-08 12:40:17 -0700 | [diff] [blame] | 144 | }; |
| 145 | |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 146 | class MidiPortStateBase { |
| 147 | public: |
| 148 | typedef ScopedVector<MidiPort>::iterator iterator; |
agoode | bd4be9b | 2015-03-16 19:17:25 -0700 | [diff] [blame] | 149 | |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 150 | virtual ~MidiPortStateBase(); |
| 151 | |
| 152 | // Given a port, finds a port in the internal store. |
| 153 | iterator Find(const MidiPort& port); |
| 154 | |
| 155 | // Given a port, finds a connected port, using exact matching. |
| 156 | iterator FindConnected(const MidiPort& port); |
| 157 | |
| 158 | // Given a port, finds a disconnected port, using heuristic matching. |
| 159 | iterator FindDisconnected(const MidiPort& port); |
| 160 | |
| 161 | iterator begin() { return ports_.begin(); } |
| 162 | iterator end() { return ports_.end(); } |
| 163 | |
| 164 | protected: |
| 165 | MidiPortStateBase(); |
| 166 | |
agoode | b058287 | 2015-05-20 05:22:24 -0700 | [diff] [blame^] | 167 | ScopedVector<MidiPort>* ports() { return &ports_; } |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 168 | |
| 169 | private: |
| 170 | ScopedVector<MidiPort> ports_; |
| 171 | |
| 172 | DISALLOW_COPY_AND_ASSIGN(MidiPortStateBase); |
| 173 | }; |
| 174 | |
| 175 | class TemporaryMidiPortState final : public MidiPortStateBase { |
| 176 | public: |
| 177 | // Removes a port from the list without deleting it. |
| 178 | iterator weak_erase(iterator position) { |
| 179 | return ports()->weak_erase(position); |
| 180 | } |
| 181 | |
| 182 | void Insert(scoped_ptr<MidiPort> port); |
| 183 | }; |
| 184 | |
| 185 | class MidiPortState final : public MidiPortStateBase { |
| 186 | public: |
| 187 | MidiPortState(); |
| 188 | |
| 189 | // Inserts a port. Returns web_port_index. |
| 190 | uint32 Insert(scoped_ptr<MidiPort> port); |
| 191 | |
| 192 | private: |
| 193 | uint32 num_input_ports_; |
| 194 | uint32 num_output_ports_; |
| 195 | }; |
| 196 | |
| 197 | class AlsaSeqState { |
| 198 | public: |
| 199 | enum class PortDirection { kInput, kOutput, kDuplex }; |
| 200 | |
| 201 | AlsaSeqState(); |
| 202 | ~AlsaSeqState(); |
| 203 | |
| 204 | void ClientStart(int client_id, |
| 205 | const std::string& client_name, |
| 206 | snd_seq_client_type_t type); |
| 207 | bool ClientStarted(int client_id); |
| 208 | void ClientExit(int client_id); |
| 209 | void PortStart(int client_id, |
| 210 | int port_id, |
| 211 | const std::string& port_name, |
| 212 | PortDirection direction, |
| 213 | bool midi); |
| 214 | void PortExit(int client_id, int port_id); |
| 215 | snd_seq_client_type_t ClientType(int client_id) const; |
agoode | b09423b | 2015-05-11 11:39:57 -0700 | [diff] [blame] | 216 | scoped_ptr<TemporaryMidiPortState> ToMidiPortState( |
| 217 | const AlsaCardMap& alsa_cards); |
| 218 | |
| 219 | int card_client_count() { return card_client_count_; } |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 220 | |
| 221 | private: |
| 222 | class Port { |
| 223 | public: |
| 224 | Port(const std::string& name, PortDirection direction, bool midi); |
| 225 | ~Port(); |
| 226 | |
agoode | b058287 | 2015-05-20 05:22:24 -0700 | [diff] [blame^] | 227 | std::string name() const { return name_; } |
| 228 | PortDirection direction() const { return direction_; } |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 229 | // True if this port is a MIDI port, instead of another kind of ALSA port. |
agoode | b058287 | 2015-05-20 05:22:24 -0700 | [diff] [blame^] | 230 | bool midi() const { return midi_; } |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 231 | |
| 232 | private: |
| 233 | const std::string name_; |
| 234 | const PortDirection direction_; |
| 235 | const bool midi_; |
| 236 | |
| 237 | DISALLOW_COPY_AND_ASSIGN(Port); |
| 238 | }; |
| 239 | |
| 240 | class Client { |
| 241 | public: |
| 242 | typedef std::map<int, Port*> PortMap; |
| 243 | |
| 244 | Client(const std::string& name, snd_seq_client_type_t type); |
| 245 | ~Client(); |
| 246 | |
agoode | b058287 | 2015-05-20 05:22:24 -0700 | [diff] [blame^] | 247 | std::string name() const { return name_; } |
| 248 | snd_seq_client_type_t type() const { return type_; } |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 249 | void AddPort(int addr, scoped_ptr<Port> port); |
| 250 | void RemovePort(int addr); |
| 251 | PortMap::const_iterator begin() const; |
| 252 | PortMap::const_iterator end() const; |
| 253 | |
| 254 | private: |
| 255 | const std::string name_; |
| 256 | const snd_seq_client_type_t type_; |
| 257 | PortMap ports_; |
| 258 | STLValueDeleter<PortMap> ports_deleter_; |
| 259 | |
| 260 | DISALLOW_COPY_AND_ASSIGN(Client); |
| 261 | }; |
| 262 | |
| 263 | typedef std::map<int, Client*> ClientMap; |
| 264 | |
| 265 | ClientMap clients_; |
| 266 | STLValueDeleter<ClientMap> clients_deleter_; |
| 267 | |
agoode | b09423b | 2015-05-11 11:39:57 -0700 | [diff] [blame] | 268 | // This is the current number of clients we know about that have |
| 269 | // cards. When this number matches alsa_card_midi_count_, we know |
| 270 | // we are in sync between ALSA and udev. Until then, we cannot generate |
| 271 | // MIDIConnectionEvents to web clients. |
| 272 | int card_client_count_; |
| 273 | |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 274 | DISALLOW_COPY_AND_ASSIGN(AlsaSeqState); |
| 275 | }; |
| 276 | |
agoode | b09423b | 2015-05-11 11:39:57 -0700 | [diff] [blame] | 277 | class AlsaCard { |
| 278 | public: |
| 279 | AlsaCard(udev_device* dev, |
| 280 | const std::string& alsa_name, |
| 281 | const std::string& alsa_longname, |
| 282 | const std::string& alsa_driver, |
| 283 | int midi_device_count); |
| 284 | ~AlsaCard(); |
| 285 | const std::string alsa_name() const { return alsa_name_; } |
| 286 | const std::string alsa_longname() const { return alsa_longname_; } |
| 287 | const std::string manufacturer() const { return manufacturer_; } |
| 288 | const std::string alsa_driver() const { return alsa_driver_; } |
| 289 | int midi_device_count() const { return midi_device_count_; } |
| 290 | // Returns hardware path. |
| 291 | const std::string path() const; |
| 292 | // Returns the id we can use to try to match hardware across different |
| 293 | // paths. |
| 294 | const std::string id() const; |
| 295 | |
| 296 | private: |
| 297 | FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ExtractManufacturer); |
| 298 | |
| 299 | // Extracts the manufacturer using heuristics and a variety of sources. |
| 300 | static std::string ExtractManufacturerString( |
| 301 | const std::string& udev_id_vendor, |
| 302 | const std::string& udev_id_vendor_id, |
| 303 | const std::string& udev_id_vendor_from_database, |
| 304 | const std::string& alsa_name, |
| 305 | const std::string& alsa_longname); |
| 306 | |
| 307 | std::string alsa_name_; |
| 308 | std::string alsa_longname_; |
| 309 | std::string manufacturer_; |
| 310 | std::string alsa_driver_; |
| 311 | std::string path_; |
| 312 | std::string bus_; |
| 313 | std::string serial_; |
| 314 | std::string vendor_id_; |
| 315 | std::string model_id_; |
| 316 | std::string usb_interface_num_; |
| 317 | int midi_device_count_; |
| 318 | |
| 319 | DISALLOW_COPY_AND_ASSIGN(AlsaCard); |
| 320 | }; |
| 321 | |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 322 | typedef base::hash_map<int, uint32> SourceMap; |
| 323 | typedef base::hash_map<uint32, int> OutPortMap; |
| 324 | |
agoode@chromium.org | 2522751 | 2014-06-08 05:12:05 +0000 | [diff] [blame] | 325 | // An internal callback that runs on MidiSendThread. |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 326 | void SendMidiData(uint32 port_index, const std::vector<uint8>& data); |
agoode@chromium.org | 2522751 | 2014-06-08 05:12:05 +0000 | [diff] [blame] | 327 | |
agoode | bd4be9b | 2015-03-16 19:17:25 -0700 | [diff] [blame] | 328 | void ScheduleEventLoop(); |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 329 | void EventLoop(); |
agoode | bd4be9b | 2015-03-16 19:17:25 -0700 | [diff] [blame] | 330 | void ProcessSingleEvent(snd_seq_event_t* event, double timestamp); |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 331 | void ProcessClientStartEvent(int client_id); |
| 332 | void ProcessPortStartEvent(const snd_seq_addr_t& addr); |
| 333 | void ProcessClientExitEvent(const snd_seq_addr_t& addr); |
| 334 | void ProcessPortExitEvent(const snd_seq_addr_t& addr); |
agoode | 975043d | 2015-05-11 00:46:17 -0700 | [diff] [blame] | 335 | void ProcessUdevEvent(udev_device* dev); |
agoode | b09423b | 2015-05-11 11:39:57 -0700 | [diff] [blame] | 336 | void AddCard(udev_device* dev); |
| 337 | void RemoveCard(int number); |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 338 | |
| 339 | // Updates port_state_ and Web MIDI state from alsa_seq_state_. |
| 340 | void UpdatePortStateAndGenerateEvents(); |
| 341 | |
| 342 | // Enumerates ports. Call once after subscribing to the announce port. |
| 343 | void EnumerateAlsaPorts(); |
agoode | 975043d | 2015-05-11 00:46:17 -0700 | [diff] [blame] | 344 | // Enumerates udev cards. Call once after initializing the udev monitor. |
| 345 | bool EnumerateUdevCards(); |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 346 | // Returns true if successful. |
| 347 | bool CreateAlsaOutputPort(uint32 port_index, int client_id, int port_id); |
| 348 | void DeleteAlsaOutputPort(uint32 port_index); |
| 349 | // Returns true if successful. |
| 350 | bool Subscribe(uint32 port_index, int client_id, int port_id); |
| 351 | |
| 352 | AlsaSeqState alsa_seq_state_; |
| 353 | MidiPortState port_state_; |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 354 | |
agoode | bd4be9b | 2015-03-16 19:17:25 -0700 | [diff] [blame] | 355 | // ALSA seq handles. |
agoode@chromium.org | 2522751 | 2014-06-08 05:12:05 +0000 | [diff] [blame] | 356 | snd_seq_t* in_client_; |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 357 | int in_client_id_; |
agoode@chromium.org | 2522751 | 2014-06-08 05:12:05 +0000 | [diff] [blame] | 358 | snd_seq_t* out_client_; |
| 359 | int out_client_id_; |
| 360 | |
| 361 | // One input port, many output ports. |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 362 | int in_port_id_; |
| 363 | OutPortMap out_ports_; // guarded by out_ports_lock_ |
| 364 | base::Lock out_ports_lock_; // guards out_ports_ |
agoode@chromium.org | 2522751 | 2014-06-08 05:12:05 +0000 | [diff] [blame] | 365 | |
agoode | bd4be9b | 2015-03-16 19:17:25 -0700 | [diff] [blame] | 366 | // Mapping from ALSA client:port to our index. |
agoode@chromium.org | 2522751 | 2014-06-08 05:12:05 +0000 | [diff] [blame] | 367 | SourceMap source_map_; |
| 368 | |
agoode | b09423b | 2015-05-11 11:39:57 -0700 | [diff] [blame] | 369 | // Mapping from card to devices. |
| 370 | AlsaCardMap alsa_cards_; |
| 371 | STLValueDeleter<AlsaCardMap> alsa_cards_deleter_; |
| 372 | |
| 373 | // This is the current count of midi devices across all cards we know |
| 374 | // about. When this number matches card_client_count_ in AlsaSeqState, |
| 375 | // we are safe to generate MIDIConnectionEvents. Otherwise we need to |
| 376 | // wait for our information from ALSA and udev to get back in sync. |
| 377 | int alsa_card_midi_count_; |
| 378 | |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 379 | // ALSA event -> MIDI coder. |
agoode@chromium.org | 2522751 | 2014-06-08 05:12:05 +0000 | [diff] [blame] | 380 | snd_midi_event_t* decoder_; |
agoode@chromium.org | 2522751 | 2014-06-08 05:12:05 +0000 | [diff] [blame] | 381 | |
agoode | 7de413f | 2015-04-24 00:13:39 -0700 | [diff] [blame] | 382 | // udev, for querying hardware devices. |
| 383 | device::ScopedUdevPtr udev_; |
agoode | 975043d | 2015-05-11 00:46:17 -0700 | [diff] [blame] | 384 | device::ScopedUdevMonitorPtr udev_monitor_; |
agoode | 7de413f | 2015-04-24 00:13:39 -0700 | [diff] [blame] | 385 | |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 386 | base::Thread send_thread_; |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 387 | base::Thread event_thread_; |
| 388 | |
agoode | 99d6329 | 2015-04-13 08:39:25 -0700 | [diff] [blame] | 389 | bool event_thread_shutdown_; // guarded by shutdown_lock_ |
| 390 | base::Lock shutdown_lock_; // guards event_thread_shutdown_ |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 391 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 392 | DISALLOW_COPY_AND_ASSIGN(MidiManagerAlsa); |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 393 | }; |
| 394 | |
toyoshim | e147c5e | 2015-05-07 21:58:31 -0700 | [diff] [blame] | 395 | } // namespace midi |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 396 | } // namespace media |
| 397 | |
dnicoara@chromium.org | 9f2a6f0 | 2014-01-03 21:25:00 +0000 | [diff] [blame] | 398 | #endif // MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ |