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

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

Issue 2262043002: MidiScheduler binds to task runner of constructing thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 3 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
« no previous file with comments | « media/midi/midi_manager_android.h ('k') | media/midi/midi_manager_usb.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 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/midi_manager_android.h" 5 #include "media/midi/midi_manager_android.h"
6 6
7 #include "base/android/build_info.h" 7 #include "base/android/build_info.h"
8 #include "base/android/context_utils.h" 8 #include "base/android/context_utils.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 17 matching lines...) Expand all
28 switches::kUseAndroidMidiApi)) { 28 switches::kUseAndroidMidiApi)) {
29 return new MidiManagerUsb(std::unique_ptr<UsbMidiDevice::Factory>( 29 return new MidiManagerUsb(std::unique_ptr<UsbMidiDevice::Factory>(
30 new UsbMidiDeviceFactoryAndroid)); 30 new UsbMidiDeviceFactoryAndroid));
31 } 31 }
32 32
33 return new MidiManagerAndroid(); 33 return new MidiManagerAndroid();
34 } 34 }
35 35
36 MidiManagerAndroid::MidiManagerAndroid() {} 36 MidiManagerAndroid::MidiManagerAndroid() {}
37 37
38 MidiManagerAndroid::~MidiManagerAndroid() {} 38 MidiManagerAndroid::~MidiManagerAndroid() {
39 base::AutoLock auto_lock(scheduler_lock_);
40 CHECK(!scheduler_);
41 }
39 42
40 void MidiManagerAndroid::StartInitialization() { 43 void MidiManagerAndroid::StartInitialization() {
41 JNIEnv* env = base::android::AttachCurrentThread(); 44 JNIEnv* env = base::android::AttachCurrentThread();
42 45
43 uintptr_t pointer = reinterpret_cast<uintptr_t>(this); 46 uintptr_t pointer = reinterpret_cast<uintptr_t>(this);
44 raw_manager_.Reset(Java_MidiManagerAndroid_create( 47 raw_manager_.Reset(Java_MidiManagerAndroid_create(
45 env, base::android::GetApplicationContext(), pointer)); 48 env, base::android::GetApplicationContext(), pointer));
46 scheduler_.reset(new MidiScheduler(this)); 49
50 {
51 base::AutoLock auto_lock(scheduler_lock_);
52 scheduler_.reset(new MidiScheduler(this));
53 }
54
47 Java_MidiManagerAndroid_initialize(env, raw_manager_); 55 Java_MidiManagerAndroid_initialize(env, raw_manager_);
48 } 56 }
49 57
58 void MidiManagerAndroid::Finalize() {
59 // Destruct MidiScheduler on Chrome_IOThread.
60 base::AutoLock auto_lock(scheduler_lock_);
61 scheduler_.reset();
62 }
63
50 void MidiManagerAndroid::DispatchSendMidiData(MidiManagerClient* client, 64 void MidiManagerAndroid::DispatchSendMidiData(MidiManagerClient* client,
51 uint32_t port_index, 65 uint32_t port_index,
52 const std::vector<uint8_t>& data, 66 const std::vector<uint8_t>& data,
53 double timestamp) { 67 double timestamp) {
54 if (port_index >= all_output_ports_.size()) { 68 if (port_index >= all_output_ports_.size()) {
55 // |port_index| is provided by a renderer so we can't believe that it is 69 // |port_index| is provided by a renderer so we can't believe that it is
56 // in the valid range. 70 // in the valid range.
57 return; 71 return;
58 } 72 }
59 DCHECK_EQ(output_ports().size(), all_output_ports_.size()); 73 DCHECK_EQ(output_ports().size(), all_output_ports_.size());
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 175 }
162 devices_.push_back(device.release()); 176 devices_.push_back(device.release());
163 } 177 }
164 178
165 bool MidiManagerAndroid::Register(JNIEnv* env) { 179 bool MidiManagerAndroid::Register(JNIEnv* env) {
166 return RegisterNativesImpl(env); 180 return RegisterNativesImpl(env);
167 } 181 }
168 182
169 } // namespace midi 183 } // namespace midi
170 } // namespace media 184 } // namespace media
OLDNEW
« no previous file with comments | « media/midi/midi_manager_android.h ('k') | media/midi/midi_manager_usb.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698