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

Side by Side Diff: media/midi/midi_manager_alsa.h

Issue 1007613006: Rename CardInfo to MidiDevice and factor out some device probing logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Hopefully final refactor before adding hotplug Created 5 years, 9 months 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
« no previous file with comments | « no previous file | media/midi/midi_manager_alsa.cc » ('j') | media/midi/midi_manager_alsa.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
(...skipping 18 matching lines...) Expand all
29 29
30 // MidiManager implementation. 30 // MidiManager implementation.
31 void StartInitialization() override; 31 void StartInitialization() override;
32 void DispatchSendMidiData(MidiManagerClient* client, 32 void DispatchSendMidiData(MidiManagerClient* client,
33 uint32 port_index, 33 uint32 port_index,
34 const std::vector<uint8>& data, 34 const std::vector<uint8>& data,
35 double timestamp) override; 35 double timestamp) override;
36 36
37 private: 37 private:
38 FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ExtractManufacturer); 38 FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ExtractManufacturer);
39 FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, UdevEscape);
40 39
41 class CardInfo { 40 class MidiDevice {
42 public: 41 public:
43 CardInfo(const MidiManagerAlsa* outer, 42 MidiDevice(const MidiManagerAlsa* outer,
44 const std::string& alsa_name, const std::string& alsa_longname, 43 const std::string& alsa_name,
45 const std::string& alsa_driver, int card_index); 44 const std::string& alsa_longname,
46 ~CardInfo(); 45 const std::string& alsa_driver,
46 int card_index);
47 ~MidiDevice();
Takashi Toyoshima 2015/03/16 07:22:08 Can you just remove the destructor? Since it does
Adam Goode 2015/03/16 20:30:54 When I do this I get: In file included from ../..
47 48
48 const std::string alsa_name() const; 49 const std::string alsa_name() const;
49 const std::string manufacturer() const; 50 const std::string manufacturer() const;
50 const std::string alsa_driver() const; 51 const std::string alsa_driver() const;
51 const std::string udev_id_path() const; 52 const std::string udev_id_path() const;
52 const std::string udev_id_id() const; 53 const std::string udev_id_id() const;
53 54
54 private: 55 private:
55 FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ExtractManufacturer); 56 FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ExtractManufacturer);
56 FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, UdevEscape);
57 57
58 // Extracts the manufacturer using heuristics and a variety of sources. 58 // Extracts the manufacturer using heuristics and a variety of sources.
59 static std::string ExtractManufacturerString( 59 static std::string ExtractManufacturerString(
60 const std::string& udev_id_vendor, 60 const std::string& udev_id_vendor,
61 const std::string& udev_id_vendor_id, 61 const std::string& udev_id_vendor_id,
62 const std::string& udev_id_vendor_from_database, 62 const std::string& udev_id_vendor_from_database,
63 const std::string& alsa_name, 63 const std::string& alsa_name,
64 const std::string& alsa_longname); 64 const std::string& alsa_longname);
65 65
66 std::string alsa_name_; 66 std::string alsa_name_;
67 std::string manufacturer_; 67 std::string manufacturer_;
68 std::string alsa_driver_; 68 std::string alsa_driver_;
69 std::string udev_id_path_; 69 std::string udev_id_path_;
70 std::string udev_id_id_; 70 std::string udev_id_id_;
Takashi Toyoshima 2015/03/16 07:22:08 It seems we forgot to add DISALLOW_COPY_AND_ASSIGN
Adam Goode 2015/03/16 20:30:54 done
71 }; 71 };
72 72
73 // Returns an ordered vector of all the rawmidi devices on the system.
74 ScopedVector<MidiDevice> AllMidiDevices();
75
76 // Enumerate all the ports for initial setup.
77 void EnumeratePorts();
78
73 // An internal callback that runs on MidiSendThread. 79 // An internal callback that runs on MidiSendThread.
74 void SendMidiData(uint32 port_index, 80 void SendMidiData(uint32 port_index,
75 const std::vector<uint8>& data); 81 const std::vector<uint8>& data);
76 82
77 void EventReset(); 83 void ScheduleEventLoop();
78 void EventLoop(); 84 void EventLoop();
85 void ProcessSingleEvent(snd_seq_event_t* event, double timestamp);
79 86
80 // Alsa seq handles. 87 // ALSA seq handles.
81 snd_seq_t* in_client_; 88 snd_seq_t* in_client_;
82 snd_seq_t* out_client_; 89 snd_seq_t* out_client_;
83 int out_client_id_; 90 int out_client_id_;
84 91
85 // One input port, many output ports. 92 // One input port, many output ports.
86 int in_port_; 93 int in_port_;
87 std::vector<int> out_ports_; 94 std::vector<int> out_ports_;
88 95
89 // Mapping from Alsa client:port to our index. 96 // Mapping from ALSA client:port to our index.
90 typedef std::map<int, uint32> SourceMap; 97 typedef std::map<int, uint32> SourceMap;
91 SourceMap source_map_; 98 SourceMap source_map_;
92 99
93 // Alsa event <-> MIDI coders. 100 // ALSA event <-> MIDI coders.
94 snd_midi_event_t* decoder_; 101 snd_midi_event_t* decoder_;
95 typedef std::vector<snd_midi_event_t*> EncoderList; 102 typedef std::vector<snd_midi_event_t*> EncoderList;
96 EncoderList encoders_; 103 EncoderList encoders_;
97 104
98 // udev, for querying hardware devices. 105 // udev, for querying hardware devices.
99 #if defined(USE_UDEV) 106 #if defined(USE_UDEV)
100 device::ScopedUdevPtr udev_; 107 device::ScopedUdevPtr udev_;
101 #endif // defined(USE_UDEV) 108 #endif // defined(USE_UDEV)
102 109
103 base::Thread send_thread_; 110 base::Thread send_thread_;
104 base::Thread event_thread_; 111 base::Thread event_thread_;
105 112
106 bool event_thread_shutdown_; // guarded by shutdown_lock_ 113 bool event_thread_shutdown_; // guarded by shutdown_lock_
107 base::Lock shutdown_lock_; // guards event_thread_shutdown_ 114 base::Lock shutdown_lock_; // guards event_thread_shutdown_
108 115
109 DISALLOW_COPY_AND_ASSIGN(MidiManagerAlsa); 116 DISALLOW_COPY_AND_ASSIGN(MidiManagerAlsa);
110 }; 117 };
111 118
112 } // namespace media 119 } // namespace media
113 120
114 #endif // MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ 121 #endif // MEDIA_MIDI_MIDI_MANAGER_ALSA_H_
OLDNEW
« no previous file with comments | « no previous file | media/midi/midi_manager_alsa.cc » ('j') | media/midi/midi_manager_alsa.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698