/[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 554 by schoenebeck, Thu May 19 19:25:14 2005 UTC revision 1924 by persson, Sun Jun 28 16:43:38 2009 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 - 2009 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 24  Line 24 
24  #ifndef __LS_GIG_DISKTHREAD_H__  #ifndef __LS_GIG_DISKTHREAD_H__
25  #define __LS_GIG_DISKTHREAD_H__  #define __LS_GIG_DISKTHREAD_H__
26    
27  #include "../../common/global.h"  #include "../../common/global_private.h"
28    
29  #include <gig.h>  #include <gig.h>
30    
31  #include "../../common/Thread.h"  #include "../../common/Thread.h"
32  #include "../../common/RingBuffer.h"  #include "../../common/RingBuffer.h"
33    #include "../../common/atomic.h"
34  #include "Stream.h"  #include "Stream.h"
35  #include "Voice.h"  #include "Voice.h"
36    
# Line 37  namespace LinuxSampler { namespace gig { Line 38  namespace LinuxSampler { namespace gig {
38    
39      int CompareStreamWriteSpace(const void* a, const void* b);      int CompareStreamWriteSpace(const void* a, const void* b);
40    
41        /** @brief Disk Reader Thread
42         *
43         * The disk reader thread is responsible for periodically refilling
44         * disk streams in parallel to the audio thread's rendering process.
45         *
46         * There is also a function for releasing parts of instruments not
47         * in use anymore (as this is not real time safe, the audio thread
48         * cannot do it directly).
49         */
50      class DiskThread : public Thread {      class DiskThread : public Thread {
51          public:          public:
52              // Methods              // Methods
53              DiskThread(uint BufferWrapElements);              DiskThread(int MaxStreams, uint BufferWrapElements, InstrumentResourceManager* pInstruments);
54              virtual ~DiskThread();              virtual ~DiskThread();
55              void    Reset();              void    Reset();
56              String  GetBufferFillBytes();              String  GetBufferFillBytes();
57              String  GetBufferFillPercentage();              String  GetBufferFillPercentage();
58              int     OrderNewStream(Stream::reference_t* pStreamRef, ::gig::Sample* pSample, unsigned long SampleOffset, bool DoLoop);              int     OrderNewStream(Stream::reference_t* pStreamRef, ::gig::DimensionRegion* pDimRgn, unsigned long SampleOffset, bool DoLoop);
59              int     OrderDeletionOfStream(Stream::reference_t* pStreamRef);              int     OrderDeletionOfStream(Stream::reference_t* pStreamRef, bool bRequestNotification = false);
60                int     OrderDeletionOfDimreg(::gig::DimensionRegion* dimreg);
61                int     OrderProgramChange(uint8_t Program, EngineChannel* pEngineChannel);
62              Stream* AskForCreatedStream(Stream::OrderID_t StreamOrderID);              Stream* AskForCreatedStream(Stream::OrderID_t StreamOrderID);
63                Stream::Handle AskForDeletedStream();
64    
65              // the number of streams currently in usage              // the number of streams currently in usage
66              // printed on the console the main thread (along with the active voice count)              // printed on the console the main thread (along with the active voice count)
67              int ActiveStreamCount;              uint GetActiveStreamCount() { return atomic_read(&ActiveStreamCount); }
68                void SetActiveStreamCount(uint Streams) { atomic_set(&ActiveStreamCount, Streams); }
69              int ActiveStreamCountMax;              int ActiveStreamCountMax;
70    
71          protected:          protected:
# Line 66  namespace LinuxSampler { namespace gig { Line 80  namespace LinuxSampler { namespace gig {
80                  Stream::OrderID_t    OrderID;                  Stream::OrderID_t    OrderID;
81                  Stream::Handle       hStream;                  Stream::Handle       hStream;
82                  Stream::reference_t* pStreamRef;                  Stream::reference_t* pStreamRef;
83                  ::gig::Sample*       pSample;                  ::gig::DimensionRegion* pDimRgn;
84                  unsigned long        SampleOffset;                  unsigned long        SampleOffset;
85                  bool                 DoLoop;                  bool                 DoLoop;
86              };              };
# Line 74  namespace LinuxSampler { namespace gig { Line 88  namespace LinuxSampler { namespace gig {
88                  Stream*           pStream;                  Stream*           pStream;
89                  Stream::Handle    hStream;                  Stream::Handle    hStream;
90                  Stream::OrderID_t OrderID;                  Stream::OrderID_t OrderID;
91                    bool              bNotify;
92                };
93                struct program_change_command_t {
94                    uint8_t Program;
95                    EngineChannel* pEngineChannel;
96              };              };
   
97              // Attributes              // Attributes
98              bool                           IsIdle;              bool                           IsIdle;
99              uint                           Streams;              uint                           Streams;
100              RingBuffer<create_command_t>*  CreationQueue;                          ///< Contains commands to create streams              RingBuffer<create_command_t,false>* CreationQueue;                      ///< Contains commands to create streams
101              RingBuffer<delete_command_t>*  DeletionQueue;                          ///< Contains commands to delete streams              RingBuffer<delete_command_t,false>* DeletionQueue;                      ///< Contains commands to delete streams
102              RingBuffer<Stream::Handle>*    GhostQueue;                             ///< Contains handles to streams that are not used anymore and weren't deletable immediately              RingBuffer<delete_command_t,false>* GhostQueue;                         ///< Contains handles to streams that are not used anymore and weren't deletable immediately
103                RingBuffer<Stream::Handle,false>    DeletionNotificationQueue;          ///< In case the original sender requested a notification for its stream deletion order, this queue will receive the handle of the respective stream once actually be deleted by the disk thread.
104                RingBuffer< ::gig::DimensionRegion*,false>* DeleteDimregQueue;          ///< Contains dimension regions that are not used anymore and should be handed back to the instrument resource manager
105                RingBuffer<program_change_command_t,false> ProgramChangeQueue;          ///< Contains requests for MIDI program change
106              unsigned int                   RefillStreamsPerRun;                    ///< How many streams should be refilled in each loop run              unsigned int                   RefillStreamsPerRun;                    ///< How many streams should be refilled in each loop run
107              Stream*                        pStreams[CONFIG_MAX_STREAMS];            ///< Contains all disk streams (wether used or unused)              Stream**                       pStreams; ///< Contains all disk streams (whether used or unused)
108              Stream*                        pCreatedStreams[CONFIG_MAX_STREAMS + 1]; ///< This is where the voice (audio thread) picks up it's meanwhile hopefully created disk stream.              Stream**                       pCreatedStreams; ///< This is where the voice (audio thread) picks up it's meanwhile hopefully created disk stream.
109              static Stream*                 SLOT_RESERVED;                          ///< This value is used to mark an entry in pCreatedStreams[] as reserved.              static Stream*                 SLOT_RESERVED;                          ///< This value is used to mark an entry in pCreatedStreams[] as reserved.
110                InstrumentResourceManager*     pInstruments;                           ///< The instrument resource manager of the engine that is using this disk thread. Used by the dimension region deletion feature.
111    
112              // Methods              // Methods
113              void                           CreateStream(create_command_t& Command);              void                           CreateStream(create_command_t& Command);
# Line 93  namespace LinuxSampler { namespace gig { Line 115  namespace LinuxSampler { namespace gig {
115              void                           RefillStreams();              void                           RefillStreams();
116              Stream::Handle                 CreateHandle();              Stream::Handle                 CreateHandle();
117              Stream::OrderID_t              CreateOrderID();              Stream::OrderID_t              CreateOrderID();
118    
119                atomic_t ActiveStreamCount;
120      };      };
121    
122  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig

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

  ViewVC Help
Powered by ViewVC