summaryrefslogtreecommitdiffstats
path: root/content/browser/media/midi_host.cc
diff options
context:
space:
mode:
authortoyoshim <toyoshim@chromium.org>2015-10-06 00:54:21 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-06 07:55:28 +0000
commit29aaa95a4444e6d4ce9bb789cc7996821f044e52 (patch)
treeba5f25ae3f4bbc0b927f036ec34d34ab3554128b /content/browser/media/midi_host.cc
parent20783544a35e815bd4ddfcf9bfae447d0778b9ca (diff)
downloadchromium_src-29aaa95a4444e6d4ce9bb789cc7996821f044e52.zip
chromium_src-29aaa95a4444e6d4ce9bb789cc7996821f044e52.tar.gz
chromium_src-29aaa95a4444e6d4ce9bb789cc7996821f044e52.tar.bz2
Web MIDI: introduce MidiManager::Shutdown to shutdown gracefully
Platform dependent MidiManager implementations allocate extra threads lazily on the IO thread, but it does not have a chance to stop them correctly on the same IO thread, and stop it on the main thread. This patch introduces Shutdown() method to be called before the IO thread stopped so that the MidiManager implementations can stop the extra threads gracefully on the right thread. Platform specific fixes follow this change. BUG=374341 Review URL: https://codereview.chromium.org/1315793008 Cr-Commit-Position: refs/heads/master@{#352564}
Diffstat (limited to 'content/browser/media/midi_host.cc')
-rw-r--r--content/browser/media/midi_host.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/content/browser/media/midi_host.cc b/content/browser/media/midi_host.cc
index c26a719..bc697ed 100644
--- a/content/browser/media/midi_host.cc
+++ b/content/browser/media/midi_host.cc
@@ -56,12 +56,12 @@ MidiHost::MidiHost(int renderer_process_id,
sent_bytes_in_flight_(0),
bytes_sent_since_last_acknowledgement_(0),
output_port_count_(0) {
- CHECK(midi_manager_);
+ DCHECK(midi_manager_);
}
MidiHost::~MidiHost() {
// Close an open session, or abort opening a session.
- if (is_session_requested_)
+ if (is_session_requested_ && midi_manager_)
midi_manager_->EndSession(this);
}
@@ -84,7 +84,8 @@ bool MidiHost::OnMessageReceived(const IPC::Message& message) {
void MidiHost::OnStartSession() {
is_session_requested_ = true;
- midi_manager_->StartSession(this);
+ if (midi_manager_)
+ midi_manager_->StartSession(this);
}
void MidiHost::OnSendData(uint32 port,
@@ -122,12 +123,14 @@ void MidiHost::OnSendData(uint32 port,
return;
sent_bytes_in_flight_ += data.size();
}
- midi_manager_->DispatchSendMidiData(this, port, data, timestamp);
+ if (midi_manager_)
+ midi_manager_->DispatchSendMidiData(this, port, data, timestamp);
}
void MidiHost::OnEndSession() {
is_session_requested_ = false;
- midi_manager_->EndSession(this);
+ if (midi_manager_)
+ midi_manager_->EndSession(this);
}
void MidiHost::CompleteStartSession(media::midi::Result result) {
@@ -216,6 +219,10 @@ void MidiHost::AccumulateMidiBytesSent(size_t n) {
}
}
+void MidiHost::Detach() {
+ midi_manager_ = nullptr;
+}
+
// static
bool MidiHost::IsValidWebMIDIData(const std::vector<uint8>& data) {
bool in_sysex = false;