/[svn]/linuxsampler/trunk/src/engines/gig/DiskThread.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/gig/DiskThread.cpp

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

revision 1037 by schoenebeck, Wed Dec 6 22:28:17 2006 UTC revision 1038 by persson, Sat Feb 3 15:33:00 2007 UTC
# Line 58  namespace LinuxSampler { namespace gig { Line 58  namespace LinuxSampler { namespace gig {
58          GhostQueue->init();          GhostQueue->init();
59          CreationQueue->init();          CreationQueue->init();
60          DeletionQueue->init();          DeletionQueue->init();
61            DeleteDimregQueue->init();
62          ActiveStreamCount = 0;          ActiveStreamCount = 0;
63          ActiveStreamCountMax = 0;          ActiveStreamCountMax = 0;
64          if (running) this->StartThread(); // start thread only if it was running before          if (running) this->StartThread(); // start thread only if it was running before
# Line 154  namespace LinuxSampler { namespace gig { Line 155  namespace LinuxSampler { namespace gig {
155      }      }
156    
157      /**      /**
158         * Tell the disk thread to release a dimension region that belong
159         * to an instrument which isn't loaded anymore. The disk thread
160         * will hand back the dimension region to the instrument resource
161         * manager. (OrderDeletionOfDimreg is called from the audio thread
162         * when a voice dies.)
163         */
164        int DiskThread::OrderDeletionOfDimreg(::gig::DimensionRegion* dimreg) {
165            dmsg(4,("Disk Thread: dimreg deletion ordered\n"));
166            if (DeleteDimregQueue->write_space() < 1) {
167                dmsg(1,("DiskThread: DeleteDimreg queue full!\n"));
168                return -1;
169            }
170            DeleteDimregQueue->push(&dimreg);
171            return 0;
172        }
173    
174        /**
175       * Returns the pointer to a disk stream if the ordered disk stream       * Returns the pointer to a disk stream if the ordered disk stream
176       * represented by the \a StreamOrderID was already activated by the disk       * represented by the \a StreamOrderID was already activated by the disk
177       * thread, returns NULL otherwise. If the call was successful, thus if it       * thread, returns NULL otherwise. If the call was successful, thus if it
# Line 185  namespace LinuxSampler { namespace gig { Line 203  namespace LinuxSampler { namespace gig {
203      // #         (following code should only be executed by the disk thread)      // #         (following code should only be executed by the disk thread)
204    
205    
206      DiskThread::DiskThread(uint BufferWrapElements) : Thread(true, false, 1, -2) {      DiskThread::DiskThread(uint BufferWrapElements, InstrumentResourceManager* pInstruments) :
207            Thread(true, false, 1, -2),
208            pInstruments(pInstruments) {
209          DecompressionBuffer = ::gig::Sample::CreateDecompressionBuffer(CONFIG_STREAM_MAX_REFILL_SIZE);          DecompressionBuffer = ::gig::Sample::CreateDecompressionBuffer(CONFIG_STREAM_MAX_REFILL_SIZE);
210          CreationQueue       = new RingBuffer<create_command_t,false>(1024);          CreationQueue       = new RingBuffer<create_command_t,false>(1024);
211          DeletionQueue       = new RingBuffer<delete_command_t,false>(1024);          DeletionQueue       = new RingBuffer<delete_command_t,false>(1024);
212          GhostQueue          = new RingBuffer<Stream::Handle,false>(CONFIG_MAX_STREAMS);          GhostQueue          = new RingBuffer<Stream::Handle,false>(CONFIG_MAX_STREAMS);
213            DeleteDimregQueue   = new RingBuffer< ::gig::DimensionRegion*,false>(1024);
214          Streams             = CONFIG_MAX_STREAMS;          Streams             = CONFIG_MAX_STREAMS;
215          RefillStreamsPerRun = CONFIG_REFILL_STREAMS_PER_RUN;          RefillStreamsPerRun = CONFIG_REFILL_STREAMS_PER_RUN;
216          for (int i = 0; i < CONFIG_MAX_STREAMS; i++) {          for (int i = 0; i < CONFIG_MAX_STREAMS; i++) {
# Line 208  namespace LinuxSampler { namespace gig { Line 229  namespace LinuxSampler { namespace gig {
229          if (CreationQueue) delete CreationQueue;          if (CreationQueue) delete CreationQueue;
230          if (DeletionQueue) delete DeletionQueue;          if (DeletionQueue) delete DeletionQueue;
231          if (GhostQueue)    delete GhostQueue;          if (GhostQueue)    delete GhostQueue;
232            if (DeleteDimregQueue) delete DeleteDimregQueue;
233          ::gig::Sample::DestroyDecompressionBuffer(DecompressionBuffer);          ::gig::Sample::DestroyDecompressionBuffer(DecompressionBuffer);
234      }      }
235    
# Line 246  namespace LinuxSampler { namespace gig { Line 268  namespace LinuxSampler { namespace gig {
268                  DeleteStream(command);                  DeleteStream(command);
269              }              }
270    
271                // release DimensionRegions that belong to instruments
272                // that are no longer loaded
273                while (DeleteDimregQueue->read_space() > 0) {
274                    ::gig::DimensionRegion* dimreg;
275                    DeleteDimregQueue->pop(&dimreg);
276                    pInstruments->HandBackDimReg(dimreg);
277                }
278    
279              RefillStreams(); // refill the most empty streams              RefillStreams(); // refill the most empty streams
280    
281              // if nothing was done during this iteration (eg no streambuffer              // if nothing was done during this iteration (eg no streambuffer

Legend:
Removed from v.1037  
changed lines
  Added in v.1038

  ViewVC Help
Powered by ViewVC