OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ | 5 #ifndef MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ |
6 #define MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ | 6 #define MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ |
7 | 7 |
8 #include <alsa/asoundlib.h> | 8 #include <alsa/asoundlib.h> |
| 9 #include <map> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/containers/scoped_ptr_map.h" | |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "device/udev_linux/scoped_udev.h" | 19 #include "device/udev_linux/scoped_udev.h" |
20 #include "media/midi/midi_export.h" | 20 #include "media/midi/midi_export.h" |
21 #include "media/midi/midi_manager.h" | 21 #include "media/midi/midi_manager.h" |
22 | 22 |
(...skipping 12 matching lines...) Expand all Loading... |
35 uint32 port_index, | 35 uint32 port_index, |
36 const std::vector<uint8>& data, | 36 const std::vector<uint8>& data, |
37 double timestamp) override; | 37 double timestamp) override; |
38 | 38 |
39 private: | 39 private: |
40 friend class MidiManagerAlsaTest; | 40 friend class MidiManagerAlsaTest; |
41 FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ExtractManufacturer); | 41 FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ExtractManufacturer); |
42 FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ToMidiPortState); | 42 FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ToMidiPortState); |
43 | 43 |
44 class AlsaCard; | 44 class AlsaCard; |
45 typedef base::ScopedPtrMap<int, scoped_ptr<AlsaCard>> AlsaCardMap; | 45 using AlsaCardMap = std::map<int, scoped_ptr<AlsaCard>>; |
46 | 46 |
47 class MidiPort { | 47 class MidiPort { |
48 public: | 48 public: |
49 enum class Type { kInput, kOutput }; | 49 enum class Type { kInput, kOutput }; |
50 | 50 |
51 // The Id class is used to keep the multiple strings separate | 51 // The Id class is used to keep the multiple strings separate |
52 // but compare them all together for equality purposes. | 52 // but compare them all together for equality purposes. |
53 // The individual strings that make up the Id can theoretically contain | 53 // The individual strings that make up the Id can theoretically contain |
54 // arbitrary characters, so unfortunately there is no simple way to | 54 // arbitrary characters, so unfortunately there is no simple way to |
55 // concatenate them into a single string. | 55 // concatenate them into a single string. |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 private: | 262 private: |
263 const std::string name_; | 263 const std::string name_; |
264 const PortDirection direction_; | 264 const PortDirection direction_; |
265 const bool midi_; | 265 const bool midi_; |
266 | 266 |
267 DISALLOW_COPY_AND_ASSIGN(Port); | 267 DISALLOW_COPY_AND_ASSIGN(Port); |
268 }; | 268 }; |
269 | 269 |
270 class Client { | 270 class Client { |
271 public: | 271 public: |
272 typedef base::ScopedPtrMap<int, scoped_ptr<Port>> PortMap; | 272 using PortMap = std::map<int, scoped_ptr<Port>>; |
273 | 273 |
274 Client(const std::string& name, snd_seq_client_type_t type); | 274 Client(const std::string& name, snd_seq_client_type_t type); |
275 ~Client(); | 275 ~Client(); |
276 | 276 |
277 std::string name() const { return name_; } | 277 std::string name() const { return name_; } |
278 snd_seq_client_type_t type() const { return type_; } | 278 snd_seq_client_type_t type() const { return type_; } |
279 void AddPort(int addr, scoped_ptr<Port> port); | 279 void AddPort(int addr, scoped_ptr<Port> port); |
280 void RemovePort(int addr); | 280 void RemovePort(int addr); |
281 PortMap::const_iterator begin() const; | 281 PortMap::const_iterator begin() const; |
282 PortMap::const_iterator end() const; | 282 PortMap::const_iterator end() const; |
283 | 283 |
284 private: | 284 private: |
285 const std::string name_; | 285 const std::string name_; |
286 const snd_seq_client_type_t type_; | 286 const snd_seq_client_type_t type_; |
287 PortMap ports_; | 287 PortMap ports_; |
288 | 288 |
289 DISALLOW_COPY_AND_ASSIGN(Client); | 289 DISALLOW_COPY_AND_ASSIGN(Client); |
290 }; | 290 }; |
291 | 291 |
292 typedef base::ScopedPtrMap<int, scoped_ptr<Client>> ClientMap; | 292 std::map<int, scoped_ptr<Client>> clients_; |
293 | |
294 ClientMap clients_; | |
295 | 293 |
296 // This is the current number of clients we know about that have | 294 // This is the current number of clients we know about that have |
297 // cards. When this number matches alsa_card_midi_count_, we know | 295 // cards. When this number matches alsa_card_midi_count_, we know |
298 // we are in sync between ALSA and udev. Until then, we cannot generate | 296 // we are in sync between ALSA and udev. Until then, we cannot generate |
299 // MIDIConnectionEvents to web clients. | 297 // MIDIConnectionEvents to web clients. |
300 int card_client_count_ = 0; | 298 int card_client_count_ = 0; |
301 | 299 |
302 DISALLOW_COPY_AND_ASSIGN(AlsaSeqState); | 300 DISALLOW_COPY_AND_ASSIGN(AlsaSeqState); |
303 }; | 301 }; |
304 | 302 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 bool event_thread_shutdown_ = false; // guarded by shutdown_lock_ | 425 bool event_thread_shutdown_ = false; // guarded by shutdown_lock_ |
428 base::Lock shutdown_lock_; // guards event_thread_shutdown_ | 426 base::Lock shutdown_lock_; // guards event_thread_shutdown_ |
429 | 427 |
430 DISALLOW_COPY_AND_ASSIGN(MidiManagerAlsa); | 428 DISALLOW_COPY_AND_ASSIGN(MidiManagerAlsa); |
431 }; | 429 }; |
432 | 430 |
433 } // namespace midi | 431 } // namespace midi |
434 } // namespace media | 432 } // namespace media |
435 | 433 |
436 #endif // MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ | 434 #endif // MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ |
OLD | NEW |