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

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

Issue 264973012: Use seq instead of rawmidi for MidiManagerAlsa (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Increase MIDI send buffer size to 256, to avoid splitting sysex messages too much. Created 6 years, 7 months 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_alsa.cc » ('j') | media/midi/midi_manager_alsa.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_ALSA_H_ 5 #ifndef MEDIA_MIDI_MIDI_MANAGER_ALSA_H_
6 #define MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ 6 #define MEDIA_MIDI_MIDI_MANAGER_ALSA_H_
7 7
8 #include <poll.h> 8 #include <alsa/asoundlib.h>
9 #include <map>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/synchronization/lock.h"
13 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
14 #include "media/midi/midi_manager.h" 16 #include "media/midi/midi_manager.h"
15 17
16 namespace media { 18 namespace media {
17 19
18 class MidiManagerAlsa : public MidiManager { 20 class MidiManagerAlsa : public MidiManager {
19 public: 21 public:
20 MidiManagerAlsa(); 22 MidiManagerAlsa();
21 virtual ~MidiManagerAlsa(); 23 virtual ~MidiManagerAlsa();
22 24
23 // MidiManager implementation. 25 // MidiManager implementation.
24 virtual void StartInitialization() OVERRIDE; 26 virtual void StartInitialization() OVERRIDE;
25 virtual void DispatchSendMidiData(MidiManagerClient* client, 27 virtual void DispatchSendMidiData(MidiManagerClient* client,
26 uint32 port_index, 28 uint32 port_index,
27 const std::vector<uint8>& data, 29 const std::vector<uint8>& data,
28 double timestamp) OVERRIDE; 30 double timestamp) OVERRIDE;
29 31
30 private: 32 private:
33 // An internal callback that runs on MidiSendThread.
34 void SendMidiData(uint32 port_index,
35 const std::vector<uint8>& data);
36
31 void EventReset(); 37 void EventReset();
32 void EventLoop(); 38 void EventLoop();
33 39
34 class MidiDeviceInfo; 40 // Alsa seq handles.
35 std::vector<scoped_refptr<MidiDeviceInfo> > in_devices_; 41 snd_seq_t* in_client_;
36 std::vector<scoped_refptr<MidiDeviceInfo> > out_devices_; 42 snd_seq_t* out_client_;
43 int out_client_id_;
44
45 // One input port, many output ports.
46 int in_port_;
47 std::vector<int> out_ports_;
48
49 // Mapping from Alsa client:port to our index.
50 typedef std::map<int, uint32> SourceMap;
51 SourceMap source_map_;
52
53 // Alsa event <-> MIDI coders.
54 snd_midi_event_t* decoder_;
55 typedef std::vector<snd_midi_event_t*> EncoderList;
56 EncoderList encoders_;
57
37 base::Thread send_thread_; 58 base::Thread send_thread_;
38 base::Thread event_thread_; 59 base::Thread event_thread_;
39 60
40 // Used for shutting down the |event_thread_| safely. 61 bool event_thread_shutdown_; // guarded by shutdown_mu_
41 int pipe_fd_[2]; 62 base::Lock shutdown_mu_; // guards event_thread_shutdown_
42 // Used for polling input MIDI ports and |pipe_fd_| in |event_thread_|.
43 std::vector<struct pollfd> poll_fds_;
44 63
45 DISALLOW_COPY_AND_ASSIGN(MidiManagerAlsa); 64 DISALLOW_COPY_AND_ASSIGN(MidiManagerAlsa);
46 }; 65 };
47 66
48 } // namespace media 67 } // namespace media
49 68
50 #endif // MEDIA_MIDI_MIDI_MANAGER_ALSA_H_ 69 #endif // MEDIA_MIDI_MIDI_MANAGER_ALSA_H_
OLDNEW
« no previous file with comments | « no previous file | media/midi/midi_manager_alsa.cc » ('j') | media/midi/midi_manager_alsa.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698