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

Unified Diff: media/midi/midi_manager.cc

Issue 68353002: Use MIDIMessageQueue/IsValidWebMIDIData for MIDI byte stream validation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use ScopedVector<T> instead to make legacy compilers happy. Created 7 years, 1 month 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.h ('k') | media/midi/midi_message_queue.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/midi/midi_manager.cc
diff --git a/media/midi/midi_manager.cc b/media/midi/midi_manager.cc
index b3262e4a034516ab8af46629bc3cfffa5b5d5ea7..91198021b835e8d2e58204bb58373cc43e2cdf5e 100644
--- a/media/midi/midi_manager.cc
+++ b/media/midi/midi_manager.cc
@@ -8,6 +8,7 @@
#include "base/bind_helpers.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread.h"
+#include "media/midi/midi_message_queue.h"
namespace media {
@@ -46,6 +47,7 @@ void MIDIManager::EndSession(MIDIManagerClient* client) {
void MIDIManager::AddInputPort(const MIDIPortInfo& info) {
input_ports_.push_back(info);
+ input_message_queues_.push_back(new MIDIMessageQueue(true));
}
void MIDIManager::AddOutputPort(const MIDIPortInfo& info) {
@@ -59,8 +61,15 @@ void MIDIManager::ReceiveMIDIData(
double timestamp) {
base::AutoLock auto_lock(clients_lock_);
Takashi Toyoshima 2013/11/12 21:59:36 This message queue introduces two additional memor
yukawa 2013/11/14 14:55:31 Thank you for the suggestion. I moved MIDIMessageQ
- for (ClientList::iterator i = clients_.begin(); i != clients_.end(); ++i)
- (*i)->ReceiveMIDIData(port_index, data, length, timestamp);
+ input_message_queues_[port_index]->Add(data, length);
+ std::vector<uint8> message;
+ while (true) {
+ input_message_queues_[port_index]->Get(&message);
+ if (message.empty())
+ return;
+ for (ClientList::iterator i = clients_.begin(); i != clients_.end(); ++i)
+ (*i)->ReceiveMIDIData(port_index, &message[0], message.size(), timestamp);
+ }
}
bool MIDIManager::CurrentlyOnMIDISendThread() {
« no previous file with comments | « media/midi/midi_manager.h ('k') | media/midi/midi_message_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698