/[svn]/linuxsampler/trunk/src/network/lscpserver.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/network/lscpserver.cpp

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

revision 123 by schoenebeck, Mon Jun 14 19:33:16 2004 UTC revision 137 by capela, Sun Jun 20 16:49:47 2004 UTC
# Line 132  String LSCPServer::DestroyAudioOutputDev Line 132  String LSCPServer::DestroyAudioOutputDev
132  /**  /**
133   * Will be called by the parser to load an instrument.   * Will be called by the parser to load an instrument.
134   */   */
135  String LSCPServer::LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel) {  String LSCPServer::LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel, bool bBackground) {
136      dmsg(2,("LSCPServer: LoadInstrument(Filename=%s,Instrument=%d,SamplerChannel=%d)\n", Filename.c_str(), uiInstrument, uiSamplerChannel));      dmsg(2,("LSCPServer: LoadInstrument(Filename=%s,Instrument=%d,SamplerChannel=%d)\n", Filename.c_str(), uiInstrument, uiSamplerChannel));
137      LSCPResultSet result;      LSCPResultSet result;
138      try {      try {
# Line 140  String LSCPServer::LoadInstrument(String Line 140  String LSCPServer::LoadInstrument(String
140          if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds");          if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds");
141          Engine* pEngine = pSamplerChannel->GetEngine();          Engine* pEngine = pSamplerChannel->GetEngine();
142          if (!pEngine) throw LinuxSamplerException("No engine loaded on channel");          if (!pEngine) throw LinuxSamplerException("No engine loaded on channel");
143          pEngine->LoadInstrument(Filename.c_str(), uiInstrument);          if (bBackground) {
144                LSCPLoadInstrument *pLoadInstrument = new LSCPLoadInstrument(pEngine, Filename.c_str(), uiInstrument);
145                pLoadInstrument->StartThread();
146            }
147            else pEngine->LoadInstrument(Filename.c_str(), uiInstrument);
148      }      }
149      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
150           result.Error(e);           result.Error(e);
# Line 244  String LSCPServer::GetChannelInfo(uint u Line 248  String LSCPServer::GetChannelInfo(uint u
248          String EngineName = "NONE";          String EngineName = "NONE";
249          float Volume = 0;          float Volume = 0;
250          String InstrumentFileName = "NONE";          String InstrumentFileName = "NONE";
251          int InstrumentIndex = 0;          int InstrumentIndex = -1;
252            int InstrumentStatus = -1;
253    
254          if (pEngine) {          if (pEngine) {
255              EngineName =  pEngine->EngineName();              EngineName =  pEngine->EngineName();
256              Volume = pEngine->Volume();              Volume = pEngine->Volume();
257              int iIdx = pEngine->InstrumentIndex();              InstrumentStatus = pEngine->InstrumentStatus();
258              if (iIdx != -1) {              InstrumentIndex = pEngine->InstrumentIndex();
259                if (InstrumentIndex != -1)
260                  InstrumentFileName = pEngine->InstrumentFileName();                  InstrumentFileName = pEngine->InstrumentFileName();
                 InstrumentIndex = iIdx;  
             }  
261          }          }
262    
263          result.Add("ENGINE_NAME", EngineName);          result.Add("ENGINE_NAME", EngineName);
# Line 266  String LSCPServer::GetChannelInfo(uint u Line 270  String LSCPServer::GetChannelInfo(uint u
270    
271          result.Add("INSTRUMENT_FILE", InstrumentFileName);          result.Add("INSTRUMENT_FILE", InstrumentFileName);
272          result.Add("INSTRUMENT_NR", InstrumentIndex);          result.Add("INSTRUMENT_NR", InstrumentIndex);
273            result.Add("INSTRUMENT_STATUS", InstrumentStatus);
274    
275          //Some more hardcoded stuff for now to make GUI look good          //Some more hardcoded stuff for now to make GUI look good
276          result.Add("MIDI_INPUT_DEVICE", "0");          result.Add("MIDI_INPUT_DEVICE", "0");
# Line 330  String LSCPServer::GetBufferFill(fill_re Line 335  String LSCPServer::GetBufferFill(fill_re
335          if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds");          if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds");
336          Engine* pEngine = pSamplerChannel->GetEngine();          Engine* pEngine = pSamplerChannel->GetEngine();
337          if (!pEngine) throw LinuxSamplerException("No engine loaded on channel");          if (!pEngine) throw LinuxSamplerException("No engine loaded on channel");
338          if (!pEngine->DiskStreamSupported()) return "NA\r\n"; //FIXME: Update resultset class to support "NA"          if (!pEngine->DiskStreamSupported())
339          switch (ResponseType) {              result.Add("NA");
340              case fill_response_bytes:          else {
341                  result.Add(pEngine->DiskStreamBufferFillBytes());              switch (ResponseType) {
342                  break;                  case fill_response_bytes:
343              case fill_response_percentage:                      result.Add(pEngine->DiskStreamBufferFillBytes());
344                  result.Add(pEngine->DiskStreamBufferFillPercentage());                      break;
345                  break;                  case fill_response_percentage:
346              default:                      result.Add(pEngine->DiskStreamBufferFillPercentage());
347                  throw LinuxSamplerException("Unknown fill response type");                      break;
348          }                  default:
349                        throw LinuxSamplerException("Unknown fill response type");
350                }
351            }
352      }      }
353      catch (LinuxSamplerException e) {      catch (LinuxSamplerException e) {
354           result.Error(e);           result.Error(e);
# Line 577  String LSCPServer::SetMIDIInputType(Stri Line 585  String LSCPServer::SetMIDIInputType(Stri
585          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
586          if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds");          if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds");
587          // FIXME: workaround until MIDI driver configuration is implemented (using a Factory class for the MIDI input drivers then, like its already done for audio output drivers)          // FIXME: workaround until MIDI driver configuration is implemented (using a Factory class for the MIDI input drivers then, like its already done for audio output drivers)
588          if (MidiInputDriver != "ALSA") throw LinuxSamplerException("Unknown MIDI input driver '" + MidiInputDriver + "'.");          if (MidiInputDriver != "Alsa") throw LinuxSamplerException("Unknown MIDI input driver '" + MidiInputDriver + "'.");
589          MidiInputDevice::type_t MidiInputType = MidiInputDevice::type_alsa;          MidiInputDevice::type_t MidiInputType = MidiInputDevice::type_alsa;
590          pSamplerChannel->SetMidiInputDevice(MidiInputType);          pSamplerChannel->SetMidiInputDevice(MidiInputType);
591      }      }
# Line 680  String LSCPServer::ResetChannel(uint uiS Line 688  String LSCPServer::ResetChannel(uint uiS
688   * Will be called by the parser to subscribe a client (frontend) on the   * Will be called by the parser to subscribe a client (frontend) on the
689   * server for receiving event messages.   * server for receiving event messages.
690   */   */
691  String LSCPServer::SubscribeNotification(uint UDPPort) {  String LSCPServer::SubscribeNotification(event_t Event) {
692      dmsg(2,("LSCPServer: SubscribeNotification(UDPPort=%d)\n", UDPPort));      dmsg(2,("LSCPServer: SubscribeNotification(Event=%d)\n", Event));
693      return "ERR:0:Not implemented yet.\r\n";      return "ERR:0:Not implemented yet.\r\n";
694  }  }
695    
# Line 689  String LSCPServer::SubscribeNotification Line 697  String LSCPServer::SubscribeNotification
697   * Will be called by the parser to unsubscribe a client on the server   * Will be called by the parser to unsubscribe a client on the server
698   * for not receiving further event messages.   * for not receiving further event messages.
699   */   */
700  String LSCPServer::UnsubscribeNotification(String SessionID) {  String LSCPServer::UnsubscribeNotification(event_t Event) {
701      dmsg(2,("LSCPServer: UnsubscribeNotification(SessionID=%s)\n", SessionID.c_str()));      dmsg(2,("LSCPServer: UnsubscribeNotification(Event=%d)\n", Event));
702      return "ERR:0:Not implemented yet.\r\n";      return "ERR:0:Not implemented yet.\r\n";
703  }  }
704    
705    
706    // Instrument loader constructor.
707    LSCPLoadInstrument::LSCPLoadInstrument(Engine* pEngine, String Filename, uint uiInstrument)
708        : Thread(false, 0, -4)
709    {
710        this->pEngine = pEngine;
711        this->Filename = Filename;
712        this->uiInstrument = uiInstrument;
713    }
714    
715    // Instrument loader process.
716    int LSCPLoadInstrument::Main()
717    {
718        try {
719            pEngine->LoadInstrument(Filename.c_str(), uiInstrument);
720        }
721    
722        catch (LinuxSamplerException e) {
723            e.PrintMessage();
724        }
725    
726        // Always re-enable the engine.
727        pEngine->Enable();
728    
729        // FIXME: Shoot ourselves on the foot?
730        delete this;
731    }

Legend:
Removed from v.123  
changed lines
  Added in v.137

  ViewVC Help
Powered by ViewVC