toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 1 | // Copyright 2014 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 | |
dnicoara@chromium.org | 9f2a6f0 | 2014-01-03 21:25:00 +0000 | [diff] [blame] | 5 | #ifndef MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ |
| 6 | #define MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 7 | |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame^] | 8 | #include <poll.h> |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 9 | #include <vector> |
| 10 | |
| 11 | #include "base/basictypes.h" |
| 12 | #include "base/memory/scoped_ptr.h" |
| 13 | #include "base/threading/thread.h" |
| 14 | #include "media/midi/midi_manager.h" |
| 15 | |
| 16 | namespace media { |
| 17 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 18 | class MidiManagerAlsa : public MidiManager { |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 19 | public: |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 20 | MidiManagerAlsa(); |
| 21 | virtual ~MidiManagerAlsa(); |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 22 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 23 | // MidiManager implementation. |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 24 | virtual bool Initialize() OVERRIDE; |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 25 | virtual void DispatchSendMidiData(MidiManagerClient* client, |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 26 | uint32 port_index, |
| 27 | const std::vector<uint8>& data, |
| 28 | double timestamp) OVERRIDE; |
| 29 | |
| 30 | private: |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame^] | 31 | void EventReset(); |
| 32 | void EventLoop(); |
| 33 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 34 | class MidiDeviceInfo; |
| 35 | std::vector<scoped_refptr<MidiDeviceInfo> > in_devices_; |
| 36 | std::vector<scoped_refptr<MidiDeviceInfo> > out_devices_; |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 37 | base::Thread send_thread_; |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame^] | 38 | base::Thread event_thread_; |
| 39 | |
| 40 | // Used for shutting down the |event_thread_| safely. |
| 41 | int pipe_fd_[2]; |
| 42 | // Used for polling input MIDI ports and |pipe_fd_| in |event_thread_|. |
| 43 | std::vector<struct pollfd> poll_fds_; |
| 44 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 45 | DISALLOW_COPY_AND_ASSIGN(MidiManagerAlsa); |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | } // namespace media |
| 49 | |
dnicoara@chromium.org | 9f2a6f0 | 2014-01-03 21:25:00 +0000 | [diff] [blame] | 50 | #endif // MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ |