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 <map> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
16 #include "media/midi/midi_manager.h" | 16 #include "media/midi/midi_manager.h" |
17 | 17 |
18 #if defined(USE_UDEV) | |
Ryan Sleevi
2015/03/04 19:46:56
Yes, this is fine because it's forced into the ent
| |
19 #include "device/udev_linux/scoped_udev.h" | |
20 #endif // defined(USE_UDEV) | |
21 | |
18 namespace media { | 22 namespace media { |
19 | 23 |
20 class MidiManagerAlsa : public MidiManager { | 24 namespace internal { |
25 | |
26 // Decodes just \xXX in strings. | |
27 MEDIA_EXPORT_PRIVATE std::string UnescapeUdev(const std::string& s); | |
Takashi Toyoshima
2015/03/04 09:33:37
Do you have any reason to place these two function
wolenetz
2015/03/04 19:28:58
+1. I'm not fully conversant with the pros/cons he
Adam Goode
2015/03/04 19:59:18
Done.
| |
28 | |
29 // Extracts the manufacturer using heuristics and a variety of sources. | |
30 MEDIA_EXPORT_PRIVATE std::string ExtractManufacturer( | |
31 const std::string& udev_id_vendor_enc, | |
32 const std::string& udev_id_vendor_id, | |
33 const std::string& udev_id_vendor_from_database, | |
34 const std::string& alsa_name, | |
35 const std::string& alsa_longname); | |
36 | |
37 } // namespace internal | |
38 | |
39 class MEDIA_EXPORT MidiManagerAlsa : public MidiManager { | |
21 public: | 40 public: |
22 MidiManagerAlsa(); | 41 MidiManagerAlsa(); |
23 ~MidiManagerAlsa() override; | 42 ~MidiManagerAlsa() override; |
24 | 43 |
25 // MidiManager implementation. | 44 // MidiManager implementation. |
26 void StartInitialization() override; | 45 void StartInitialization() override; |
27 void DispatchSendMidiData(MidiManagerClient* client, | 46 void DispatchSendMidiData(MidiManagerClient* client, |
28 uint32 port_index, | 47 uint32 port_index, |
29 const std::vector<uint8>& data, | 48 const std::vector<uint8>& data, |
30 double timestamp) override; | 49 double timestamp) override; |
(...skipping 17 matching lines...) Expand all Loading... | |
48 | 67 |
49 // Mapping from Alsa client:port to our index. | 68 // Mapping from Alsa client:port to our index. |
50 typedef std::map<int, uint32> SourceMap; | 69 typedef std::map<int, uint32> SourceMap; |
51 SourceMap source_map_; | 70 SourceMap source_map_; |
52 | 71 |
53 // Alsa event <-> MIDI coders. | 72 // Alsa event <-> MIDI coders. |
54 snd_midi_event_t* decoder_; | 73 snd_midi_event_t* decoder_; |
55 typedef std::vector<snd_midi_event_t*> EncoderList; | 74 typedef std::vector<snd_midi_event_t*> EncoderList; |
56 EncoderList encoders_; | 75 EncoderList encoders_; |
57 | 76 |
77 // udev, for querying hardware devices. | |
78 #if defined(USE_UDEV) | |
79 device::ScopedUdevPtr udev_; | |
80 #endif // defined(USE_UDEV) | |
81 | |
58 base::Thread send_thread_; | 82 base::Thread send_thread_; |
59 base::Thread event_thread_; | 83 base::Thread event_thread_; |
60 | 84 |
61 bool event_thread_shutdown_; // guarded by shutdown_lock_ | 85 bool event_thread_shutdown_; // guarded by shutdown_lock_ |
62 base::Lock shutdown_lock_; // guards event_thread_shutdown_ | 86 base::Lock shutdown_lock_; // guards event_thread_shutdown_ |
63 | 87 |
64 DISALLOW_COPY_AND_ASSIGN(MidiManagerAlsa); | 88 DISALLOW_COPY_AND_ASSIGN(MidiManagerAlsa); |
65 }; | 89 }; |
66 | 90 |
67 } // namespace media | 91 } // namespace media |
68 | 92 |
69 #endif // MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ | 93 #endif // MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ |
OLD | NEW |