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

Side by Side Diff: media/midi/midi_manager.h

Issue 108603004: [WebMIDI] MIDIManager::create should return non-null object. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years 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 | « no previous file | media/midi/midi_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef MEDIA_MIDI_MIDI_MANAGER_H_ 5 #ifndef MEDIA_MIDI_MIDI_MANAGER_H_
6 #define MEDIA_MIDI_MIDI_MANAGER_H_ 6 #define MEDIA_MIDI_MIDI_MANAGER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void EndSession(MIDIManagerClient* client); 58 void EndSession(MIDIManagerClient* client);
59 59
60 // DispatchSendMIDIData() is called when MIDI data should be sent to the MIDI 60 // DispatchSendMIDIData() is called when MIDI data should be sent to the MIDI
61 // system. 61 // system.
62 // This method is supposed to return immediately and should not block. 62 // This method is supposed to return immediately and should not block.
63 // |port_index| represents the specific output port from output_ports(). 63 // |port_index| represents the specific output port from output_ports().
64 // |data| represents a series of bytes encoding one or more MIDI messages. 64 // |data| represents a series of bytes encoding one or more MIDI messages.
65 // |length| is the number of bytes in |data|. 65 // |length| is the number of bytes in |data|.
66 // |timestamp| is the time to send the data, in seconds. A value of 0 66 // |timestamp| is the time to send the data, in seconds. A value of 0
67 // means send "now" or as soon as possible. 67 // means send "now" or as soon as possible.
68 // The default implementation is for unsupported platforms.
68 virtual void DispatchSendMIDIData(MIDIManagerClient* client, 69 virtual void DispatchSendMIDIData(MIDIManagerClient* client,
69 uint32 port_index, 70 uint32 port_index,
70 const std::vector<uint8>& data, 71 const std::vector<uint8>& data,
71 double timestamp) = 0; 72 double timestamp);
72 73
73 // input_ports() is a list of MIDI ports for receiving MIDI data. 74 // input_ports() is a list of MIDI ports for receiving MIDI data.
74 // Each individual port in this list can be identified by its 75 // Each individual port in this list can be identified by its
75 // integer index into this list. 76 // integer index into this list.
76 const MIDIPortInfoList& input_ports() { return input_ports_; } 77 const MIDIPortInfoList& input_ports() { return input_ports_; }
77 78
78 // output_ports() is a list of MIDI ports for sending MIDI data. 79 // output_ports() is a list of MIDI ports for sending MIDI data.
79 // Each individual port in this list can be identified by its 80 // Each individual port in this list can be identified by its
80 // integer index into this list. 81 // integer index into this list.
81 const MIDIPortInfoList& output_ports() { return output_ports_; } 82 const MIDIPortInfoList& output_ports() { return output_ports_; }
82 83
83 protected: 84 protected:
84 // Initializes the MIDI system, returning |true| on success. 85 // Initializes the MIDI system, returning |true| on success.
85 virtual bool Initialize() = 0; 86 // The default implementation is for unsupported platforms.
87 virtual bool Initialize();
86 88
87 void AddInputPort(const MIDIPortInfo& info); 89 void AddInputPort(const MIDIPortInfo& info);
88 void AddOutputPort(const MIDIPortInfo& info); 90 void AddOutputPort(const MIDIPortInfo& info);
89 91
90 // Dispatches to all clients. 92 // Dispatches to all clients.
91 void ReceiveMIDIData(uint32 port_index, 93 void ReceiveMIDIData(uint32 port_index,
92 const uint8* data, 94 const uint8* data,
93 size_t length, 95 size_t length,
94 double timestamp); 96 double timestamp);
95 97
96 bool initialized_; 98 bool initialized_;
97 99
98 // Keeps track of all clients who wish to receive MIDI data. 100 // Keeps track of all clients who wish to receive MIDI data.
99 typedef std::set<MIDIManagerClient*> ClientList; 101 typedef std::set<MIDIManagerClient*> ClientList;
100 ClientList clients_; 102 ClientList clients_;
101 103
102 // Protects access to our clients. 104 // Protects access to our clients.
103 base::Lock clients_lock_; 105 base::Lock clients_lock_;
104 106
105 MIDIPortInfoList input_ports_; 107 MIDIPortInfoList input_ports_;
106 MIDIPortInfoList output_ports_; 108 MIDIPortInfoList output_ports_;
107 109
108 DISALLOW_COPY_AND_ASSIGN(MIDIManager); 110 DISALLOW_COPY_AND_ASSIGN(MIDIManager);
109 }; 111 };
110 112
111 } // namespace media 113 } // namespace media
112 114
113 #endif // MEDIA_MIDI_MIDI_MANAGER_H_ 115 #endif // MEDIA_MIDI_MIDI_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | media/midi/midi_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698