/[svn]/linuxsampler/trunk/src/mididriver/MidiInputDeviceAlsa.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/mididriver/MidiInputDeviceAlsa.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 173 by senkov, Tue Jun 29 00:50:38 2004 UTC revision 174 by senkov, Tue Jul 6 03:27:38 2004 UTC
# Line 25  Line 25 
25    
26  namespace LinuxSampler {  namespace LinuxSampler {
27    
28          REGISTER_MIDI_INPUT_DRIVER("Alsa",MidiInputDeviceAlsa);          REGISTER_MIDI_INPUT_DRIVER(MidiInputDeviceAlsa);
29    
30      MidiInputDeviceAlsa::MidiInputDeviceAlsa(std::map<String,String> Parameters) : MidiInputDevice(CreateParameters(Parameters)), Thread(true, 1, -1) {          /* Common parameters */
31            REGISTER_MIDI_INPUT_DRIVER_PARAMETER(MidiInputDeviceAlsa, ParameterActive);
32            REGISTER_MIDI_INPUT_DRIVER_PARAMETER(MidiInputDeviceAlsa, ParameterPorts);
33    
34        MidiInputDeviceAlsa::MidiInputDeviceAlsa(std::map<String,DeviceCreationParameter*> Parameters) : MidiInputDevice(Parameters), Thread(true, 1, -1) {
35          if (snd_seq_open(&hAlsaSeq, "default", SND_SEQ_OPEN_INPUT, 0) < 0) {          if (snd_seq_open(&hAlsaSeq, "default", SND_SEQ_OPEN_INPUT, 0) < 0) {
36              throw MidiInputException("Error opening ALSA sequencer");              throw MidiInputException("Error opening ALSA sequencer");
37          }          }
38          this->hAlsaSeqClient = snd_seq_client_id(hAlsaSeq);          this->hAlsaSeqClient = snd_seq_client_id(hAlsaSeq);
39          snd_seq_set_client_name(hAlsaSeq, "LinuxSampler");          snd_seq_set_client_name(hAlsaSeq, "LinuxSampler");
40            AcquirePorts(((DeviceCreationParameterInt*)Parameters["ports"])->ValueAsInt());
41            if (((DeviceCreationParameterBool*)Parameters["active"])->ValueAsBool()) {
42                    Listen();
43            }
44      }      }
45    
46      MidiInputDeviceAlsa::~MidiInputDeviceAlsa() {      MidiInputDeviceAlsa::~MidiInputDeviceAlsa() {
# Line 41  namespace LinuxSampler { Line 49  namespace LinuxSampler {
49    
50      MidiInputDeviceAlsa::MidiInputPortAlsa::MidiInputPortAlsa(MidiInputDeviceAlsa* pDevice, int alsaPort) : MidiInputPort(pDevice, alsaPort) {      MidiInputDeviceAlsa::MidiInputPortAlsa::MidiInputPortAlsa(MidiInputDeviceAlsa* pDevice, int alsaPort) : MidiInputPort(pDevice, alsaPort) {
51              Parameters["alsa_seq_bindings"] = new ParameterAlsaSeqBindings(this);              Parameters["alsa_seq_bindings"] = new ParameterAlsaSeqBindings(this);
52                this->pDevice = pDevice;
53      }      }
54    
55      MidiInputDeviceAlsa::MidiInputPortAlsa::~MidiInputPortAlsa() {      MidiInputDeviceAlsa::MidiInputPortAlsa::~MidiInputPortAlsa() {
# Line 57  namespace LinuxSampler { Line 66  namespace LinuxSampler {
66              return ( new MidiInputPortAlsa(this, alsaPort) );              return ( new MidiInputPortAlsa(this, alsaPort) );
67      }      }
68    
69        String MidiInputDeviceAlsa::Name() {
70                return "Alsa";
71        }
72    
73        String MidiInputDeviceAlsa::Driver() {
74                return Name();
75        }
76    
77      void MidiInputDeviceAlsa::Listen() {      void MidiInputDeviceAlsa::Listen() {
78          StartThread();          StartThread();
79      }      }
# Line 97  namespace LinuxSampler { Line 114  namespace LinuxSampler {
114      }      }
115    
116      String MidiInputDeviceAlsa::Version() {      String MidiInputDeviceAlsa::Version() {
117              String s = "$Revision: 1.6 $";              String s = "$Revision: 1.7 $";
118              return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword              return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
119      }      }
120    
     std::map<String,DeviceCreationParameter*> MidiInputDeviceAlsa::CreateParameters(std::map<String,String> Parameters) {  
              std::map<String,DeviceCreationParameter*> result;  
              result["active"] = OptionalParameter<ParameterActive>::New(this, Parameters["active"]);  
              result["ports"] = OptionalParameter<ParameterPorts>::New(this, Parameters["ports"]);  
              return result;  
     }  
   
121      int MidiInputDeviceAlsa::Main() {      int MidiInputDeviceAlsa::Main() {
122          int npfd;          int npfd;
123          struct pollfd* pfd;          struct pollfd* pfd;

Legend:
Removed from v.173  
changed lines
  Added in v.174

  ViewVC Help
Powered by ViewVC