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; |
| 17 using base::android::ScopedJavaLocalRef; |
| 18 |
16 namespace media { | 19 namespace media { |
17 namespace midi { | 20 namespace midi { |
18 | 21 |
19 UsbMidiDeviceAndroid::UsbMidiDeviceAndroid( | 22 UsbMidiDeviceAndroid::UsbMidiDeviceAndroid( |
20 const base::android::JavaRef<jobject>& raw_device, | 23 const base::android::JavaRef<jobject>& raw_device, |
21 UsbMidiDeviceDelegate* delegate) | 24 UsbMidiDeviceDelegate* delegate) |
22 : raw_device_(raw_device), delegate_(delegate) { | 25 : raw_device_(raw_device), delegate_(delegate) { |
23 JNIEnv* env = base::android::AttachCurrentThread(); | 26 JNIEnv* env = base::android::AttachCurrentThread(); |
24 Java_UsbMidiDeviceAndroid_registerSelf(env, raw_device_.obj(), | 27 Java_UsbMidiDeviceAndroid_registerSelf(env, raw_device_.obj(), |
25 reinterpret_cast<jlong>(this)); | 28 reinterpret_cast<jlong>(this)); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 std::string encoded(reinterpret_cast<char*>(&descriptor[0]) + 2, size - 2); | 141 std::string encoded(reinterpret_cast<char*>(&descriptor[0]) + 2, size - 2); |
139 std::string result; | 142 std::string result; |
140 // Unicode ECN specifies that the string is encoded in UTF-16LE. | 143 // Unicode ECN specifies that the string is encoded in UTF-16LE. |
141 if (!base::ConvertToUtf8AndNormalize(encoded, "utf-16le", &result)) | 144 if (!base::ConvertToUtf8AndNormalize(encoded, "utf-16le", &result)) |
142 return backup; | 145 return backup; |
143 return result; | 146 return result; |
144 } | 147 } |
145 | 148 |
146 } // namespace midi | 149 } // namespace midi |
147 } // namespace media | 150 } // namespace media |
OLD | NEW |