blob: 271a6b8661b4aa288a99bebdbf679229047c3cb3 [file] [log] [blame]
toyoshim@chromium.orga97eebf2014-01-03 07:52:39 +00001// 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.org9f2a6f02014-01-03 21:25:00 +00005#ifndef MEDIA_MIDI_MIDI_MANAGER_ALSA_H_
6#define MEDIA_MIDI_MIDI_MANAGER_ALSA_H_
toyoshim@chromium.orga97eebf2014-01-03 07:52:39 +00007
agoode@chromium.org25227512014-06-08 05:12:05 +00008#include <alsa/asoundlib.h>
avi793390d2015-12-22 22:22:36 -08009#include <stdint.h>
danakj75afea02016-04-25 20:36:04 -070010
limasdfe59d0392015-11-19 20:28:57 -080011#include <map>
danakj75afea02016-04-25 20:36:04 -070012#include <memory>
Takuto Ikutafd795cb2019-01-05 00:32:48 +000013#include <unordered_map>
dchengc2aeece2015-12-27 00:54:00 -080014#include <utility>
toyoshim@chromium.orga97eebf2014-01-03 07:52:39 +000015#include <vector>
16
agoode55a8b522015-03-08 12:40:17 -070017#include "base/gtest_prod_util.h"
avieea95e82015-12-18 20:27:08 -080018#include "base/macros.h"
agoode@chromium.org25227512014-06-08 05:12:05 +000019#include "base/synchronization/lock.h"
Takashi Toyoshimae8240ab2018-10-03 09:30:11 +000020#include "base/thread_annotations.h"
toyoshim@chromium.orga97eebf2014-01-03 07:52:39 +000021#include "base/threading/thread.h"
agoodef212b2a2015-03-19 12:53:23 -070022#include "base/values.h"
agoode7de413f2015-04-24 00:13:39 -070023#include "device/udev_linux/scoped_udev.h"
brettw49ff0172015-05-05 12:43:04 -070024#include "media/midi/midi_export.h"
toyoshim@chromium.orga97eebf2014-01-03 07:52:39 +000025#include "media/midi/midi_manager.h"
26
toyoshime147c5e2015-05-07 21:58:31 -070027namespace midi {
toyoshim@chromium.orga97eebf2014-01-03 07:52:39 +000028
brettw49ff0172015-05-05 12:43:04 -070029class MIDI_EXPORT MidiManagerAlsa final : public MidiManager {
toyoshim@chromium.orga97eebf2014-01-03 07:52:39 +000030 public:
toyoshimf4d61522017-02-10 02:03:32 -080031 explicit MidiManagerAlsa(MidiService* service);
Peter Boström53634032021-09-22 20:24:34 +000032
33 MidiManagerAlsa(const MidiManagerAlsa&) = delete;
34 MidiManagerAlsa& operator=(const MidiManagerAlsa&) = delete;
35
dcheng9e8524d2014-10-27 15:18:50 -070036 ~MidiManagerAlsa() override;
toyoshim@chromium.orga97eebf2014-01-03 07:52:39 +000037
toyoshim@chromium.orgc82e66e2014-02-04 07:05:47 +000038 // MidiManager implementation.
dcheng9e8524d2014-10-27 15:18:50 -070039 void StartInitialization() override;
40 void DispatchSendMidiData(MidiManagerClient* client,
Avi Drissman3528fd02015-12-18 20:11:31 -050041 uint32_t port_index,
42 const std::vector<uint8_t>& data,
tzik925e2c62018-02-02 07:39:45 +000043 base::TimeTicks timestamp) override;
toyoshim@chromium.orga97eebf2014-01-03 07:52:39 +000044
45 private:
agoode99d63292015-04-13 08:39:25 -070046 friend class MidiManagerAlsaTest;
agoode55a8b522015-03-08 12:40:17 -070047 FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ExtractManufacturer);
agoode99d63292015-04-13 08:39:25 -070048 FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ToMidiPortState);
agoode55a8b522015-03-08 12:40:17 -070049
agoodeb09423b2015-05-11 11:39:57 -070050 class AlsaCard;
danakj75afea02016-04-25 20:36:04 -070051 using AlsaCardMap = std::map<int, std::unique_ptr<AlsaCard>>;
agoodeb09423b2015-05-11 11:39:57 -070052
agoode99d63292015-04-13 08:39:25 -070053 class MidiPort {
agoodef212b2a2015-03-19 12:53:23 -070054 public:
55 enum class Type { kInput, kOutput };
56
agooded87fc0f2015-05-21 08:29:31 -070057 // The Id class is used to keep the multiple strings separate
58 // but compare them all together for equality purposes.
59 // The individual strings that make up the Id can theoretically contain
60 // arbitrary characters, so unfortunately there is no simple way to
61 // concatenate them into a single string.
62 class Id final {
63 public:
64 Id();
65 Id(const std::string& bus,
66 const std::string& vendor_id,
67 const std::string& model_id,
68 const std::string& usb_interface_num,
69 const std::string& serial);
70 Id(const Id&);
71 ~Id();
72 bool operator==(const Id&) const;
73 bool empty() const;
74
75 std::string bus() const { return bus_; }
76 std::string vendor_id() const { return vendor_id_; }
77 std::string model_id() const { return model_id_; }
78 std::string usb_interface_num() const { return usb_interface_num_; }
79 std::string serial() const { return serial_; }
80
81 private:
82 std::string bus_;
83 std::string vendor_id_;
84 std::string model_id_;
85 std::string usb_interface_num_;
86 std::string serial_;
87 };
88
agoode99d63292015-04-13 08:39:25 -070089 MidiPort(const std::string& path,
agooded87fc0f2015-05-21 08:29:31 -070090 const Id& id,
agoode99d63292015-04-13 08:39:25 -070091 int client_id,
92 int port_id,
93 int midi_device,
94 const std::string& client_name,
95 const std::string& port_name,
96 const std::string& manufacturer,
97 const std::string& version,
98 Type type);
99 ~MidiPort();
agoodef212b2a2015-03-19 12:53:23 -0700100
101 // Gets a Value representation of this object, suitable for serialization.
danakj75afea02016-04-25 20:36:04 -0700102 std::unique_ptr<base::Value> Value() const;
agoodef212b2a2015-03-19 12:53:23 -0700103
104 // Gets a string version of Value in JSON format.
105 std::string JSONValue() const;
106
107 // Gets an opaque identifier for this object, suitable for using as the id
108 // field in MidiPort.id on the web. Note that this string does not store
109 // the full state.
110 std::string OpaqueKey() const;
111
agoode99d63292015-04-13 08:39:25 -0700112 // Checks for equality for connected ports.
113 bool MatchConnected(const MidiPort& query) const;
114 // Checks for equality for kernel cards with id, pass 1.
115 bool MatchCardPass1(const MidiPort& query) const;
116 // Checks for equality for kernel cards with id, pass 2.
117 bool MatchCardPass2(const MidiPort& query) const;
118 // Checks for equality for non-card clients, pass 1.
119 bool MatchNoCardPass1(const MidiPort& query) const;
120 // Checks for equality for non-card clients, pass 2.
121 bool MatchNoCardPass2(const MidiPort& query) const;
agoodef212b2a2015-03-19 12:53:23 -0700122
agoode99d63292015-04-13 08:39:25 -0700123 // accessors
124 std::string path() const { return path_; }
agooded87fc0f2015-05-21 08:29:31 -0700125 Id id() const { return id_; }
agoode99d63292015-04-13 08:39:25 -0700126 std::string client_name() const { return client_name_; }
127 std::string port_name() const { return port_name_; }
128 std::string manufacturer() const { return manufacturer_; }
129 std::string version() const { return version_; }
130 int client_id() const { return client_id_; }
131 int port_id() const { return port_id_; }
132 int midi_device() const { return midi_device_; }
133 Type type() const { return type_; }
Avi Drissman3528fd02015-12-18 20:11:31 -0500134 uint32_t web_port_index() const { return web_port_index_; }
agoode99d63292015-04-13 08:39:25 -0700135 bool connected() const { return connected_; }
136
137 // mutators
Avi Drissman3528fd02015-12-18 20:11:31 -0500138 void set_web_port_index(uint32_t web_port_index) {
agoode99d63292015-04-13 08:39:25 -0700139 web_port_index_ = web_port_index;
140 }
141 void set_connected(bool connected) { connected_ = connected; }
142 void Update(const std::string& path,
143 int client_id,
144 int port_id,
145 const std::string& client_name,
146 const std::string& port_name,
147 const std::string& manufacturer,
148 const std::string& version) {
149 path_ = path;
150 client_id_ = client_id;
151 port_id_ = port_id;
152 client_name_ = client_name;
153 port_name_ = port_name;
154 manufacturer_ = manufacturer;
155 version_ = version;
156 }
157
158 private:
159 // Immutable properties.
agooded87fc0f2015-05-21 08:29:31 -0700160 const Id id_;
agoode99d63292015-04-13 08:39:25 -0700161 const int midi_device_;
162
agoodef212b2a2015-03-19 12:53:23 -0700163 const Type type_;
164
agoode99d63292015-04-13 08:39:25 -0700165 // Mutable properties. These will get updated as ports move around or
166 // drivers change.
167 std::string path_;
168 int client_id_;
169 int port_id_;
170 std::string client_name_;
171 std::string port_name_;
172 std::string manufacturer_;
173 std::string version_;
174
175 // Index for MidiManager.
Avi Drissman3528fd02015-12-18 20:11:31 -0500176 uint32_t web_port_index_ = 0;
agoode99d63292015-04-13 08:39:25 -0700177
178 // Port is present in the ALSA system.
agoode5a1aa112015-06-21 20:51:00 -0700179 bool connected_ = true;
agoode99d63292015-04-13 08:39:25 -0700180
181 DISALLOW_COPY_AND_ASSIGN(MidiPort);
agoode55a8b522015-03-08 12:40:17 -0700182 };
183
agoode99d63292015-04-13 08:39:25 -0700184 class MidiPortStateBase {
185 public:
danakj75afea02016-04-25 20:36:04 -0700186 typedef std::vector<std::unique_ptr<MidiPort>>::iterator iterator;
agoodebd4be9b2015-03-16 19:17:25 -0700187
Peter Boström53634032021-09-22 20:24:34 +0000188 MidiPortStateBase(const MidiPortStateBase&) = delete;
189 MidiPortStateBase& operator=(const MidiPortStateBase&) = delete;
190
agoode99d63292015-04-13 08:39:25 -0700191 virtual ~MidiPortStateBase();
192
193 // Given a port, finds a port in the internal store.
194 iterator Find(const MidiPort& port);
195
196 // Given a port, finds a connected port, using exact matching.
197 iterator FindConnected(const MidiPort& port);
198
199 // Given a port, finds a disconnected port, using heuristic matching.
200 iterator FindDisconnected(const MidiPort& port);
201
202 iterator begin() { return ports_.begin(); }
203 iterator end() { return ports_.end(); }
204
205 protected:
206 MidiPortStateBase();
agoode5ebc4932015-12-01 08:25:12 -0800207 iterator erase(iterator position) { return ports_.erase(position); }
danakj75afea02016-04-25 20:36:04 -0700208 void push_back(std::unique_ptr<MidiPort> port) {
dchengc2aeece2015-12-27 00:54:00 -0800209 ports_.push_back(std::move(port));
210 }
agoode99d63292015-04-13 08:39:25 -0700211
212 private:
danakj75afea02016-04-25 20:36:04 -0700213 std::vector<std::unique_ptr<MidiPort>> ports_;
agoode99d63292015-04-13 08:39:25 -0700214 };
215
216 class TemporaryMidiPortState final : public MidiPortStateBase {
217 public:
agoode5ebc4932015-12-01 08:25:12 -0800218 iterator erase(iterator position) {
219 return MidiPortStateBase::erase(position);
Nico Webera0faaf72019-02-07 19:07:54 +0000220 }
danakj75afea02016-04-25 20:36:04 -0700221 void push_back(std::unique_ptr<MidiPort> port) {
dchengc2aeece2015-12-27 00:54:00 -0800222 MidiPortStateBase::push_back(std::move(port));
agoode5ebc4932015-12-01 08:25:12 -0800223 }
agoode99d63292015-04-13 08:39:25 -0700224 };
225
226 class MidiPortState final : public MidiPortStateBase {
227 public:
228 MidiPortState();
229
agoode5ebc4932015-12-01 08:25:12 -0800230 // Inserts a port at the end. Returns web_port_index.
danakj75afea02016-04-25 20:36:04 -0700231 uint32_t push_back(std::unique_ptr<MidiPort> port);
agoode99d63292015-04-13 08:39:25 -0700232
233 private:
Avi Drissman3528fd02015-12-18 20:11:31 -0500234 uint32_t num_input_ports_ = 0;
235 uint32_t num_output_ports_ = 0;
agoode99d63292015-04-13 08:39:25 -0700236 };
237
238 class AlsaSeqState {
239 public:
240 enum class PortDirection { kInput, kOutput, kDuplex };
241
242 AlsaSeqState();
Peter Boström53634032021-09-22 20:24:34 +0000243
244 AlsaSeqState(const AlsaSeqState&) = delete;
245 AlsaSeqState& operator=(const AlsaSeqState&) = delete;
246
agoode99d63292015-04-13 08:39:25 -0700247 ~AlsaSeqState();
248
249 void ClientStart(int client_id,
250 const std::string& client_name,
251 snd_seq_client_type_t type);
252 bool ClientStarted(int client_id);
253 void ClientExit(int client_id);
254 void PortStart(int client_id,
255 int port_id,
256 const std::string& port_name,
257 PortDirection direction,
258 bool midi);
259 void PortExit(int client_id, int port_id);
260 snd_seq_client_type_t ClientType(int client_id) const;
danakj75afea02016-04-25 20:36:04 -0700261 std::unique_ptr<TemporaryMidiPortState> ToMidiPortState(
agoodeb09423b2015-05-11 11:39:57 -0700262 const AlsaCardMap& alsa_cards);
263
264 int card_client_count() { return card_client_count_; }
agoode99d63292015-04-13 08:39:25 -0700265
266 private:
267 class Port {
268 public:
269 Port(const std::string& name, PortDirection direction, bool midi);
Peter Boström53634032021-09-22 20:24:34 +0000270
271 Port(const Port&) = delete;
272 Port& operator=(const Port&) = delete;
273
agoode99d63292015-04-13 08:39:25 -0700274 ~Port();
275
agoodeb0582872015-05-20 05:22:24 -0700276 std::string name() const { return name_; }
277 PortDirection direction() const { return direction_; }
agoode99d63292015-04-13 08:39:25 -0700278 // True if this port is a MIDI port, instead of another kind of ALSA port.
agoodeb0582872015-05-20 05:22:24 -0700279 bool midi() const { return midi_; }
agoode99d63292015-04-13 08:39:25 -0700280
281 private:
282 const std::string name_;
283 const PortDirection direction_;
284 const bool midi_;
agoode99d63292015-04-13 08:39:25 -0700285 };
286
287 class Client {
288 public:
danakj75afea02016-04-25 20:36:04 -0700289 using PortMap = std::map<int, std::unique_ptr<Port>>;
agoode99d63292015-04-13 08:39:25 -0700290
291 Client(const std::string& name, snd_seq_client_type_t type);
Peter Boström53634032021-09-22 20:24:34 +0000292
293 Client(const Client&) = delete;
294 Client& operator=(const Client&) = delete;
295
agoode99d63292015-04-13 08:39:25 -0700296 ~Client();
297
agoodeb0582872015-05-20 05:22:24 -0700298 std::string name() const { return name_; }
299 snd_seq_client_type_t type() const { return type_; }
danakj75afea02016-04-25 20:36:04 -0700300 void AddPort(int addr, std::unique_ptr<Port> port);
agoode99d63292015-04-13 08:39:25 -0700301 void RemovePort(int addr);
302 PortMap::const_iterator begin() const;
303 PortMap::const_iterator end() const;
304
305 private:
306 const std::string name_;
307 const snd_seq_client_type_t type_;
308 PortMap ports_;
agoode99d63292015-04-13 08:39:25 -0700309 };
310
danakj75afea02016-04-25 20:36:04 -0700311 std::map<int, std::unique_ptr<Client>> clients_;
agoode99d63292015-04-13 08:39:25 -0700312
agoodeb09423b2015-05-11 11:39:57 -0700313 // This is the current number of clients we know about that have
314 // cards. When this number matches alsa_card_midi_count_, we know
315 // we are in sync between ALSA and udev. Until then, we cannot generate
316 // MIDIConnectionEvents to web clients.
agoodedf1b9ff2015-06-25 18:14:50 -0700317 int card_client_count_ = 0;
agoode99d63292015-04-13 08:39:25 -0700318 };
319
agoodeb09423b2015-05-11 11:39:57 -0700320 class AlsaCard {
321 public:
322 AlsaCard(udev_device* dev,
agooded87fc0f2015-05-21 08:29:31 -0700323 const std::string& name,
324 const std::string& longname,
325 const std::string& driver,
agoodeb09423b2015-05-11 11:39:57 -0700326 int midi_device_count);
Peter Boström53634032021-09-22 20:24:34 +0000327
328 AlsaCard(const AlsaCard&) = delete;
329 AlsaCard& operator=(const AlsaCard&) = delete;
330
agoodeb09423b2015-05-11 11:39:57 -0700331 ~AlsaCard();
agooded87fc0f2015-05-21 08:29:31 -0700332 std::string name() const { return name_; }
333 std::string longname() const { return longname_; }
334 std::string driver() const { return driver_; }
335 std::string path() const { return path_; }
336 std::string bus() const { return bus_; }
337 std::string vendor_id() const { return vendor_id_; }
338 std::string model_id() const { return model_id_; }
339 std::string usb_interface_num() const { return usb_interface_num_; }
340 std::string serial() const { return serial_; }
agoodeb09423b2015-05-11 11:39:57 -0700341 int midi_device_count() const { return midi_device_count_; }
agooded87fc0f2015-05-21 08:29:31 -0700342 std::string manufacturer() const { return manufacturer_; }
agoodeb09423b2015-05-11 11:39:57 -0700343
344 private:
345 FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ExtractManufacturer);
346
347 // Extracts the manufacturer using heuristics and a variety of sources.
348 static std::string ExtractManufacturerString(
349 const std::string& udev_id_vendor,
350 const std::string& udev_id_vendor_id,
351 const std::string& udev_id_vendor_from_database,
agooded87fc0f2015-05-21 08:29:31 -0700352 const std::string& name,
353 const std::string& longname);
agoodeb09423b2015-05-11 11:39:57 -0700354
agooded87fc0f2015-05-21 08:29:31 -0700355 const std::string name_;
356 const std::string longname_;
357 const std::string driver_;
358 const std::string path_;
359 const std::string bus_;
360 const std::string vendor_id_;
361 const std::string model_id_;
362 const std::string usb_interface_num_;
363 const std::string serial_;
364 const int midi_device_count_;
365 const std::string manufacturer_;
agoodeb09423b2015-05-11 11:39:57 -0700366 };
367
agoode5a1aa112015-06-21 20:51:00 -0700368 struct SndSeqDeleter {
369 void operator()(snd_seq_t* seq) const { snd_seq_close(seq); }
370 };
371
372 struct SndMidiEventDeleter {
373 void operator()(snd_midi_event_t* coder) const {
374 snd_midi_event_free(coder);
Nico Webera0faaf72019-02-07 19:07:54 +0000375 }
agoode5a1aa112015-06-21 20:51:00 -0700376 };
377
Takuto Ikutafd795cb2019-01-05 00:32:48 +0000378 using SourceMap = std::unordered_map<int, uint32_t>;
379 using OutPortMap = std::unordered_map<uint32_t, int>;
danakj75afea02016-04-25 20:36:04 -0700380 using ScopedSndSeqPtr = std::unique_ptr<snd_seq_t, SndSeqDeleter>;
agoodeb2ead822016-03-11 12:14:35 -0800381 using ScopedSndMidiEventPtr =
danakj75afea02016-04-25 20:36:04 -0700382 std::unique_ptr<snd_midi_event_t, SndMidiEventDeleter>;
agoode99d63292015-04-13 08:39:25 -0700383
agoode@chromium.org25227512014-06-08 05:12:05 +0000384 // An internal callback that runs on MidiSendThread.
toyoshimefcee5e2017-06-14 07:14:39 -0700385 void SendMidiData(MidiManagerClient* client,
toyoshimf4d61522017-02-10 02:03:32 -0800386 uint32_t port_index,
387 const std::vector<uint8_t>& data);
agoode@chromium.org25227512014-06-08 05:12:05 +0000388
toyoshimefcee5e2017-06-14 07:14:39 -0700389 void EventLoop();
tzik925e2c62018-02-02 07:39:45 +0000390 void ProcessSingleEvent(snd_seq_event_t* event, base::TimeTicks timestamp);
agoode99d63292015-04-13 08:39:25 -0700391 void ProcessClientStartEvent(int client_id);
392 void ProcessPortStartEvent(const snd_seq_addr_t& addr);
393 void ProcessClientExitEvent(const snd_seq_addr_t& addr);
394 void ProcessPortExitEvent(const snd_seq_addr_t& addr);
agoode975043d2015-05-11 00:46:17 -0700395 void ProcessUdevEvent(udev_device* dev);
agoodeb09423b2015-05-11 11:39:57 -0700396 void AddCard(udev_device* dev);
397 void RemoveCard(int number);
agoode99d63292015-04-13 08:39:25 -0700398
399 // Updates port_state_ and Web MIDI state from alsa_seq_state_.
400 void UpdatePortStateAndGenerateEvents();
401
402 // Enumerates ports. Call once after subscribing to the announce port.
403 void EnumerateAlsaPorts();
agoode975043d2015-05-11 00:46:17 -0700404 // Enumerates udev cards. Call once after initializing the udev monitor.
405 bool EnumerateUdevCards();
agoode99d63292015-04-13 08:39:25 -0700406 // Returns true if successful.
Avi Drissman3528fd02015-12-18 20:11:31 -0500407 bool CreateAlsaOutputPort(uint32_t port_index, int client_id, int port_id);
408 void DeleteAlsaOutputPort(uint32_t port_index);
agoode99d63292015-04-13 08:39:25 -0700409 // Returns true if successful.
Avi Drissman3528fd02015-12-18 20:11:31 -0500410 bool Subscribe(uint32_t port_index, int client_id, int port_id);
agoode99d63292015-04-13 08:39:25 -0700411
Takashi Toyoshima0ae49702017-09-01 04:59:51 +0000412 // Allocates new snd_midi_event_t instance and wraps it to return as
413 // ScopedSndMidiEventPtr.
414 ScopedSndMidiEventPtr CreateScopedSndMidiEventPtr(size_t size);
415
agoodeb2ead822016-03-11 12:14:35 -0800416 // Members initialized in the constructor are below.
417 // Our copies of the internal state of the ports of seq and udev.
agoode99d63292015-04-13 08:39:25 -0700418 AlsaSeqState alsa_seq_state_;
419 MidiPortState port_state_;
toyoshim@chromium.org4a8657c2014-02-06 11:23:09 +0000420
agoode@chromium.org25227512014-06-08 05:12:05 +0000421 // One input port, many output ports.
Takashi Toyoshimae8240ab2018-10-03 09:30:11 +0000422 base::Lock out_ports_lock_;
423 OutPortMap out_ports_ GUARDED_BY(out_ports_lock_);
agoode@chromium.org25227512014-06-08 05:12:05 +0000424
agoodebd4be9b2015-03-16 19:17:25 -0700425 // Mapping from ALSA client:port to our index.
agoode@chromium.org25227512014-06-08 05:12:05 +0000426 SourceMap source_map_;
427
agoodeb09423b2015-05-11 11:39:57 -0700428 // Mapping from card to devices.
429 AlsaCardMap alsa_cards_;
agoodeb09423b2015-05-11 11:39:57 -0700430
431 // This is the current count of midi devices across all cards we know
432 // about. When this number matches card_client_count_ in AlsaSeqState,
433 // we are safe to generate MIDIConnectionEvents. Otherwise we need to
434 // wait for our information from ALSA and udev to get back in sync.
agoode5a1aa112015-06-21 20:51:00 -0700435 int alsa_card_midi_count_ = 0;
agoodeb09423b2015-05-11 11:39:57 -0700436
agoodeb2ead822016-03-11 12:14:35 -0800437 // ALSA seq handles and ids.
438 ScopedSndSeqPtr in_client_;
439 int in_client_id_;
Takashi Toyoshimae8240ab2018-10-03 09:30:11 +0000440 ScopedSndSeqPtr out_client_ GUARDED_BY(out_client_lock_);
441 base::Lock out_client_lock_;
agoodeb2ead822016-03-11 12:14:35 -0800442 int out_client_id_;
443 int in_port_id_;
444
agoode99d63292015-04-13 08:39:25 -0700445 // ALSA event -> MIDI coder.
agoodeb2ead822016-03-11 12:14:35 -0800446 ScopedSndMidiEventPtr decoder_;
agoode@chromium.org25227512014-06-08 05:12:05 +0000447
agoode7de413f2015-04-24 00:13:39 -0700448 // udev, for querying hardware devices.
449 device::ScopedUdevPtr udev_;
agoode975043d2015-05-11 00:46:17 -0700450 device::ScopedUdevMonitorPtr udev_monitor_;
toyoshim@chromium.orga97eebf2014-01-03 07:52:39 +0000451};
452
toyoshime147c5e2015-05-07 21:58:31 -0700453} // namespace midi
toyoshim@chromium.orga97eebf2014-01-03 07:52:39 +0000454
dnicoara@chromium.org9f2a6f02014-01-03 21:25:00 +0000455#endif // MEDIA_MIDI_MIDI_MANAGER_ALSA_H_