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

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

Issue 2431393002: Web MIDI: move MIDI message validating logic into message_util.{cc|h} (Closed)
Patch Set: build fix Created 4 years, 2 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_message_util.h ('k') | media/midi/midi_message_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/logging.h"
6 #include "media/midi/midi_message_util.h"
7
8 namespace midi {
9
10 size_t GetMidiMessageLength(uint8_t status_byte) {
11 if (status_byte < 0x80)
12 return 0;
13 if (0x80 <= status_byte && status_byte <= 0xbf)
14 return 3;
15 if (0xc0 <= status_byte && status_byte <= 0xdf)
16 return 2;
17 if (0xe0 <= status_byte && status_byte <= 0xef)
18 return 3;
19
20 switch (status_byte) {
21 case 0xf0:
22 return 0;
23 case 0xf1:
24 return 2;
25 case 0xf2:
26 return 3;
27 case 0xf3:
28 return 2;
29 case 0xf4: // Reserved
30 case 0xf5: // Reserved
31 return 0;
32 case 0xf6:
33 return 1;
34 case 0xf7:
35 return 0;
36 case 0xf8:
37 case 0xf9:
38 case 0xfa:
39 case 0xfb:
40 case 0xfc:
41 case 0xfd:
42 case 0xfe:
43 case 0xff:
44 return 1;
45 default:
46 NOTREACHED();
47 return 0;
48 }
49 }
50
51 } // namespace midi
OLDNEW
« no previous file with comments | « media/midi/midi_message_util.h ('k') | media/midi/midi_message_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698