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

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

Issue 700723004: Do not use vector<scoped_ptr<>>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 1 month 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 | « media/midi/midi_manager_win.h ('k') | win8/metro_driver/print_document_source.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 scoped_ptr<InDeviceInfo> in_device(InDeviceInfo::Create(this, device_id)); 511 scoped_ptr<InDeviceInfo> in_device(InDeviceInfo::Create(this, device_id));
512 if (!in_device) 512 if (!in_device)
513 continue; 513 continue;
514 MidiPortInfo info( 514 MidiPortInfo info(
515 base::IntToString(static_cast<int>(device_id)), 515 base::IntToString(static_cast<int>(device_id)),
516 "", 516 "",
517 base::WideToUTF8(caps.szPname), 517 base::WideToUTF8(caps.szPname),
518 base::IntToString(static_cast<int>(caps.vDriverVersion))); 518 base::IntToString(static_cast<int>(caps.vDriverVersion)));
519 AddInputPort(info); 519 AddInputPort(info);
520 in_device->set_port_index(inport_index++); 520 in_device->set_port_index(inport_index++);
521 in_devices_.push_back(in_device.Pass()); 521 in_devices_.push_back(in_device.release());
522 } 522 }
523 523
524 const UINT num_out_devices = midiOutGetNumDevs(); 524 const UINT num_out_devices = midiOutGetNumDevs();
525 out_devices_.reserve(num_out_devices); 525 out_devices_.reserve(num_out_devices);
526 for (UINT device_id = 0; device_id < num_out_devices; ++device_id) { 526 for (UINT device_id = 0; device_id < num_out_devices; ++device_id) {
527 MIDIOUTCAPS caps = {}; 527 MIDIOUTCAPS caps = {};
528 MMRESULT result = midiOutGetDevCaps(device_id, &caps, sizeof(caps)); 528 MMRESULT result = midiOutGetDevCaps(device_id, &caps, sizeof(caps));
529 if (result != MMSYSERR_NOERROR) { 529 if (result != MMSYSERR_NOERROR) {
530 DLOG(ERROR) << "Failed to obtain output device info: " 530 DLOG(ERROR) << "Failed to obtain output device info: "
531 << GetOutErrorMessage(result); 531 << GetOutErrorMessage(result);
532 continue; 532 continue;
533 } 533 }
534 scoped_ptr<OutDeviceInfo> out_port(OutDeviceInfo::Create(device_id)); 534 scoped_ptr<OutDeviceInfo> out_port(OutDeviceInfo::Create(device_id));
535 if (!out_port) 535 if (!out_port)
536 continue; 536 continue;
537 MidiPortInfo info( 537 MidiPortInfo info(
538 base::IntToString(static_cast<int>(device_id)), 538 base::IntToString(static_cast<int>(device_id)),
539 "", 539 "",
540 base::WideToUTF8(caps.szPname), 540 base::WideToUTF8(caps.szPname),
541 base::IntToString(static_cast<int>(caps.vDriverVersion))); 541 base::IntToString(static_cast<int>(caps.vDriverVersion)));
542 AddOutputPort(info); 542 AddOutputPort(info);
543 out_devices_.push_back(out_port.Pass()); 543 out_devices_.push_back(out_port.release());
544 } 544 }
545 545
546 CompleteInitialization(MIDI_OK); 546 CompleteInitialization(MIDI_OK);
547 } 547 }
548 548
549 MidiManagerWin::~MidiManagerWin() { 549 MidiManagerWin::~MidiManagerWin() {
550 // Cleanup order is important. |send_thread_| must be stopped before 550 // Cleanup order is important. |send_thread_| must be stopped before
551 // |out_devices_| is cleared. 551 // |out_devices_| is cleared.
552 for (auto& device : out_devices_) 552 for (auto& device : out_devices_)
553 device->Quit(); 553 device->Quit();
(...skipping 14 matching lines...) Expand all
568 if (timestamp != 0.0) { 568 if (timestamp != 0.0) {
569 base::TimeTicks time_to_send = 569 base::TimeTicks time_to_send =
570 base::TimeTicks() + base::TimeDelta::FromMicroseconds( 570 base::TimeTicks() + base::TimeDelta::FromMicroseconds(
571 timestamp * base::Time::kMicrosecondsPerSecond); 571 timestamp * base::Time::kMicrosecondsPerSecond);
572 delay = std::max(time_to_send - base::TimeTicks::Now(), base::TimeDelta()); 572 delay = std::max(time_to_send - base::TimeTicks::Now(), base::TimeDelta());
573 } 573 }
574 574
575 if (!send_thread_.IsRunning()) 575 if (!send_thread_.IsRunning())
576 send_thread_.Start(); 576 send_thread_.Start();
577 577
578 OutDeviceInfo* out_port = out_devices_[port_index].get(); 578 OutDeviceInfo* out_port = out_devices_[port_index];
579 send_thread_.message_loop()->PostDelayedTask( 579 send_thread_.message_loop()->PostDelayedTask(
580 FROM_HERE, 580 FROM_HERE,
581 base::Bind(&OutDeviceInfo::Send, base::Unretained(out_port), data), 581 base::Bind(&OutDeviceInfo::Send, base::Unretained(out_port), data),
582 delay); 582 delay);
583 583
584 // Call back AccumulateMidiBytesSent() on |send_thread_| to emulate the 584 // Call back AccumulateMidiBytesSent() on |send_thread_| to emulate the
585 // behavior of MidiManagerMac::SendMidiData. 585 // behavior of MidiManagerMac::SendMidiData.
586 // TODO(yukawa): Do this task in a platform-independent way if possible. 586 // TODO(yukawa): Do this task in a platform-independent way if possible.
587 // See crbug.com/325810. 587 // See crbug.com/325810.
588 send_thread_.message_loop()->PostTask( 588 send_thread_.message_loop()->PostTask(
589 FROM_HERE, 589 FROM_HERE,
590 base::Bind(&MidiManagerClient::AccumulateMidiBytesSent, 590 base::Bind(&MidiManagerClient::AccumulateMidiBytesSent,
591 base::Unretained(client), data.size())); 591 base::Unretained(client), data.size()));
592 } 592 }
593 593
594 MidiManager* MidiManager::Create() { 594 MidiManager* MidiManager::Create() {
595 return new MidiManagerWin(); 595 return new MidiManagerWin();
596 } 596 }
597 597
598 } // namespace media 598 } // namespace media
OLDNEW
« no previous file with comments | « media/midi/midi_manager_win.h ('k') | win8/metro_driver/print_document_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698