OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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.h" | 5 #include "media/midi/midi_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/message_loop/message_loop.h" | |
9 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
10 | 11 |
11 namespace media { | 12 namespace media { |
12 | 13 |
13 #if !defined(OS_MACOSX) | 14 #if !defined(OS_MACOSX) |
14 // TODO(crogers): implement MIDIManager for other platforms. | 15 // TODO(crogers): implement MIDIManager for other platforms. |
15 MIDIManager* MIDIManager::Create() { | 16 MIDIManager* MIDIManager::Create() { |
16 return NULL; | 17 return NULL; |
17 } | 18 } |
18 #endif | 19 #endif |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 int port_index, | 56 int port_index, |
56 const uint8* data, | 57 const uint8* data, |
57 size_t length, | 58 size_t length, |
58 double timestamp) { | 59 double timestamp) { |
59 base::AutoLock auto_lock(clients_lock_); | 60 base::AutoLock auto_lock(clients_lock_); |
60 | 61 |
61 for (ClientList::iterator i = clients_.begin(); i != clients_.end(); ++i) | 62 for (ClientList::iterator i = clients_.begin(); i != clients_.end(); ++i) |
62 (*i)->ReceiveMIDIData(port_index, data, length, timestamp); | 63 (*i)->ReceiveMIDIData(port_index, data, length, timestamp); |
63 } | 64 } |
64 | 65 |
66 bool MIDIManager::CurrentlyOnMIDISendThread() { | |
67 return send_thread_->message_loop() == base::MessageLoop::current(); | |
68 } | |
69 | |
65 void MIDIManager::DispatchSendMIDIData(MIDIManagerClient* client, | 70 void MIDIManager::DispatchSendMIDIData(MIDIManagerClient* client, |
66 int port_index, | 71 unsigned int port_index, |
67 const uint8* data, | 72 const std::vector<uint8>& data, |
68 size_t length, | |
69 double timestamp) { | 73 double timestamp) { |
70 // Lazily create the thread when first needed. | 74 // Lazily create the thread when first needed. |
71 if (!send_thread_) { | 75 if (!send_thread_) { |
72 send_thread_.reset(new base::Thread("MIDISendThread")); | 76 send_thread_.reset(new base::Thread("MIDISendThread")); |
73 send_thread_->Start(); | 77 send_thread_->Start(); |
74 send_message_loop_ = send_thread_->message_loop_proxy(); | 78 send_message_loop_ = send_thread_->message_loop_proxy(); |
75 } | 79 } |
76 | 80 |
77 send_message_loop_->PostTask( | 81 send_message_loop_->PostTask( |
78 FROM_HERE, | 82 FROM_HERE, |
79 base::Bind(&MIDIManager::SendMIDIData, base::Unretained(this), | 83 base::Bind(&MIDIManager::SendMIDIData, base::Unretained(this), |
80 client, port_index, data, length, timestamp)); | 84 client, port_index, data, timestamp)); |
Takashi Toyoshima
2013/08/21 13:48:22
raw buffer could not be passed to another thread c
|
scherkus (not reviewing)
2013/08/21 17:46:29
do you know how large |data| can typically be?
ar
Takashi Toyoshima
2013/08/22 05:47:45
Typically, it's just 3 Bytes.
|
81 } | 85 } |
82 | 86 |
83 } // namespace media | 87 } // namespace media |
OLD | NEW |