| 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 #include "media/midi/midi_manager_alsa.h" | 5 #include "media/midi/midi_manager_alsa.h" |
| 6 | 6 |
| 7 #include <alsa/asoundlib.h> | 7 #include <alsa/asoundlib.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 snd_seq_addr_t dest; | 245 snd_seq_addr_t dest; |
| 246 dest.client = snd_seq_client_id(in_client_); | 246 dest.client = snd_seq_client_id(in_client_); |
| 247 dest.port = in_port_; | 247 dest.port = in_port_; |
| 248 snd_seq_port_subscribe_set_sender(subs, sender); | 248 snd_seq_port_subscribe_set_sender(subs, sender); |
| 249 snd_seq_port_subscribe_set_dest(subs, &dest); | 249 snd_seq_port_subscribe_set_dest(subs, &dest); |
| 250 err = snd_seq_subscribe_port(in_client_, subs); | 250 err = snd_seq_subscribe_port(in_client_, subs); |
| 251 if (err != 0) { | 251 if (err != 0) { |
| 252 VLOG(1) << "snd_seq_subscribe_port fails: " << snd_strerror(err); | 252 VLOG(1) << "snd_seq_subscribe_port fails: " << snd_strerror(err); |
| 253 } else { | 253 } else { |
| 254 source_map_[AddrToInt(sender)] = current_input++; | 254 source_map_[AddrToInt(sender)] = current_input++; |
| 255 AddInputPort(MidiPortInfo(id, manufacturer, name, version)); | 255 AddInputPort(MidiPortInfo( |
| 256 id, manufacturer, name, version, MIDI_PORT_OPENED)); |
| 256 } | 257 } |
| 257 } | 258 } |
| 258 if ((caps & kRequiredOutputPortCaps) == kRequiredOutputPortCaps) { | 259 if ((caps & kRequiredOutputPortCaps) == kRequiredOutputPortCaps) { |
| 259 // Create a port for us to send on. | 260 // Create a port for us to send on. |
| 260 int out_port = | 261 int out_port = |
| 261 snd_seq_create_simple_port(out_client_, NULL, | 262 snd_seq_create_simple_port(out_client_, NULL, |
| 262 SND_SEQ_PORT_CAP_READ | | 263 SND_SEQ_PORT_CAP_READ | |
| 263 SND_SEQ_PORT_CAP_NO_EXPORT, | 264 SND_SEQ_PORT_CAP_NO_EXPORT, |
| 264 SND_SEQ_PORT_TYPE_MIDI_GENERIC | | 265 SND_SEQ_PORT_TYPE_MIDI_GENERIC | |
| 265 SND_SEQ_PORT_TYPE_APPLICATION); | 266 SND_SEQ_PORT_TYPE_APPLICATION); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 279 snd_seq_port_subscribe_set_dest(subs, dest); | 280 snd_seq_port_subscribe_set_dest(subs, dest); |
| 280 err = snd_seq_subscribe_port(out_client_, subs); | 281 err = snd_seq_subscribe_port(out_client_, subs); |
| 281 if (err != 0) { | 282 if (err != 0) { |
| 282 VLOG(1) << "snd_seq_subscribe_port fails: " << snd_strerror(err); | 283 VLOG(1) << "snd_seq_subscribe_port fails: " << snd_strerror(err); |
| 283 snd_seq_delete_simple_port(out_client_, out_port); | 284 snd_seq_delete_simple_port(out_client_, out_port); |
| 284 } else { | 285 } else { |
| 285 snd_midi_event_t* encoder; | 286 snd_midi_event_t* encoder; |
| 286 snd_midi_event_new(kSendBufferSize, &encoder); | 287 snd_midi_event_new(kSendBufferSize, &encoder); |
| 287 encoders_.push_back(encoder); | 288 encoders_.push_back(encoder); |
| 288 out_ports_.push_back(out_port); | 289 out_ports_.push_back(out_port); |
| 289 AddOutputPort(MidiPortInfo(id, manufacturer, name, version)); | 290 AddOutputPort(MidiPortInfo( |
| 291 id, manufacturer, name, version, MIDI_PORT_OPENED)); |
| 290 } | 292 } |
| 291 } | 293 } |
| 292 } | 294 } |
| 293 } | 295 } |
| 294 } | 296 } |
| 295 | 297 |
| 296 event_thread_.Start(); | 298 event_thread_.Start(); |
| 297 event_thread_.message_loop()->PostTask( | 299 event_thread_.message_loop()->PostTask( |
| 298 FROM_HERE, | 300 FROM_HERE, |
| 299 base::Bind(&MidiManagerAlsa::EventReset, base::Unretained(this))); | 301 base::Bind(&MidiManagerAlsa::EventReset, base::Unretained(this))); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 event_thread_.message_loop()->PostTask( | 445 event_thread_.message_loop()->PostTask( |
| 444 FROM_HERE, | 446 FROM_HERE, |
| 445 base::Bind(&MidiManagerAlsa::EventLoop, base::Unretained(this))); | 447 base::Bind(&MidiManagerAlsa::EventLoop, base::Unretained(this))); |
| 446 } | 448 } |
| 447 | 449 |
| 448 MidiManager* MidiManager::Create() { | 450 MidiManager* MidiManager::Create() { |
| 449 return new MidiManagerAlsa(); | 451 return new MidiManagerAlsa(); |
| 450 } | 452 } |
| 451 | 453 |
| 452 } // namespace media | 454 } // namespace media |
| OLD | NEW |