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> |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 // Given a port, finds a disconnected port, using heuristic matching. | 158 // Given a port, finds a disconnected port, using heuristic matching. |
159 iterator FindDisconnected(const MidiPort& port); | 159 iterator FindDisconnected(const MidiPort& port); |
160 | 160 |
161 iterator begin() { return ports_.begin(); } | 161 iterator begin() { return ports_.begin(); } |
162 iterator end() { return ports_.end(); } | 162 iterator end() { return ports_.end(); } |
163 | 163 |
164 protected: | 164 protected: |
165 MidiPortStateBase(); | 165 MidiPortStateBase(); |
166 | 166 |
167 ScopedVector<MidiPort>* ports(); | 167 ScopedVector<MidiPort>* ports() { return &ports_; } |
168 | 168 |
169 private: | 169 private: |
170 ScopedVector<MidiPort> ports_; | 170 ScopedVector<MidiPort> ports_; |
171 | 171 |
172 DISALLOW_COPY_AND_ASSIGN(MidiPortStateBase); | 172 DISALLOW_COPY_AND_ASSIGN(MidiPortStateBase); |
173 }; | 173 }; |
174 | 174 |
175 class TemporaryMidiPortState final : public MidiPortStateBase { | 175 class TemporaryMidiPortState final : public MidiPortStateBase { |
176 public: | 176 public: |
177 // Removes a port from the list without deleting it. | 177 // Removes a port from the list without deleting it. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 const AlsaCardMap& alsa_cards); | 217 const AlsaCardMap& alsa_cards); |
218 | 218 |
219 int card_client_count() { return card_client_count_; } | 219 int card_client_count() { return card_client_count_; } |
220 | 220 |
221 private: | 221 private: |
222 class Port { | 222 class Port { |
223 public: | 223 public: |
224 Port(const std::string& name, PortDirection direction, bool midi); | 224 Port(const std::string& name, PortDirection direction, bool midi); |
225 ~Port(); | 225 ~Port(); |
226 | 226 |
227 std::string name() const; | 227 std::string name() const { return name_; } |
228 PortDirection direction() const; | 228 PortDirection direction() const { return direction_; } |
229 // True if this port is a MIDI port, instead of another kind of ALSA port. | 229 // True if this port is a MIDI port, instead of another kind of ALSA port. |
230 bool midi() const; | 230 bool midi() const { return midi_; } |
231 | 231 |
232 private: | 232 private: |
233 const std::string name_; | 233 const std::string name_; |
234 const PortDirection direction_; | 234 const PortDirection direction_; |
235 const bool midi_; | 235 const bool midi_; |
236 | 236 |
237 DISALLOW_COPY_AND_ASSIGN(Port); | 237 DISALLOW_COPY_AND_ASSIGN(Port); |
238 }; | 238 }; |
239 | 239 |
240 class Client { | 240 class Client { |
241 public: | 241 public: |
242 typedef std::map<int, Port*> PortMap; | 242 typedef std::map<int, Port*> PortMap; |
243 | 243 |
244 Client(const std::string& name, snd_seq_client_type_t type); | 244 Client(const std::string& name, snd_seq_client_type_t type); |
245 ~Client(); | 245 ~Client(); |
246 | 246 |
247 std::string name() const; | 247 std::string name() const { return name_; } |
248 snd_seq_client_type_t type() const; | 248 snd_seq_client_type_t type() const { return type_; } |
249 void AddPort(int addr, scoped_ptr<Port> port); | 249 void AddPort(int addr, scoped_ptr<Port> port); |
250 void RemovePort(int addr); | 250 void RemovePort(int addr); |
251 PortMap::const_iterator begin() const; | 251 PortMap::const_iterator begin() const; |
252 PortMap::const_iterator end() const; | 252 PortMap::const_iterator end() const; |
253 | 253 |
254 private: | 254 private: |
255 const std::string name_; | 255 const std::string name_; |
256 const snd_seq_client_type_t type_; | 256 const snd_seq_client_type_t type_; |
257 PortMap ports_; | 257 PortMap ports_; |
258 STLValueDeleter<PortMap> ports_deleter_; | 258 STLValueDeleter<PortMap> ports_deleter_; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 bool event_thread_shutdown_; // guarded by shutdown_lock_ | 389 bool event_thread_shutdown_; // guarded by shutdown_lock_ |
390 base::Lock shutdown_lock_; // guards event_thread_shutdown_ | 390 base::Lock shutdown_lock_; // guards event_thread_shutdown_ |
391 | 391 |
392 DISALLOW_COPY_AND_ASSIGN(MidiManagerAlsa); | 392 DISALLOW_COPY_AND_ASSIGN(MidiManagerAlsa); |
393 }; | 393 }; |
394 | 394 |
395 } // namespace midi | 395 } // namespace midi |
396 } // namespace media | 396 } // namespace media |
397 | 397 |
398 #endif // MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ | 398 #endif // MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ |
OLD | NEW |