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 | #include "media/midi/midi_manager_alsa.h" |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 6 | |
| 7 | #include <alsa/asoundlib.h> |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 8 | #include <stdlib.h> |
yhirano@chromium.org | cfa642c | 2014-05-01 08:54:41 +0000 | [diff] [blame^] | 9 | #include <algorithm> |
| 10 | #include <string> |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 11 | |
| 12 | #include "base/bind.h" |
| 13 | #include "base/debug/trace_event.h" |
| 14 | #include "base/logging.h" |
| 15 | #include "base/memory/ref_counted.h" |
| 16 | #include "base/message_loop/message_loop.h" |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 17 | #include "base/posix/eintr_wrapper.h" |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 18 | #include "base/strings/stringprintf.h" |
| 19 | #include "base/threading/thread.h" |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 20 | #include "base/time/time.h" |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 21 | #include "media/midi/midi_port_info.h" |
| 22 | |
| 23 | namespace media { |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 24 | |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 25 | namespace { |
| 26 | |
| 27 | const size_t kReceiveBufferSize = 4096; |
| 28 | const unsigned short kPollEventMask = POLLIN | POLLERR | POLLNVAL; |
| 29 | |
| 30 | } // namespace |
| 31 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 32 | class MidiManagerAlsa::MidiDeviceInfo |
| 33 | : public base::RefCounted<MidiDeviceInfo> { |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 34 | public: |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 35 | MidiDeviceInfo(MidiManagerAlsa* manager, |
toyoshim@chromium.org | 9ebe19a | 2014-02-02 06:10:36 +0000 | [diff] [blame] | 36 | const std::string& bus_id, |
| 37 | snd_ctl_card_info_t* card, |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 38 | const snd_rawmidi_info_t* midi, |
| 39 | int device) { |
toyoshim@chromium.org | 9ebe19a | 2014-02-02 06:10:36 +0000 | [diff] [blame] | 40 | opened_ = !snd_rawmidi_open(&midi_in_, &midi_out_, bus_id.c_str(), 0); |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 41 | if (!opened_) |
| 42 | return; |
| 43 | |
toyoshim@chromium.org | 9ebe19a | 2014-02-02 06:10:36 +0000 | [diff] [blame] | 44 | const std::string id = base::StringPrintf("%s:%d", bus_id.c_str(), device); |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 45 | const std::string name = snd_rawmidi_info_get_name(midi); |
toyoshim@chromium.org | 9ebe19a | 2014-02-02 06:10:36 +0000 | [diff] [blame] | 46 | // We assume that card longname is in the format of |
| 47 | // "<manufacturer> <name> at <bus>". Otherwise, we give up to detect |
| 48 | // a manufacturer name here. |
| 49 | std::string manufacturer; |
| 50 | const std::string card_name = snd_ctl_card_info_get_longname(card); |
| 51 | size_t name_index = card_name.find(name); |
| 52 | if (std::string::npos != name_index) |
| 53 | manufacturer = card_name.substr(0, name_index - 1); |
| 54 | const std::string version = |
| 55 | base::StringPrintf("%s / ALSA library version %d.%d.%d", |
| 56 | snd_ctl_card_info_get_driver(card), |
| 57 | SND_LIB_MAJOR, SND_LIB_MINOR, SND_LIB_SUBMINOR); |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 58 | port_info_ = MidiPortInfo(id, manufacturer, name, version); |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 59 | } |
| 60 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 61 | void Send(MidiManagerClient* client, const std::vector<uint8>& data) { |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 62 | ssize_t result = snd_rawmidi_write( |
| 63 | midi_out_, reinterpret_cast<const void*>(&data[0]), data.size()); |
| 64 | if (static_cast<size_t>(result) != data.size()) { |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 65 | // TODO(toyoshim): Handle device disconnection. |
toyoshim@chromium.org | 2b058e8 | 2014-02-26 06:10:46 +0000 | [diff] [blame] | 66 | VLOG(1) << "snd_rawmidi_write fails: " << strerror(-result); |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 67 | } |
| 68 | base::MessageLoop::current()->PostTask( |
| 69 | FROM_HERE, |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 70 | base::Bind(&MidiManagerClient::AccumulateMidiBytesSent, |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 71 | base::Unretained(client), data.size())); |
| 72 | } |
| 73 | |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 74 | // Read input data from a MIDI input device which is ready to read through |
| 75 | // the ALSA library. Called from EventLoop() and read data will be sent to |
| 76 | // blink through MIDIManager base class. |
| 77 | size_t Receive(uint8* data, size_t length) { |
| 78 | return snd_rawmidi_read(midi_in_, reinterpret_cast<void*>(data), length); |
| 79 | } |
| 80 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 81 | const MidiPortInfo& GetMidiPortInfo() const { return port_info_; } |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 82 | |
| 83 | // Get the number of descriptors which is required to call poll() on the |
| 84 | // device. The ALSA library always returns 1 here now, but it may be changed |
| 85 | // in the future. |
| 86 | int GetPollDescriptorsCount() { |
| 87 | return snd_rawmidi_poll_descriptors_count(midi_in_); |
| 88 | } |
| 89 | |
| 90 | // Following API initializes pollfds for polling the device, and returns the |
| 91 | // number of descriptors they are initialized. It must be the same value with |
| 92 | // snd_rawmidi_poll_descriptors_count(). |
| 93 | int SetupPollDescriptors(struct pollfd* pfds, unsigned int count) { |
| 94 | return snd_rawmidi_poll_descriptors(midi_in_, pfds, count); |
| 95 | } |
| 96 | |
| 97 | unsigned short GetPollDescriptorsRevents(struct pollfd* pfds) { |
| 98 | unsigned short revents; |
| 99 | snd_rawmidi_poll_descriptors_revents(midi_in_, |
| 100 | pfds, |
| 101 | GetPollDescriptorsCount(), |
| 102 | &revents); |
| 103 | return revents; |
| 104 | } |
| 105 | |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 106 | bool IsOpened() const { return opened_; } |
| 107 | |
| 108 | private: |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 109 | friend class base::RefCounted<MidiDeviceInfo>; |
| 110 | virtual ~MidiDeviceInfo() { |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 111 | if (opened_) { |
| 112 | snd_rawmidi_close(midi_in_); |
| 113 | snd_rawmidi_close(midi_out_); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | bool opened_; |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 118 | MidiPortInfo port_info_; |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 119 | snd_rawmidi_t* midi_in_; |
| 120 | snd_rawmidi_t* midi_out_; |
| 121 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 122 | DISALLOW_COPY_AND_ASSIGN(MidiDeviceInfo); |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 123 | }; |
| 124 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 125 | MidiManagerAlsa::MidiManagerAlsa() |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 126 | : send_thread_("MidiSendThread"), |
| 127 | event_thread_("MidiEventThread") { |
| 128 | for (size_t i = 0; i < arraysize(pipe_fd_); ++i) |
| 129 | pipe_fd_[i] = -1; |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 130 | } |
| 131 | |
toyoshim@chromium.org | f77a1e6 | 2014-04-11 13:16:24 +0000 | [diff] [blame] | 132 | MidiResult MidiManagerAlsa::Initialize() { |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 133 | // TODO(toyoshim): Make Initialize() asynchronous. |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 134 | // See http://crbug.com/339746. |
toyoshim@chromium.org | 2b058e8 | 2014-02-26 06:10:46 +0000 | [diff] [blame] | 135 | TRACE_EVENT0("midi", "MidiManagerAlsa::Initialize"); |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 136 | |
| 137 | // Enumerate only hardware MIDI devices because software MIDIs running in |
| 138 | // the browser process is not secure. |
| 139 | snd_ctl_card_info_t* card; |
| 140 | snd_rawmidi_info_t* midi_out; |
| 141 | snd_rawmidi_info_t* midi_in; |
| 142 | snd_ctl_card_info_alloca(&card); |
| 143 | snd_rawmidi_info_alloca(&midi_out); |
| 144 | snd_rawmidi_info_alloca(&midi_in); |
| 145 | for (int index = -1; !snd_card_next(&index) && index >= 0; ) { |
| 146 | const std::string id = base::StringPrintf("hw:CARD=%i", index); |
| 147 | snd_ctl_t* handle; |
| 148 | int err = snd_ctl_open(&handle, id.c_str(), 0); |
| 149 | if (err != 0) { |
toyoshim@chromium.org | 2b058e8 | 2014-02-26 06:10:46 +0000 | [diff] [blame] | 150 | VLOG(1) << "snd_ctl_open fails: " << snd_strerror(err); |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 151 | continue; |
| 152 | } |
| 153 | err = snd_ctl_card_info(handle, card); |
| 154 | if (err != 0) { |
toyoshim@chromium.org | 2b058e8 | 2014-02-26 06:10:46 +0000 | [diff] [blame] | 155 | VLOG(1) << "snd_ctl_card_info fails: " << snd_strerror(err); |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 156 | snd_ctl_close(handle); |
| 157 | continue; |
| 158 | } |
| 159 | for (int device = -1; |
| 160 | !snd_ctl_rawmidi_next_device(handle, &device) && device >= 0; ) { |
| 161 | bool output; |
| 162 | bool input; |
| 163 | snd_rawmidi_info_set_device(midi_out, device); |
| 164 | snd_rawmidi_info_set_subdevice(midi_out, 0); |
| 165 | snd_rawmidi_info_set_stream(midi_out, SND_RAWMIDI_STREAM_OUTPUT); |
| 166 | output = snd_ctl_rawmidi_info(handle, midi_out) == 0; |
| 167 | snd_rawmidi_info_set_device(midi_in, device); |
| 168 | snd_rawmidi_info_set_subdevice(midi_in, 0); |
| 169 | snd_rawmidi_info_set_stream(midi_in, SND_RAWMIDI_STREAM_INPUT); |
| 170 | input = snd_ctl_rawmidi_info(handle, midi_in) == 0; |
| 171 | if (!output && !input) |
| 172 | continue; |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 173 | scoped_refptr<MidiDeviceInfo> port = new MidiDeviceInfo( |
toyoshim@chromium.org | 9ebe19a | 2014-02-02 06:10:36 +0000 | [diff] [blame] | 174 | this, id, card, output ? midi_out : midi_in, device); |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 175 | if (!port->IsOpened()) { |
toyoshim@chromium.org | 2b058e8 | 2014-02-26 06:10:46 +0000 | [diff] [blame] | 176 | VLOG(1) << "MidiDeviceInfo open fails"; |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 177 | continue; |
| 178 | } |
| 179 | if (input) { |
| 180 | in_devices_.push_back(port); |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 181 | AddInputPort(port->GetMidiPortInfo()); |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 182 | } |
| 183 | if (output) { |
| 184 | out_devices_.push_back(port); |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 185 | AddOutputPort(port->GetMidiPortInfo()); |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | snd_ctl_close(handle); |
| 189 | } |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 190 | |
| 191 | if (pipe(pipe_fd_) < 0) { |
toyoshim@chromium.org | 2b058e8 | 2014-02-26 06:10:46 +0000 | [diff] [blame] | 192 | VPLOG(1) << "pipe() failed"; |
toyoshim@chromium.org | f77a1e6 | 2014-04-11 13:16:24 +0000 | [diff] [blame] | 193 | return MIDI_INITIALIZATION_ERROR; |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 194 | } |
| 195 | event_thread_.Start(); |
| 196 | event_thread_.message_loop()->PostTask( |
| 197 | FROM_HERE, |
| 198 | base::Bind(&MidiManagerAlsa::EventReset, base::Unretained(this))); |
| 199 | |
toyoshim@chromium.org | f77a1e6 | 2014-04-11 13:16:24 +0000 | [diff] [blame] | 200 | return MIDI_OK; |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 201 | } |
| 202 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 203 | MidiManagerAlsa::~MidiManagerAlsa() { |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 204 | // Send a shutdown message to awake |event_thread_| from poll(). |
| 205 | if (pipe_fd_[1] >= 0) |
| 206 | HANDLE_EINTR(write(pipe_fd_[1], "Q", 1)); |
| 207 | |
| 208 | // Stop receiving messages. |
| 209 | event_thread_.Stop(); |
| 210 | |
| 211 | for (int i = 0; i < 2; ++i) { |
| 212 | if (pipe_fd_[i] >= 0) |
| 213 | close(pipe_fd_[i]); |
| 214 | } |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 215 | send_thread_.Stop(); |
| 216 | } |
| 217 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 218 | void MidiManagerAlsa::DispatchSendMidiData(MidiManagerClient* client, |
dnicoara@chromium.org | 9f2a6f0 | 2014-01-03 21:25:00 +0000 | [diff] [blame] | 219 | uint32 port_index, |
| 220 | const std::vector<uint8>& data, |
| 221 | double timestamp) { |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 222 | if (out_devices_.size() <= port_index) |
| 223 | return; |
| 224 | |
| 225 | base::TimeDelta delay; |
| 226 | if (timestamp != 0.0) { |
| 227 | base::TimeTicks time_to_send = |
| 228 | base::TimeTicks() + base::TimeDelta::FromMicroseconds( |
| 229 | timestamp * base::Time::kMicrosecondsPerSecond); |
| 230 | delay = std::max(time_to_send - base::TimeTicks::Now(), base::TimeDelta()); |
| 231 | } |
| 232 | |
| 233 | if (!send_thread_.IsRunning()) |
| 234 | send_thread_.Start(); |
| 235 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 236 | scoped_refptr<MidiDeviceInfo> device = out_devices_[port_index]; |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 237 | send_thread_.message_loop()->PostDelayedTask( |
| 238 | FROM_HERE, |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 239 | base::Bind(&MidiDeviceInfo::Send, device, client, data), |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 240 | delay); |
| 241 | } |
| 242 | |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 243 | void MidiManagerAlsa::EventReset() { |
yhirano@chromium.org | cfa642c | 2014-05-01 08:54:41 +0000 | [diff] [blame^] | 244 | CHECK_GE(pipe_fd_[0], 0); |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 245 | |
| 246 | // Sum up descriptors which are needed to poll input devices and a shutdown |
| 247 | // message. |
| 248 | // Keep the first one descriptor for a shutdown message. |
| 249 | size_t poll_fds_size = 1; |
| 250 | for (size_t i = 0; i < in_devices_.size(); ++i) |
| 251 | poll_fds_size += in_devices_[i]->GetPollDescriptorsCount(); |
| 252 | poll_fds_.resize(poll_fds_size); |
| 253 | |
| 254 | // Setup struct pollfd to poll input MIDI devices and a shutdown message. |
| 255 | // The first pollfd is for a shutdown message. |
| 256 | poll_fds_[0].fd = pipe_fd_[0]; |
| 257 | poll_fds_[0].events = kPollEventMask; |
| 258 | int fds_index = 1; |
| 259 | for (size_t i = 0; i < in_devices_.size(); ++i) { |
| 260 | fds_index += in_devices_[i]->SetupPollDescriptors( |
| 261 | &poll_fds_[fds_index], poll_fds_.size() - fds_index); |
| 262 | } |
| 263 | |
| 264 | event_thread_.message_loop()->PostTask( |
| 265 | FROM_HERE, |
| 266 | base::Bind(&MidiManagerAlsa::EventLoop, base::Unretained(this))); |
| 267 | } |
| 268 | |
| 269 | void MidiManagerAlsa::EventLoop() { |
| 270 | if (HANDLE_EINTR(poll(&poll_fds_[0], poll_fds_.size(), -1)) < 0) { |
toyoshim@chromium.org | 2b058e8 | 2014-02-26 06:10:46 +0000 | [diff] [blame] | 271 | VPLOG(1) << "Couldn't poll(). Stop to poll input MIDI devices."; |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 272 | // TODO(toyoshim): Handle device disconnection, and try to reconnect? |
| 273 | return; |
| 274 | } |
| 275 | |
| 276 | // Check timestamp as soon as possible because the API requires accurate |
| 277 | // timestamp as possible. It will be useful for recording MIDI events. |
| 278 | base::TimeTicks now = base::TimeTicks::HighResNow(); |
| 279 | |
| 280 | // Is this thread going to be shutdown? |
| 281 | if (poll_fds_[0].revents & kPollEventMask) |
| 282 | return; |
| 283 | |
| 284 | // Read available incoming MIDI data. |
| 285 | int fds_index = 1; |
| 286 | uint8 buffer[kReceiveBufferSize]; |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 287 | |
| 288 | for (size_t i = 0; i < in_devices_.size(); ++i) { |
| 289 | unsigned short revents = |
| 290 | in_devices_[i]->GetPollDescriptorsRevents(&poll_fds_[fds_index]); |
| 291 | if (revents & (POLLERR | POLLNVAL)) { |
| 292 | // TODO(toyoshim): Handle device disconnection. |
toyoshim@chromium.org | 2b058e8 | 2014-02-26 06:10:46 +0000 | [diff] [blame] | 293 | VLOG(1) << "snd_rawmidi_descriptors_revents fails"; |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 294 | poll_fds_[fds_index].events = 0; |
| 295 | } |
| 296 | if (revents & POLLIN) { |
| 297 | size_t read_size = in_devices_[i]->Receive(buffer, kReceiveBufferSize); |
yhirano@chromium.org | cfa642c | 2014-05-01 08:54:41 +0000 | [diff] [blame^] | 298 | ReceiveMidiData(i, buffer, read_size, now); |
toyoshim@chromium.org | 4a8657c | 2014-02-06 11:23:09 +0000 | [diff] [blame] | 299 | } |
| 300 | fds_index += in_devices_[i]->GetPollDescriptorsCount(); |
| 301 | } |
| 302 | |
| 303 | // Do again. |
| 304 | event_thread_.message_loop()->PostTask( |
| 305 | FROM_HERE, |
| 306 | base::Bind(&MidiManagerAlsa::EventLoop, base::Unretained(this))); |
| 307 | } |
| 308 | |
toyoshim@chromium.org | c82e66e | 2014-02-04 07:05:47 +0000 | [diff] [blame] | 309 | MidiManager* MidiManager::Create() { |
| 310 | return new MidiManagerAlsa(); |
toyoshim@chromium.org | a97eebf | 2014-01-03 07:52:39 +0000 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | } // namespace media |