/[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 53 by schoenebeck, Mon Apr 26 17:15:51 2004 UTC revision 361 by schoenebeck, Wed Feb 9 01:22:18 2005 UTC
# Line 2  Line 2 
2   *                                                                         *   *                                                                         *
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003 by Benno Senoner                                   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *                                                                         *   *                                                                         *
7   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
8   *   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 109  namespace LinuxSampler { namespace gig { Line 109  namespace LinuxSampler { namespace gig {
109              return -1;              return -1;
110          }          }
111    
112            const Stream::OrderID_t newOrder = CreateOrderID();
113            if (!newOrder) {
114                    dmsg(1,("DiskThread: there was no free slot\n"));
115                    return -1; // there was no free slot
116            }
117    
118          pStreamRef->State   = Stream::state_active;          pStreamRef->State   = Stream::state_active;
119          pStreamRef->OrderID = CreateOrderID();          pStreamRef->OrderID = newOrder;
120          pStreamRef->hStream = CreateHandle();          pStreamRef->hStream = CreateHandle();
121          pStreamRef->pStream = NULL; // a stream has to be activated by the disk thread first          pStreamRef->pStream = NULL; // a stream has to be activated by the disk thread first
122    
         if (!pStreamRef->OrderID) return -1; // there was no free slot  
   
123          create_command_t cmd;          create_command_t cmd;
124          cmd.OrderID      = pStreamRef->OrderID;          cmd.OrderID      = pStreamRef->OrderID;
125          cmd.hStream      = pStreamRef->hStream;          cmd.hStream      = pStreamRef->hStream;
# Line 206  namespace LinuxSampler { namespace gig { Line 210  namespace LinuxSampler { namespace gig {
210      int DiskThread::Main() {      int DiskThread::Main() {
211          dmsg(3,("Disk thread running\n"));          dmsg(3,("Disk thread running\n"));
212          while (true) {          while (true) {
213                pthread_testcancel(); // mandatory for OSX
214              IsIdle = true; // will be set to false if a stream got filled              IsIdle = true; // will be set to false if a stream got filled
215    
216              // if there are ghost streams, delete them              // if there are ghost streams, delete them
# Line 231  namespace LinuxSampler { namespace gig { Line 236  namespace LinuxSampler { namespace gig {
236              }              }
237    
238              // if there are deletion commands, delete those streams              // if there are deletion commands, delete those streams
239              while (Stream::UnusedStreams < Streams && DeletionQueue->read_space() > 0) {              while (Stream::UnusedStreams < Stream::TotalStreams && DeletionQueue->read_space() > 0) {
240                  delete_command_t command;                  delete_command_t command;
241                  DeletionQueue->pop(&command);                  DeletionQueue->pop(&command);
242                  DeleteStream(command);                  DeleteStream(command);
# Line 335  namespace LinuxSampler { namespace gig { Line 340  namespace LinuxSampler { namespace gig {
340    
341      /// order ID Generator      /// order ID Generator
342      Stream::OrderID_t DiskThread::CreateOrderID() {      Stream::OrderID_t DiskThread::CreateOrderID() {
343          static uint32_t counter = 0;          static Stream::OrderID_t counter(0);
344          for (int i = 0; i < MAX_INPUT_STREAMS; i++) {          for (int i = 0; i < MAX_INPUT_STREAMS; i++) {
345              if (counter == MAX_INPUT_STREAMS) counter = 1; // we use '0' as 'invalid order' only, so we skip 0              if (counter == MAX_INPUT_STREAMS) counter = 1; // we use '0' as 'invalid order' only, so we skip 0
346              else                              counter++;              else                              counter++;

Legend:
Removed from v.53  
changed lines
  Added in v.361

  ViewVC Help
Powered by ViewVC