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