Index: media/midi/midi_manager_alsa.h |
diff --git a/media/midi/midi_manager_alsa.h b/media/midi/midi_manager_alsa.h |
index cbe03c5fee776a69e1ec715e40a71a7edd936c1e..d06ff760c0483cf0bd4b6e075ed346cd5deba350 100644 |
--- a/media/midi/midi_manager_alsa.h |
+++ b/media/midi/midi_manager_alsa.h |
@@ -10,14 +10,19 @@ |
#include <vector> |
#include "base/basictypes.h" |
+#include "base/gtest_prod_util.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/synchronization/lock.h" |
#include "base/threading/thread.h" |
#include "media/midi/midi_manager.h" |
+#if defined(USE_UDEV) |
+#include "device/udev_linux/scoped_udev.h" |
+#endif // defined(USE_UDEV) |
+ |
namespace media { |
-class MidiManagerAlsa : public MidiManager { |
+class MEDIA_EXPORT MidiManagerAlsa : public MidiManager { |
public: |
MidiManagerAlsa(); |
~MidiManagerAlsa() override; |
@@ -30,6 +35,45 @@ class MidiManagerAlsa : public MidiManager { |
double timestamp) override; |
private: |
+ FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ExtractManufacturer); |
+ FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, UdevEscape); |
+ |
+ class CardInfo { |
+ public: |
+ CardInfo(const MidiManagerAlsa* outer, |
+ const std::string& alsa_name, const std::string& alsa_longname, |
+ const std::string& alsa_driver, int card_index); |
+ ~CardInfo(); |
+ |
+ const std::string alsa_name() const; |
+ const std::string manufacturer() const; |
+ const std::string alsa_driver() const; |
+ const std::string udev_id_path() const; |
+ const std::string udev_id_id() const; |
+ |
+ private: |
+ FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, ExtractManufacturer); |
+ FRIEND_TEST_ALL_PREFIXES(MidiManagerAlsaTest, UdevEscape); |
+ |
+ // Extracts the manufacturer using heuristics and a variety of sources. |
+ static std::string ExtractManufacturerString( |
+ const std::string& udev_id_vendor_enc, |
+ const std::string& udev_id_vendor_id, |
+ const std::string& udev_id_vendor_from_database, |
+ const std::string& alsa_name, |
+ const std::string& alsa_longname); |
+ |
+ // TODO(agoode): Move this into a common place. Maybe device/udev_linux? |
+ // Decodes just \xXX in strings. |
+ static std::string UnescapeUdev(const std::string& s); |
+ |
+ std::string alsa_name_; |
+ std::string manufacturer_; |
+ std::string alsa_driver_; |
+ std::string udev_id_path_; |
+ std::string udev_id_id_; |
+ }; |
+ |
// An internal callback that runs on MidiSendThread. |
void SendMidiData(uint32 port_index, |
const std::vector<uint8>& data); |
@@ -55,6 +99,11 @@ class MidiManagerAlsa : public MidiManager { |
typedef std::vector<snd_midi_event_t*> EncoderList; |
EncoderList encoders_; |
+ // udev, for querying hardware devices. |
+#if defined(USE_UDEV) |
+ device::ScopedUdevPtr udev_; |
+#endif // defined(USE_UDEV) |
+ |
base::Thread send_thread_; |
base::Thread event_thread_; |