/[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 554 by schoenebeck, Thu May 19 19:25:14 2005 UTC revision 970 by schoenebeck, Wed Dec 6 22:28:17 2006 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
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 Christian Schoenebeck                              *   *   Copyright (C) 2005, 2006 Christian Schoenebeck                        *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
9   *   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 103  namespace LinuxSampler { namespace gig { Line 103  namespace LinuxSampler { namespace gig {
103       * Returns -1 if command queue or pickup pool is full, 0 on success (will be       * Returns -1 if command queue or pickup pool is full, 0 on success (will be
104       * called by audio thread within the voice class).       * called by audio thread within the voice class).
105       */       */
106      int DiskThread::OrderNewStream(Stream::reference_t* pStreamRef, ::gig::Sample* pSample, unsigned long SampleOffset, bool DoLoop) {      int DiskThread::OrderNewStream(Stream::reference_t* pStreamRef, ::gig::DimensionRegion* pDimRgn, unsigned long SampleOffset, bool DoLoop) {
107          dmsg(4,("Disk Thread: new stream ordered\n"));          dmsg(4,("Disk Thread: new stream ordered\n"));
108          if (CreationQueue->write_space() < 1) {          if (CreationQueue->write_space() < 1) {
109              dmsg(1,("DiskThread: Order queue full!\n"));              dmsg(1,("DiskThread: Order queue full!\n"));
# Line 125  namespace LinuxSampler { namespace gig { Line 125  namespace LinuxSampler { namespace gig {
125          cmd.OrderID      = pStreamRef->OrderID;          cmd.OrderID      = pStreamRef->OrderID;
126          cmd.hStream      = pStreamRef->hStream;          cmd.hStream      = pStreamRef->hStream;
127          cmd.pStreamRef   = pStreamRef;          cmd.pStreamRef   = pStreamRef;
128          cmd.pSample      = pSample;          cmd.pDimRgn      = pDimRgn;
129          cmd.SampleOffset = SampleOffset;          cmd.SampleOffset = SampleOffset;
130          cmd.DoLoop       = DoLoop;          cmd.DoLoop       = DoLoop;
131    
# Line 187  namespace LinuxSampler { namespace gig { Line 187  namespace LinuxSampler { namespace gig {
187    
188      DiskThread::DiskThread(uint BufferWrapElements) : Thread(true, false, 1, -2) {      DiskThread::DiskThread(uint BufferWrapElements) : Thread(true, false, 1, -2) {
189          DecompressionBuffer = ::gig::Sample::CreateDecompressionBuffer(CONFIG_STREAM_MAX_REFILL_SIZE);          DecompressionBuffer = ::gig::Sample::CreateDecompressionBuffer(CONFIG_STREAM_MAX_REFILL_SIZE);
190          CreationQueue       = new RingBuffer<create_command_t>(1024);          CreationQueue       = new RingBuffer<create_command_t,false>(1024);
191          DeletionQueue       = new RingBuffer<delete_command_t>(1024);          DeletionQueue       = new RingBuffer<delete_command_t,false>(1024);
192          GhostQueue          = new RingBuffer<Stream::Handle>(CONFIG_MAX_STREAMS);          GhostQueue          = new RingBuffer<Stream::Handle,false>(CONFIG_MAX_STREAMS);
193          Streams             = CONFIG_MAX_STREAMS;          Streams             = CONFIG_MAX_STREAMS;
194          RefillStreamsPerRun = CONFIG_REFILL_STREAMS_PER_RUN;          RefillStreamsPerRun = CONFIG_REFILL_STREAMS_PER_RUN;
195          for (int i = 0; i < CONFIG_MAX_STREAMS; i++) {          for (int i = 0; i < CONFIG_MAX_STREAMS; i++) {
# Line 198  namespace LinuxSampler { namespace gig { Line 198  namespace LinuxSampler { namespace gig {
198          for (int i = 1; i <= CONFIG_MAX_STREAMS; i++) {          for (int i = 1; i <= CONFIG_MAX_STREAMS; i++) {
199              pCreatedStreams[i] = NULL;              pCreatedStreams[i] = NULL;
200          }          }
201            ActiveStreamCountMax = 0;
202      }      }
203    
204      DiskThread::~DiskThread() {      DiskThread::~DiskThread() {
# Line 248  namespace LinuxSampler { namespace gig { Line 249  namespace LinuxSampler { namespace gig {
249              RefillStreams(); // refill the most empty streams              RefillStreams(); // refill the most empty streams
250    
251              // if nothing was done during this iteration (eg no streambuffer              // if nothing was done during this iteration (eg no streambuffer
252              // filled with data) then sleep for 50ms              // filled with data) then sleep for 30ms
253              if (IsIdle) usleep(30000);              if (IsIdle) usleep(30000);
254    
255              int streamsInUsage = 0;              int streamsInUsage = 0;
# Line 275  namespace LinuxSampler { namespace gig { Line 276  namespace LinuxSampler { namespace gig {
276              std::cerr << "No unused stream found (OrderID:" << Command.OrderID << ") - report if this happens, this is a bug!\n" << std::flush;              std::cerr << "No unused stream found (OrderID:" << Command.OrderID << ") - report if this happens, this is a bug!\n" << std::flush;
277              return;              return;
278          }          }
279          newstream->Launch(Command.hStream, Command.pStreamRef, Command.pSample, Command.SampleOffset, Command.DoLoop);          newstream->Launch(Command.hStream, Command.pStreamRef, Command.pDimRgn, Command.SampleOffset, Command.DoLoop);
280          dmsg(4,("new Stream launched by disk thread (OrderID:%d,StreamHandle:%d)\n", Command.OrderID, Command.hStream));          dmsg(4,("new Stream launched by disk thread (OrderID:%d,StreamHandle:%d)\n", Command.OrderID, Command.hStream));
281          if (pCreatedStreams[Command.OrderID] != SLOT_RESERVED) {          if (pCreatedStreams[Command.OrderID] != SLOT_RESERVED) {
282              std::cerr << "DiskThread: Slot " << Command.OrderID << " already occupied! Please report this!\n" << std::flush;              std::cerr << "DiskThread: Slot " << Command.OrderID << " already occupied! Please report this!\n" << std::flush;

Legend:
Removed from v.554  
changed lines
  Added in v.970

  ViewVC Help
Powered by ViewVC