/[svn]/linuxsampler/trunk/src/engines/EngineBase.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/EngineBase.h

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

revision 2410 by schoenebeck, Sat Feb 2 18:52:15 2013 UTC revision 2434 by schoenebeck, Thu Mar 7 19:23:24 2013 UTC
# Line 4  Line 4 
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck    *   *   Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck    *
6   *   Copyright (C) 2005-2008 Christian Schoenebeck                         *   *   Copyright (C) 2005-2008 Christian Schoenebeck                         *
7   *   Copyright (C) 2009-2012 Christian Schoenebeck and Grigor Iliev        *   *   Copyright (C) 2009-2013 Christian Schoenebeck and Grigor Iliev        *
8   *                                                                         *   *                                                                         *
9   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
10   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 104  namespace LinuxSampler { Line 104  namespace LinuxSampler {
104               *  @param Samples - number of sample points to be rendered               *  @param Samples - number of sample points to be rendered
105               *  @returns       0 on success               *  @returns       0 on success
106               */               */
107              virtual int RenderAudio(uint Samples) {              virtual int RenderAudio(uint Samples) OVERRIDE {
108                  dmsg(8,("RenderAudio(Samples=%d)\n", Samples));                  dmsg(8,("RenderAudio(Samples=%d)\n", Samples));
109    
110                  // return if engine disabled                  // return if engine disabled
# Line 205  namespace LinuxSampler { Line 205  namespace LinuxSampler {
205                  return 0;                  return 0;
206              }              }
207    
208              virtual int MaxVoices() { return pVoicePool->poolSize(); }              virtual int MaxVoices() OVERRIDE { return pVoicePool->poolSize(); }
209    
210              virtual void SetMaxVoices(int iVoices) throw (Exception) {              virtual void SetMaxVoices(int iVoices) throw (Exception) OVERRIDE {
211                  if (iVoices < 1)                  if (iVoices < 1)
212                      throw Exception("Maximum voices for an engine cannot be set lower than 1");                      throw Exception("Maximum voices for an engine cannot be set lower than 1");
213    
# Line 250  namespace LinuxSampler { Line 250  namespace LinuxSampler {
250              /** Called after the new max number of voices is set and before resuming the engine. */              /** Called after the new max number of voices is set and before resuming the engine. */
251              virtual void PostSetMaxVoices(int iVoices) { }              virtual void PostSetMaxVoices(int iVoices) { }
252    
253              virtual uint DiskStreamCount() { return (pDiskThread) ? pDiskThread->GetActiveStreamCount() : 0; }              virtual uint DiskStreamCount() OVERRIDE { return (pDiskThread) ? pDiskThread->GetActiveStreamCount() : 0; }
254              virtual uint DiskStreamCountMax() { return (pDiskThread) ? pDiskThread->ActiveStreamCountMax : 0; }              virtual uint DiskStreamCountMax() OVERRIDE { return (pDiskThread) ? pDiskThread->ActiveStreamCountMax : 0; }
255              virtual int  MaxDiskStreams() { return iMaxDiskStreams; }              virtual int  MaxDiskStreams() OVERRIDE { return iMaxDiskStreams; }
256    
257              virtual void SetMaxDiskStreams(int iStreams) throw (Exception) {              virtual void SetMaxDiskStreams(int iStreams) throw (Exception) OVERRIDE {
258                  if (iStreams < 0)                  if (iStreams < 0)
259                      throw Exception("Maximum disk streams for an engine cannot be set lower than 0");                      throw Exception("Maximum disk streams for an engine cannot be set lower than 0");
260    
# Line 269  namespace LinuxSampler { Line 269  namespace LinuxSampler {
269                  ResumeAll();                  ResumeAll();
270              }              }
271    
272              virtual String DiskStreamBufferFillBytes() { return (pDiskThread) ? pDiskThread->GetBufferFillBytes() : ""; }              virtual String DiskStreamBufferFillBytes() OVERRIDE { return (pDiskThread) ? pDiskThread->GetBufferFillBytes() : ""; }
273              virtual String DiskStreamBufferFillPercentage() { return (pDiskThread) ? pDiskThread->GetBufferFillPercentage() : ""; }              virtual String DiskStreamBufferFillPercentage() OVERRIDE { return (pDiskThread) ? pDiskThread->GetBufferFillPercentage() : ""; }
274              virtual InstrumentManager* GetInstrumentManager() { return &instruments; }              virtual InstrumentManager* GetInstrumentManager() OVERRIDE { return &instruments; }
275    
276              /**              /**
277               * Connect this engine instance with the given audio output device.               * Connect this engine instance with the given audio output device.
# Line 282  namespace LinuxSampler { Line 282  namespace LinuxSampler {
282               *               *
283               * @param pAudioOut - audio output device to connect to               * @param pAudioOut - audio output device to connect to
284               */               */
285              virtual void Connect(AudioOutputDevice* pAudioOut) {              virtual void Connect(AudioOutputDevice* pAudioOut) OVERRIDE {
286                  // caution: don't ignore if connecting to the same device here,                  // caution: don't ignore if connecting to the same device here,
287                  // because otherwise SetMaxDiskStreams() implementation won't work anymore!                  // because otherwise SetMaxDiskStreams() implementation won't work anymore!
288    
# Line 370  namespace LinuxSampler { Line 370  namespace LinuxSampler {
370              }              }
371                    
372              // Implementattion for abstract method derived from Engine.              // Implementattion for abstract method derived from Engine.
373              virtual void ReconnectAudioOutputDevice() {              virtual void ReconnectAudioOutputDevice() OVERRIDE {
374                  SuspendAll();                  SuspendAll();
375                  if (pAudioOutputDevice) Connect(pAudioOutputDevice);                  if (pAudioOutputDevice) Connect(pAudioOutputDevice);
376                  ResumeAll();                  ResumeAll();
# Line 429  namespace LinuxSampler { Line 429  namespace LinuxSampler {
429               */               */
430              virtual void Suspend(RR* pRegion) {              virtual void Suspend(RR* pRegion) {
431                  dmsg(2,("EngineBase: Suspending Region %x ...\n",pRegion));                  dmsg(2,("EngineBase: Suspending Region %x ...\n",pRegion));
432                  SuspendedRegionsMutex.Lock();                  {
433                  SuspensionChangeOngoing.Set(true);                      LockGuard lock(SuspendedRegionsMutex);
434                  pPendingRegionSuspension = pRegion;                      SuspensionChangeOngoing.Set(true);
435                  SuspensionChangeOngoing.WaitAndUnlockIf(true);                      pPendingRegionSuspension = pRegion;
436                  SuspendedRegionsMutex.Unlock();                      SuspensionChangeOngoing.WaitAndUnlockIf(true);
437                    }
438                  dmsg(2,("EngineBase: Region %x suspended.",pRegion));                  dmsg(2,("EngineBase: Region %x suspended.",pRegion));
439              }              }
440    
# Line 445  namespace LinuxSampler { Line 446  namespace LinuxSampler {
446               */               */
447              virtual void Resume(RR* pRegion) {              virtual void Resume(RR* pRegion) {
448                  dmsg(2,("EngineBase: Resuming Region %x ...\n",pRegion));                  dmsg(2,("EngineBase: Resuming Region %x ...\n",pRegion));
449                  SuspendedRegionsMutex.Lock();                  {
450                  SuspensionChangeOngoing.Set(true);                      LockGuard lock(SuspendedRegionsMutex);
451                  pPendingRegionResumption = pRegion;                      SuspensionChangeOngoing.Set(true);
452                  SuspensionChangeOngoing.WaitAndUnlockIf(true);                      pPendingRegionResumption = pRegion;
453                  SuspendedRegionsMutex.Unlock();                      SuspensionChangeOngoing.WaitAndUnlockIf(true);
454                    }
455                  dmsg(2,("EngineBase: Region %x resumed.\n",pRegion));                  dmsg(2,("EngineBase: Region %x resumed.\n",pRegion));
456              }              }
457    
# Line 572  namespace LinuxSampler { Line 574  namespace LinuxSampler {
574              public:              public:
575                  int PendingStreamDeletions;                  int PendingStreamDeletions;
576                  RR* pPendingRegionSuspension;                  RR* pPendingRegionSuspension;
577    
578                  SuspensionVoiceHandler(RR* pPendingRegionSuspension) {                  SuspensionVoiceHandler(RR* pPendingRegionSuspension) {
579                      PendingStreamDeletions = 0;                      PendingStreamDeletions = 0;
580                      this->pPendingRegionSuspension = pPendingRegionSuspension;                      this->pPendingRegionSuspension = pPendingRegionSuspension;
581                  }                  }
582    
583                  virtual bool Process(MidiKey* pMidiKey) {                  virtual bool Process(MidiKey* pMidiKey) OVERRIDE {
584                      VoiceIterator itVoice = pMidiKey->pActiveVoices->first();                      VoiceIterator itVoice = pMidiKey->pActiveVoices->first();
585                      // if current key is not associated with this region, skip this key                      // if current key is not associated with this region, skip this key
586                      if (itVoice->GetRegion()->GetParent() != pPendingRegionSuspension) return false;                      if (itVoice->GetRegion()->GetParent() != pPendingRegionSuspension) return false;
# Line 585  namespace LinuxSampler { Line 588  namespace LinuxSampler {
588                      return true;                      return true;
589                  }                  }
590    
591                  virtual void Process(VoiceIterator& itVoice) {                  virtual void Process(VoiceIterator& itVoice) OVERRIDE {
592                      // request a notification from disk thread side for stream deletion                      // request a notification from disk thread side for stream deletion
593                      const Stream::Handle hStream = itVoice->KillImmediately(true);                      const Stream::Handle hStream = itVoice->KillImmediately(true);
594                      if (hStream != Stream::INVALID_HANDLE) { // voice actually used a stream                      if (hStream != Stream::INVALID_HANDLE) { // voice actually used a stream
# Line 1325  namespace LinuxSampler { Line 1328  namespace LinuxSampler {
1328               *  control and status variables. This method is protected by a mutex.               *  control and status variables. This method is protected by a mutex.
1329               */               */
1330              virtual void ResetInternal() {              virtual void ResetInternal() {
1331                  ResetInternalMutex.Lock();                  LockGuard lock(ResetInternalMutex);
1332    
1333                  // make sure that the engine does not get any sysex messages                  // make sure that the engine does not get any sysex messages
1334                  // while it's reseting                  // while it's reseting
# Line 1354  namespace LinuxSampler { Line 1357  namespace LinuxSampler {
1357                  pEventQueue->init();                  pEventQueue->init();
1358                  pSysexBuffer->init();                  pSysexBuffer->init();
1359                  if (sysexDisabled) MidiInputPort::AddSysexListener(this);                  if (sysexDisabled) MidiInputPort::AddSysexListener(this);
                 ResetInternalMutex.Unlock();  
1360              }              }
1361    
1362              /**              /**

Legend:
Removed from v.2410  
changed lines
  Added in v.2434

  ViewVC Help
Powered by ViewVC