| 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/usb_midi_device_android.h" | 5 #include "media/midi/usb_midi_device_android.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
| 10 #include "base/i18n/icu_string_conversions.h" | 10 #include "base/i18n/icu_string_conversions.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "jni/UsbMidiDeviceAndroid_jni.h" | 13 #include "jni/UsbMidiDeviceAndroid_jni.h" |
| 14 #include "media/midi/usb_midi_descriptor_parser.h" | 14 #include "media/midi/usb_midi_descriptor_parser.h" |
| 15 | 15 |
| 16 using base::android::JavaParamRef; | 16 using base::android::JavaParamRef; |
| 17 using base::android::ScopedJavaLocalRef; | 17 using base::android::ScopedJavaLocalRef; |
| 18 | 18 |
| 19 namespace media { | |
| 20 namespace midi { | 19 namespace midi { |
| 21 | 20 |
| 22 UsbMidiDeviceAndroid::UsbMidiDeviceAndroid( | 21 UsbMidiDeviceAndroid::UsbMidiDeviceAndroid( |
| 23 const base::android::JavaRef<jobject>& raw_device, | 22 const base::android::JavaRef<jobject>& raw_device, |
| 24 UsbMidiDeviceDelegate* delegate) | 23 UsbMidiDeviceDelegate* delegate) |
| 25 : raw_device_(raw_device), delegate_(delegate) { | 24 : raw_device_(raw_device), delegate_(delegate) { |
| 26 JNIEnv* env = base::android::AttachCurrentThread(); | 25 JNIEnv* env = base::android::AttachCurrentThread(); |
| 27 Java_UsbMidiDeviceAndroid_registerSelf(env, raw_device_, | 26 Java_UsbMidiDeviceAndroid_registerSelf(env, raw_device_, |
| 28 reinterpret_cast<jlong>(this)); | 27 reinterpret_cast<jlong>(this)); |
| 29 | 28 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 size_t size = descriptor[0]; | 138 size_t size = descriptor[0]; |
| 140 std::string encoded(reinterpret_cast<char*>(&descriptor[0]) + 2, size - 2); | 139 std::string encoded(reinterpret_cast<char*>(&descriptor[0]) + 2, size - 2); |
| 141 std::string result; | 140 std::string result; |
| 142 // Unicode ECN specifies that the string is encoded in UTF-16LE. | 141 // Unicode ECN specifies that the string is encoded in UTF-16LE. |
| 143 if (!base::ConvertToUtf8AndNormalize(encoded, "utf-16le", &result)) | 142 if (!base::ConvertToUtf8AndNormalize(encoded, "utf-16le", &result)) |
| 144 return backup; | 143 return backup; |
| 145 return result; | 144 return result; |
| 146 } | 145 } |
| 147 | 146 |
| 148 } // namespace midi | 147 } // namespace midi |
| 149 } // namespace media | |
| OLD | NEW |