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

Unified Diff: media/midi/midi_manager_mac.cc

Issue 646803005: Web MIDI: move static helper methods to functions in anonymous namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/midi/midi_manager_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/midi/midi_manager_mac.cc
diff --git a/media/midi/midi_manager_mac.cc b/media/midi/midi_manager_mac.cc
index c1302e6c80238a6415d0494d9b1af8658bf52805..59956b8ee003da2ca1e6e8461e45422557ead9d2 100644
--- a/media/midi/midi_manager_mac.cc
+++ b/media/midi/midi_manager_mac.cc
@@ -23,6 +23,63 @@ using std::string;
namespace media {
+namespace {
+
+MidiPortInfo GetPortInfoFromEndpoint(
+ MIDIEndpointRef endpoint) {
+ SInt32 id_number = 0;
+ MIDIObjectGetIntegerProperty(endpoint, kMIDIPropertyUniqueID, &id_number);
+ string id = IntToString(id_number);
+
+ string manufacturer;
+ CFStringRef manufacturer_ref = NULL;
+ OSStatus result = MIDIObjectGetStringProperty(
+ endpoint, kMIDIPropertyManufacturer, &manufacturer_ref);
+ if (result == noErr) {
+ manufacturer = SysCFStringRefToUTF8(manufacturer_ref);
+ } else {
+ // kMIDIPropertyManufacturer is not supported in IAC driver providing
+ // endpoints, and the result will be kMIDIUnknownProperty (-10835).
+ DLOG(WARNING) << "Failed to get kMIDIPropertyManufacturer with status "
+ << result;
+ }
+
+ string name;
+ CFStringRef name_ref = NULL;
+ result = MIDIObjectGetStringProperty(endpoint, kMIDIPropertyName, &name_ref);
+ if (result == noErr)
+ name = SysCFStringRefToUTF8(name_ref);
+ else
+ DLOG(WARNING) << "Failed to get kMIDIPropertyName with status " << result;
+
+ string version;
+ SInt32 version_number = 0;
+ result = MIDIObjectGetIntegerProperty(
+ endpoint, kMIDIPropertyDriverVersion, &version_number);
+ if (result == noErr) {
+ version = IntToString(version_number);
+ } else {
+ // kMIDIPropertyDriverVersion is not supported in IAC driver providing
+ // endpoints, and the result will be kMIDIUnknownProperty (-10835).
+ DLOG(WARNING) << "Failed to get kMIDIPropertyDriverVersion with status "
+ << result;
+ }
+
+ return MidiPortInfo(id, manufacturer, name, version);
+}
+
+double MIDITimeStampToSeconds(MIDITimeStamp timestamp) {
+ UInt64 nanoseconds = AudioConvertHostTimeToNanos(timestamp);
+ return static_cast<double>(nanoseconds) / 1.0e9;
+}
+
+MIDITimeStamp SecondsToMIDITimeStamp(double seconds) {
+ UInt64 nanos = UInt64(seconds * 1.0e9);
+ return AudioConvertNanosToHostTime(nanos);
+}
+
+} // namespace
+
MidiManager* MidiManager::Create() {
return new MidiManagerMac();
}
@@ -191,60 +248,4 @@ void MidiManagerMac::SendMidiData(MidiManagerClient* client,
client->AccumulateMidiBytesSent(data.size());
}
-// static
-MidiPortInfo MidiManagerMac::GetPortInfoFromEndpoint(
- MIDIEndpointRef endpoint) {
- SInt32 id_number = 0;
- MIDIObjectGetIntegerProperty(endpoint, kMIDIPropertyUniqueID, &id_number);
- string id = IntToString(id_number);
-
- string manufacturer;
- CFStringRef manufacturer_ref = NULL;
- OSStatus result = MIDIObjectGetStringProperty(
- endpoint, kMIDIPropertyManufacturer, &manufacturer_ref);
- if (result == noErr) {
- manufacturer = SysCFStringRefToUTF8(manufacturer_ref);
- } else {
- // kMIDIPropertyManufacturer is not supported in IAC driver providing
- // endpoints, and the result will be kMIDIUnknownProperty (-10835).
- DLOG(WARNING) << "Failed to get kMIDIPropertyManufacturer with status "
- << result;
- }
-
- string name;
- CFStringRef name_ref = NULL;
- result = MIDIObjectGetStringProperty(endpoint, kMIDIPropertyName, &name_ref);
- if (result == noErr)
- name = SysCFStringRefToUTF8(name_ref);
- else
- DLOG(WARNING) << "Failed to get kMIDIPropertyName with status " << result;
-
- string version;
- SInt32 version_number = 0;
- result = MIDIObjectGetIntegerProperty(
- endpoint, kMIDIPropertyDriverVersion, &version_number);
- if (result == noErr) {
- version = IntToString(version_number);
- } else {
- // kMIDIPropertyDriverVersion is not supported in IAC driver providing
- // endpoints, and the result will be kMIDIUnknownProperty (-10835).
- DLOG(WARNING) << "Failed to get kMIDIPropertyDriverVersion with status "
- << result;
- }
-
- return MidiPortInfo(id, manufacturer, name, version);
-}
-
-// static
-double MidiManagerMac::MIDITimeStampToSeconds(MIDITimeStamp timestamp) {
- UInt64 nanoseconds = AudioConvertHostTimeToNanos(timestamp);
- return static_cast<double>(nanoseconds) / 1.0e9;
-}
-
-// static
-MIDITimeStamp MidiManagerMac::SecondsToMIDITimeStamp(double seconds) {
- UInt64 nanos = UInt64(seconds * 1.0e9);
- return AudioConvertNanosToHostTime(nanos);
-}
-
} // namespace media
« no previous file with comments | « media/midi/midi_manager_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698