OLD | NEW |
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 CONTENT_BROWSER_MEDIA_MIDI_HOST_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_MIDI_HOST_H_ |
6 #define CONTENT_BROWSER_MEDIA_MIDI_HOST_H_ | 6 #define CONTENT_BROWSER_MEDIA_MIDI_HOST_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "content/public/browser/browser_message_filter.h" | 16 #include "content/public/browser/browser_message_filter.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 #include "media/midi/midi_manager.h" | 18 #include "media/midi/midi_manager.h" |
19 #include "media/midi/midi_port_info.h" | 19 #include "media/midi/midi_port_info.h" |
20 | 20 |
21 namespace media { | 21 namespace media { |
| 22 namespace midi { |
22 class MidiManager; | 23 class MidiManager; |
23 class MidiMessageQueue; | 24 class MidiMessageQueue; |
24 } | 25 } |
| 26 } |
25 | 27 |
26 namespace content { | 28 namespace content { |
27 | 29 |
28 class CONTENT_EXPORT MidiHost | 30 class CONTENT_EXPORT MidiHost : public BrowserMessageFilter, |
29 : public BrowserMessageFilter, | 31 public media::midi::MidiManagerClient { |
30 public media::MidiManagerClient { | |
31 public: | 32 public: |
32 // Called from UI thread from the owner of this object. | 33 // Called from UI thread from the owner of this object. |
33 MidiHost(int renderer_process_id, media::MidiManager* midi_manager); | 34 MidiHost(int renderer_process_id, media::midi::MidiManager* midi_manager); |
34 | 35 |
35 // BrowserMessageFilter implementation. | 36 // BrowserMessageFilter implementation. |
36 void OnDestruct() const override; | 37 void OnDestruct() const override; |
37 bool OnMessageReceived(const IPC::Message& message) override; | 38 bool OnMessageReceived(const IPC::Message& message) override; |
38 | 39 |
39 // MidiManagerClient implementation. | 40 // MidiManagerClient implementation. |
40 void CompleteStartSession(media::MidiResult result) override; | 41 void CompleteStartSession(media::midi::MidiResult result) override; |
41 void AddInputPort(const media::MidiPortInfo& info) override; | 42 void AddInputPort(const media::midi::MidiPortInfo& info) override; |
42 void AddOutputPort(const media::MidiPortInfo& info) override; | 43 void AddOutputPort(const media::midi::MidiPortInfo& info) override; |
43 void SetInputPortState(uint32 port, media::MidiPortState state) override; | 44 void SetInputPortState(uint32 port, |
44 void SetOutputPortState(uint32 port, media::MidiPortState state) override; | 45 media::midi::MidiPortState state) override; |
| 46 void SetOutputPortState(uint32 port, |
| 47 media::midi::MidiPortState state) override; |
45 void ReceiveMidiData(uint32 port, | 48 void ReceiveMidiData(uint32 port, |
46 const uint8* data, | 49 const uint8* data, |
47 size_t length, | 50 size_t length, |
48 double timestamp) override; | 51 double timestamp) override; |
49 void AccumulateMidiBytesSent(size_t n) override; | 52 void AccumulateMidiBytesSent(size_t n) override; |
50 | 53 |
51 // Start session to access MIDI hardware. | 54 // Start session to access MIDI hardware. |
52 void OnStartSession(); | 55 void OnStartSession(); |
53 | 56 |
54 // Data to be sent to a MIDI output port. | 57 // Data to be sent to a MIDI output port. |
(...skipping 25 matching lines...) Expand all Loading... |
80 bool has_sys_ex_permission_; | 83 bool has_sys_ex_permission_; |
81 | 84 |
82 // Represents if a session is requested to start. | 85 // Represents if a session is requested to start. |
83 bool is_session_requested_; | 86 bool is_session_requested_; |
84 | 87 |
85 // |midi_manager_| talks to the platform-specific MIDI APIs. | 88 // |midi_manager_| talks to the platform-specific MIDI APIs. |
86 // It can be NULL if the platform (or our current implementation) | 89 // It can be NULL if the platform (or our current implementation) |
87 // does not support MIDI. If not supported then a call to | 90 // does not support MIDI. If not supported then a call to |
88 // OnRequestAccess() will always refuse access and a call to | 91 // OnRequestAccess() will always refuse access and a call to |
89 // OnSendData() will do nothing. | 92 // OnSendData() will do nothing. |
90 media::MidiManager* const midi_manager_; | 93 media::midi::MidiManager* const midi_manager_; |
91 | 94 |
92 // Buffers where data sent from each MIDI input port is stored. | 95 // Buffers where data sent from each MIDI input port is stored. |
93 ScopedVector<media::MidiMessageQueue> received_messages_queues_; | 96 ScopedVector<media::midi::MidiMessageQueue> received_messages_queues_; |
94 | 97 |
95 // Protects access to |received_messages_queues_|; | 98 // Protects access to |received_messages_queues_|; |
96 base::Lock messages_queues_lock_; | 99 base::Lock messages_queues_lock_; |
97 | 100 |
98 // The number of bytes sent to the platform-specific MIDI sending | 101 // The number of bytes sent to the platform-specific MIDI sending |
99 // system, but not yet completed. | 102 // system, but not yet completed. |
100 size_t sent_bytes_in_flight_; | 103 size_t sent_bytes_in_flight_; |
101 | 104 |
102 // The number of bytes successfully sent since the last time | 105 // The number of bytes successfully sent since the last time |
103 // we've acknowledged back to the renderer. | 106 // we've acknowledged back to the renderer. |
104 size_t bytes_sent_since_last_acknowledgement_; | 107 size_t bytes_sent_since_last_acknowledgement_; |
105 | 108 |
106 // Protects access to |sent_bytes_in_flight_|. | 109 // Protects access to |sent_bytes_in_flight_|. |
107 base::Lock in_flight_lock_; | 110 base::Lock in_flight_lock_; |
108 | 111 |
109 // How many output port exists. | 112 // How many output port exists. |
110 uint32 output_port_count_; | 113 uint32 output_port_count_; |
111 | 114 |
112 // Protects access to |output_port_count_|. | 115 // Protects access to |output_port_count_|. |
113 base::Lock output_port_count_lock_; | 116 base::Lock output_port_count_lock_; |
114 | 117 |
115 DISALLOW_COPY_AND_ASSIGN(MidiHost); | 118 DISALLOW_COPY_AND_ASSIGN(MidiHost); |
116 }; | 119 }; |
117 | 120 |
118 } // namespace content | 121 } // namespace content |
119 | 122 |
120 #endif // CONTENT_BROWSER_MEDIA_MIDI_HOST_H_ | 123 #endif // CONTENT_BROWSER_MEDIA_MIDI_HOST_H_ |
OLD | NEW |