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

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

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

revision 53 by schoenebeck, Mon Apr 26 17:15:51 2004 UTC revision 3052 by schoenebeck, Wed Dec 14 17:34:54 2016 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     *   Copyright (C) 2005-2009 Christian Schoenebeck                         *
7     *   Copyright (C) 2009 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 21  Line 23 
23   ***************************************************************************/   ***************************************************************************/
24    
25  #ifndef __LS_GIG_DISKTHREAD_H__  #ifndef __LS_GIG_DISKTHREAD_H__
26  #define __LS_GIG_DISKTHREAD_H__  #define __LS_GIG_DISKTHREAD_H__
27    
28  #include "../../common/global.h"  #include "../InstrumentManagerBase.h"
29    #include "../common/DiskThreadBase.h"
30  #if DEBUG_HEADERS  #include "InstrumentResourceManager.h"
31  # warning DiskThread.h included  
32  #endif // DEBUG_HEADERS  #if AC_APPLE_UNIVERSAL_BUILD
33    # include <libgig/gig.h>
34  #define REFILL_STREAMS_PER_RUN          4       ///< number of streams that should be refilled with each disk thread cycle  #else
35  #define MIN_REFILL_SIZE                 1024    ///< if no buffer was filled up more than this bottom limit, the disk thread will go to sleep  # include <gig.h>
36  #define MAX_REFILL_SIZE                 65536   ///< maximum of samples a buffer should be refilled in one cycle (256kB, as 16 bit stereo)  #endif
 #define STREAM_BUFFER_SIZE              131072  ///< the diskstream ringbuffer size (256kB as sample_t is 16bit)  
 #define MAX_INPUT_STREAMS               100     ///< number of streams that should be allocated  
   
 #include "../../common/Thread.h"  
 #include "../../common/RingBuffer.h"  
 #include "Stream.h"  
 #include "Voice.h"  
37    
38  namespace LinuxSampler { namespace gig {  namespace LinuxSampler { namespace gig {
39    
40      int CompareStreamWriteSpace(const void* a, const void* b);      class DiskThread: public LinuxSampler::DiskThreadBase< ::gig::DimensionRegion, InstrumentResourceManager> {
41            protected:
42                ::gig::buffer_t DecompressionBuffer; ///< Used for thread safe streaming.
43    
44      class DiskThread : public Thread {              virtual LinuxSampler::Stream* CreateStream(long BufferSize, uint BufferWrapElements);
         public:  
             // Methods  
             DiskThread(uint BufferWrapElements);  
            ~DiskThread();  
             void    Reset();  
             String  GetBufferFillBytes();  
             String  GetBufferFillPercentage();  
             int     OrderNewStream(Stream::reference_t* pStreamRef, ::gig::Sample* pSample, unsigned long SampleOffset, bool DoLoop);  
             int     OrderDeletionOfStream(Stream::reference_t* pStreamRef);  
             Stream* AskForCreatedStream(Stream::OrderID_t StreamOrderID);  
   
             // the number of streams currently in usage  
             // printed on the console the main thread (along with the active voice count)  
             int ActiveStreamCount;  
             int ActiveStreamCountMax;  
45    
46          protected:              virtual void LaunchStream (
47              int Main(); ///< Implementation of virtual method from class Thread                  LinuxSampler::Stream*    pStream,
48          private:                  Stream::Handle           hStream,
49              // Private Types                  Stream::reference_t*     pExportReference,
50              struct create_command_t {                  ::gig::DimensionRegion*  pRgn,
51                  Stream::OrderID_t    OrderID;                  unsigned long            SampleOffset,
52                  Stream::Handle       hStream;                  bool                     DoLoop
53                  Stream::reference_t* pStreamRef;              );
54                  ::gig::Sample*       pSample;  
55                  unsigned long        SampleOffset;          public:
56                  bool                 DoLoop;              DiskThread(int MaxStreams, uint BufferWrapElements, InstrumentResourceManager* pInstruments);
57              };              virtual ~DiskThread();
             struct delete_command_t {  
                 Stream*           pStream;  
                 Stream::Handle    hStream;  
                 Stream::OrderID_t OrderID;  
             };  
   
             // Attributes  
             bool                           IsIdle;  
             uint                           Streams;  
             RingBuffer<create_command_t>*  CreationQueue;                          ///< Contains commands to create streams  
             RingBuffer<delete_command_t>*  DeletionQueue;                          ///< Contains commands to delete streams  
             RingBuffer<Stream::Handle>*    GhostQueue;                             ///< Contains handles to streams that are not used anymore and weren't deletable immediately  
             unsigned int                   RefillStreamsPerRun;                    ///< How many streams should be refilled in each loop run  
             Stream*                        pStreams[MAX_INPUT_STREAMS];            ///< Contains all disk streams (wether used or unused)  
             Stream*                        pCreatedStreams[MAX_INPUT_STREAMS + 1]; ///< This is where the voice (audio thread) picks up it's meanwhile hopefully created disk stream.  
             static Stream*                 SLOT_RESERVED;                          ///< This value is used to mark an entry in pCreatedStreams[] as reserved.  
   
             // Methods  
             void                           CreateStream(create_command_t& Command);  
             void                           DeleteStream(delete_command_t& Command);  
             void                           RefillStreams();  
             Stream::Handle                 CreateHandle();  
             Stream::OrderID_t              CreateOrderID();  
58      };      };
59    
60    
61  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig
62    
63  #endif // __LS_GIG_DISKTHREAD_H__  #endif  /* __LS_GIG_STREAM_H__ */
64    

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

  ViewVC Help
Powered by ViewVC