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

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

Issue 269543028: Web MIDI: make input_ports_ and output_ports_ members private (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_win.h" 5 #include "media/midi/midi_manager_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 // Prevent unnecessary functions from being included from <mmsystem.h> 9 // Prevent unnecessary functions from being included from <mmsystem.h>
10 #define MMNODRV 10 #define MMNODRV
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 } 509 }
510 scoped_ptr<InDeviceInfo> in_device(InDeviceInfo::Create(this, device_id)); 510 scoped_ptr<InDeviceInfo> in_device(InDeviceInfo::Create(this, device_id));
511 if (!in_device) 511 if (!in_device)
512 continue; 512 continue;
513 MidiPortInfo info( 513 MidiPortInfo info(
514 base::IntToString(static_cast<int>(device_id)), 514 base::IntToString(static_cast<int>(device_id)),
515 "", 515 "",
516 base::WideToUTF8(caps.szPname), 516 base::WideToUTF8(caps.szPname),
517 base::IntToString(static_cast<int>(caps.vDriverVersion))); 517 base::IntToString(static_cast<int>(caps.vDriverVersion)));
518 AddInputPort(info); 518 AddInputPort(info);
519 in_device->set_port_index(input_ports_.size() - 1); 519 in_device->set_port_index(get_input_ports().size() - 1);
520 in_devices_.push_back(in_device.Pass()); 520 in_devices_.push_back(in_device.Pass());
521 } 521 }
522 522
523 const UINT num_out_devices = midiOutGetNumDevs(); 523 const UINT num_out_devices = midiOutGetNumDevs();
524 out_devices_.reserve(num_out_devices); 524 out_devices_.reserve(num_out_devices);
525 for (UINT device_id = 0; device_id < num_out_devices; ++device_id) { 525 for (UINT device_id = 0; device_id < num_out_devices; ++device_id) {
526 MIDIOUTCAPS caps = {}; 526 MIDIOUTCAPS caps = {};
527 MMRESULT result = midiOutGetDevCaps(device_id, &caps, sizeof(caps)); 527 MMRESULT result = midiOutGetDevCaps(device_id, &caps, sizeof(caps));
528 if (result != MMSYSERR_NOERROR) { 528 if (result != MMSYSERR_NOERROR) {
529 DLOG(ERROR) << "Failed to obtain output device info: " 529 DLOG(ERROR) << "Failed to obtain output device info: "
(...skipping 11 matching lines...) Expand all
541 AddOutputPort(info); 541 AddOutputPort(info);
542 out_devices_.push_back(out_port.Pass()); 542 out_devices_.push_back(out_port.Pass());
543 } 543 }
544 544
545 CompleteInitialization(MIDI_OK); 545 CompleteInitialization(MIDI_OK);
546 } 546 }
547 547
548 MidiManagerWin::~MidiManagerWin() { 548 MidiManagerWin::~MidiManagerWin() {
549 // Cleanup order is important. |send_thread_| must be stopped before 549 // Cleanup order is important. |send_thread_| must be stopped before
550 // |out_devices_| is cleared. 550 // |out_devices_| is cleared.
551 for (size_t i = 0; i < output_ports_.size(); ++i) 551 for (size_t i = 0; i < get_output_ports().size(); ++i)
552 out_devices_[i]->Quit(); 552 out_devices_[i]->Quit();
553 send_thread_.Stop(); 553 send_thread_.Stop();
554 554
555 out_devices_.clear(); 555 out_devices_.clear();
556 output_ports_.clear();
557 in_devices_.clear(); 556 in_devices_.clear();
558 input_ports_.clear(); 557 ClearInputOutputPorts();
Takashi Toyoshima 2014/05/06 23:12:11 BTW, Yukawa-san, do you remember why ports should
yukawa 2014/05/07 00:29:57 Hmm, I don't know. An important rule here is that
Takashi Toyoshima 2014/05/07 02:28:26 OK, so I just remove it. For making MidiPostInfoL
559 } 558 }
560 559
561 void MidiManagerWin::DispatchSendMidiData(MidiManagerClient* client, 560 void MidiManagerWin::DispatchSendMidiData(MidiManagerClient* client,
562 uint32 port_index, 561 uint32 port_index,
563 const std::vector<uint8>& data, 562 const std::vector<uint8>& data,
564 double timestamp) { 563 double timestamp) {
565 if (out_devices_.size() <= port_index) 564 if (out_devices_.size() <= port_index)
566 return; 565 return;
567 566
568 base::TimeDelta delay; 567 base::TimeDelta delay;
(...skipping 21 matching lines...) Expand all
590 FROM_HERE, 589 FROM_HERE,
591 base::Bind(&MidiManagerClient::AccumulateMidiBytesSent, 590 base::Bind(&MidiManagerClient::AccumulateMidiBytesSent,
592 base::Unretained(client), data.size())); 591 base::Unretained(client), data.size()));
593 } 592 }
594 593
595 MidiManager* MidiManager::Create() { 594 MidiManager* MidiManager::Create() {
596 return new MidiManagerWin(); 595 return new MidiManagerWin();
597 } 596 }
598 597
599 } // namespace media 598 } // namespace media
OLDNEW
« media/midi/midi_manager.h ('K') | « media/midi/midi_manager_usb_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698