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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 505 - (hide annotations) (download) (as text)
Tue May 3 01:00:25 2005 UTC (18 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5973 byte(s)
fixed libgig include rules

1 schoenebeck 53 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5 schoenebeck 56 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 385 * Copyright (C) 2005 Christian Schoenebeck *
7 schoenebeck 53 * *
8     * 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 *
10     * the Free Software Foundation; either version 2 of the License, or *
11     * (at your option) any later version. *
12     * *
13     * This program is distributed in the hope that it will be useful, *
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16     * GNU General Public License for more details. *
17     * *
18     * You should have received a copy of the GNU General Public License *
19     * along with this program; if not, write to the Free Software *
20     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21     * MA 02111-1307 USA *
22     ***************************************************************************/
23    
24     #ifndef __LS_GIG_DISKTHREAD_H__
25     #define __LS_GIG_DISKTHREAD_H__
26    
27     #include "../../common/global.h"
28    
29     #if DEBUG_HEADERS
30     # warning DiskThread.h included
31     #endif // DEBUG_HEADERS
32    
33 schoenebeck 505 #include <gig.h>
34    
35 schoenebeck 53 #define REFILL_STREAMS_PER_RUN 4 ///< number of streams that should be refilled with each disk thread cycle
36     #define MIN_REFILL_SIZE 1024 ///< if no buffer was filled up more than this bottom limit, the disk thread will go to sleep
37     #define MAX_REFILL_SIZE 65536 ///< maximum of samples a buffer should be refilled in one cycle (256kB, as 16 bit stereo)
38    
39 letz 502
40     //#define STREAM_BUFFER_SIZE 131072 ///< the diskstream ringbuffer size (256kB as sample_t is 16bit)
41    
42     #define STREAM_BUFFER_SIZE 262144
43     //#define MAX_INPUT_STREAMS 150 ///< number of streams that should be allocated
44    
45     #define MAX_INPUT_STREAMS 90 ///< number of streams that should be allocated
46    
47    
48 schoenebeck 53 #include "../../common/Thread.h"
49     #include "../../common/RingBuffer.h"
50     #include "Stream.h"
51     #include "Voice.h"
52    
53     namespace LinuxSampler { namespace gig {
54    
55     int CompareStreamWriteSpace(const void* a, const void* b);
56    
57     class DiskThread : public Thread {
58     public:
59     // Methods
60     DiskThread(uint BufferWrapElements);
61 letz 502 virtual ~DiskThread();
62 schoenebeck 53 void Reset();
63     String GetBufferFillBytes();
64     String GetBufferFillPercentage();
65     int OrderNewStream(Stream::reference_t* pStreamRef, ::gig::Sample* pSample, unsigned long SampleOffset, bool DoLoop);
66     int OrderDeletionOfStream(Stream::reference_t* pStreamRef);
67     Stream* AskForCreatedStream(Stream::OrderID_t StreamOrderID);
68    
69     // the number of streams currently in usage
70     // printed on the console the main thread (along with the active voice count)
71     int ActiveStreamCount;
72     int ActiveStreamCountMax;
73    
74     protected:
75 schoenebeck 385 ::gig::buffer_t DecompressionBuffer; ///< Used for thread safe streaming.
76    
77 schoenebeck 53 int Main(); ///< Implementation of virtual method from class Thread
78 schoenebeck 385
79     friend class Stream;
80 schoenebeck 53 private:
81     // Private Types
82     struct create_command_t {
83     Stream::OrderID_t OrderID;
84     Stream::Handle hStream;
85     Stream::reference_t* pStreamRef;
86     ::gig::Sample* pSample;
87     unsigned long SampleOffset;
88     bool DoLoop;
89     };
90     struct delete_command_t {
91     Stream* pStream;
92     Stream::Handle hStream;
93     Stream::OrderID_t OrderID;
94     };
95    
96     // Attributes
97     bool IsIdle;
98     uint Streams;
99     RingBuffer<create_command_t>* CreationQueue; ///< Contains commands to create streams
100     RingBuffer<delete_command_t>* DeletionQueue; ///< Contains commands to delete streams
101     RingBuffer<Stream::Handle>* GhostQueue; ///< Contains handles to streams that are not used anymore and weren't deletable immediately
102     unsigned int RefillStreamsPerRun; ///< How many streams should be refilled in each loop run
103     Stream* pStreams[MAX_INPUT_STREAMS]; ///< Contains all disk streams (wether used or unused)
104     Stream* pCreatedStreams[MAX_INPUT_STREAMS + 1]; ///< This is where the voice (audio thread) picks up it's meanwhile hopefully created disk stream.
105     static Stream* SLOT_RESERVED; ///< This value is used to mark an entry in pCreatedStreams[] as reserved.
106    
107     // Methods
108     void CreateStream(create_command_t& Command);
109     void DeleteStream(delete_command_t& Command);
110     void RefillStreams();
111     Stream::Handle CreateHandle();
112     Stream::OrderID_t CreateOrderID();
113     };
114    
115     }} // namespace LinuxSampler::gig
116    
117     #endif // __LS_GIG_DISKTHREAD_H__

  ViewVC Help
Powered by ViewVC