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

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

Issue 662233002: Web MIDI: make MidiManagerMac notify device connections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + cleanup Created 6 years, 2 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
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 #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
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 const bool connected = trie;
yhirano 2014/10/24 03:30:08 true
Takashi Toyoshima 2015/02/17 17:10:37 Done.
256 AddInputPort(
257 MidiPortInfo(id, manufacturer, name, version, connected));
256 } 258 }
257 } 259 }
258 if ((caps & kRequiredOutputPortCaps) == kRequiredOutputPortCaps) { 260 if ((caps & kRequiredOutputPortCaps) == kRequiredOutputPortCaps) {
259 // Create a port for us to send on. 261 // Create a port for us to send on.
260 int out_port = 262 int out_port =
261 snd_seq_create_simple_port(out_client_, NULL, 263 snd_seq_create_simple_port(out_client_, NULL,
262 SND_SEQ_PORT_CAP_READ | 264 SND_SEQ_PORT_CAP_READ |
263 SND_SEQ_PORT_CAP_NO_EXPORT, 265 SND_SEQ_PORT_CAP_NO_EXPORT,
264 SND_SEQ_PORT_TYPE_MIDI_GENERIC | 266 SND_SEQ_PORT_TYPE_MIDI_GENERIC |
265 SND_SEQ_PORT_TYPE_APPLICATION); 267 SND_SEQ_PORT_TYPE_APPLICATION);
(...skipping 13 matching lines...) Expand all
279 snd_seq_port_subscribe_set_dest(subs, dest); 281 snd_seq_port_subscribe_set_dest(subs, dest);
280 err = snd_seq_subscribe_port(out_client_, subs); 282 err = snd_seq_subscribe_port(out_client_, subs);
281 if (err != 0) { 283 if (err != 0) {
282 VLOG(1) << "snd_seq_subscribe_port fails: " << snd_strerror(err); 284 VLOG(1) << "snd_seq_subscribe_port fails: " << snd_strerror(err);
283 snd_seq_delete_simple_port(out_client_, out_port); 285 snd_seq_delete_simple_port(out_client_, out_port);
284 } else { 286 } else {
285 snd_midi_event_t* encoder; 287 snd_midi_event_t* encoder;
286 snd_midi_event_new(kSendBufferSize, &encoder); 288 snd_midi_event_new(kSendBufferSize, &encoder);
287 encoders_.push_back(encoder); 289 encoders_.push_back(encoder);
288 out_ports_.push_back(out_port); 290 out_ports_.push_back(out_port);
289 AddOutputPort(MidiPortInfo(id, manufacturer, name, version)); 291 const bool connected = true;
292 AddOutputPort(
293 MidiPortInfo(id, manufacturer, name, version, connected));
290 } 294 }
291 } 295 }
292 } 296 }
293 } 297 }
294 } 298 }
295 299
296 event_thread_.Start(); 300 event_thread_.Start();
297 event_thread_.message_loop()->PostTask( 301 event_thread_.message_loop()->PostTask(
298 FROM_HERE, 302 FROM_HERE,
299 base::Bind(&MidiManagerAlsa::EventReset, base::Unretained(this))); 303 base::Bind(&MidiManagerAlsa::EventReset, base::Unretained(this)));
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 event_thread_.message_loop()->PostTask( 448 event_thread_.message_loop()->PostTask(
445 FROM_HERE, 449 FROM_HERE,
446 base::Bind(&MidiManagerAlsa::EventLoop, base::Unretained(this))); 450 base::Bind(&MidiManagerAlsa::EventLoop, base::Unretained(this)));
447 } 451 }
448 452
449 MidiManager* MidiManager::Create() { 453 MidiManager* MidiManager::Create() {
450 return new MidiManagerAlsa(); 454 return new MidiManagerAlsa();
451 } 455 }
452 456
453 } // namespace media 457 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698