Chromium Code Reviews| Index: media/midi/midi_message_queue.cc |
| diff --git a/media/midi/midi_message_queue.cc b/media/midi/midi_message_queue.cc |
| index 9107a4b528e23ae4bf39d286a67307085feec373..fb486fe4cfc45967cb69e86b857fa389b829fee9 100644 |
| --- a/media/midi/midi_message_queue.cc |
| +++ b/media/midi/midi_message_queue.cc |
| @@ -7,27 +7,12 @@ |
| #include <algorithm> |
| #include "base/logging.h" |
| -#include "media/midi/midi_message_util.h" |
| +#include "media/midi/message_util.h" |
| namespace midi { |
| -namespace { |
| -const uint8_t kSysEx = 0xf0; |
| -const uint8_t kEndOfSysEx = 0xf7; |
| - |
| -bool IsDataByte(uint8_t data) { |
| - return (data & 0x80) == 0; |
| -} |
| - |
| -bool IsSystemRealTimeMessage(uint8_t data) { |
| - return 0xf8 <= data; |
| -} |
| - |
| -bool IsSystemMessage(uint8_t data) { |
| - return 0xf0 <= data; |
| -} |
| - |
| -} // namespace |
| +using midi::kSysExByte; |
|
yukawa
2016/10/19 20:11:20
Do we need this?
Takashi Toyoshima
2016/10/20 05:18:17
Done.
|
| +using midi::kEndOfSysExByte; |
|
yukawa
2016/10/19 20:11:20
Do we need this?
Takashi Toyoshima
2016/10/20 05:18:17
Done.
|
| MidiMessageQueue::MidiMessageQueue(bool allow_running_status) |
| : allow_running_status_(allow_running_status) {} |
| @@ -49,13 +34,13 @@ void MidiMessageQueue::Get(std::vector<uint8_t>* message) { |
| // Check if |next_message_| is already a complete MIDI message or not. |
| if (!next_message_.empty()) { |
| const uint8_t status_byte = next_message_.front(); |
| - const size_t target_len = GetMidiMessageLength(status_byte); |
| + const size_t target_len = GetMessageLength(status_byte); |
| if (target_len == 0) { |
| - DCHECK_EQ(kSysEx, status_byte); |
| - if (next_message_.back() == kEndOfSysEx) { |
| - // OK, this is a complete SysEx message. |
| - std::swap(*message, next_message_); |
| - DCHECK(next_message_.empty()); |
| + DCHECK_EQ(kSysExByte, status_byte); |
| + if (next_message_.back() == kEndOfSysExByte) { |
| + // OK, this is a complete SysEx message. |
| + std::swap(*message, next_message_); |
| + DCHECK(next_message_.empty()); |
| return; |
| } |
| } else if (next_message_.size() == target_len) { |
| @@ -90,11 +75,11 @@ void MidiMessageQueue::Get(std::vector<uint8_t>* message) { |
| } |
| if (next_message_.empty()) { |
| - const size_t target_len = GetMidiMessageLength(next); |
| + const size_t target_len = GetMessageLength(next); |
| // If |target_len| is zero, it means either |next| is not a valid status |
| // byte or |next| is a valid status byte but the message length is |
| // unpredictable. For the latter case, only SysEx can be accepted. |
| - if (target_len > 0 || next == kSysEx) { |
| + if (target_len > 0 || next == kSysExByte) { |
| next_message_.push_back(next); |
| } |
| // Consume |next| always, since if |next| isn't status byte, which means |
| @@ -111,7 +96,8 @@ void MidiMessageQueue::Get(std::vector<uint8_t>* message) { |
| // drop the pending message and respin the loop to re-evaluate |next|. |
| // This also clears the running status byte speculatively added above, as |
| // well as any broken incomplete messages. |
| - if (!IsDataByte(next) && !(status_byte == kSysEx && next == kEndOfSysEx)) { |
| + if (!IsDataByte(next) && |
| + !(status_byte == kSysExByte && next == kEndOfSysExByte)) { |
| next_message_.clear(); |
| continue; |
| } |