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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 554 - (show annotations) (download) (as text)
Thu May 19 19:25:14 2005 UTC (18 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5221 byte(s)
* All compile time options are now centrally alterable as arguments to the
  ./configure script. All options are C Macros beginning with CONFIG_
  prefix and will be placed into auto generated config.h file.

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * Copyright (C) 2005 Christian Schoenebeck *
7 * *
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 #include <gig.h>
30
31 #include "../../common/Thread.h"
32 #include "../../common/RingBuffer.h"
33 #include "Stream.h"
34 #include "Voice.h"
35
36 namespace LinuxSampler { namespace gig {
37
38 int CompareStreamWriteSpace(const void* a, const void* b);
39
40 class DiskThread : public Thread {
41 public:
42 // Methods
43 DiskThread(uint BufferWrapElements);
44 virtual ~DiskThread();
45 void Reset();
46 String GetBufferFillBytes();
47 String GetBufferFillPercentage();
48 int OrderNewStream(Stream::reference_t* pStreamRef, ::gig::Sample* pSample, unsigned long SampleOffset, bool DoLoop);
49 int OrderDeletionOfStream(Stream::reference_t* pStreamRef);
50 Stream* AskForCreatedStream(Stream::OrderID_t StreamOrderID);
51
52 // the number of streams currently in usage
53 // printed on the console the main thread (along with the active voice count)
54 int ActiveStreamCount;
55 int ActiveStreamCountMax;
56
57 protected:
58 ::gig::buffer_t DecompressionBuffer; ///< Used for thread safe streaming.
59
60 int Main(); ///< Implementation of virtual method from class Thread
61
62 friend class Stream;
63 private:
64 // Private Types
65 struct create_command_t {
66 Stream::OrderID_t OrderID;
67 Stream::Handle hStream;
68 Stream::reference_t* pStreamRef;
69 ::gig::Sample* pSample;
70 unsigned long SampleOffset;
71 bool DoLoop;
72 };
73 struct delete_command_t {
74 Stream* pStream;
75 Stream::Handle hStream;
76 Stream::OrderID_t OrderID;
77 };
78
79 // Attributes
80 bool IsIdle;
81 uint Streams;
82 RingBuffer<create_command_t>* CreationQueue; ///< Contains commands to create streams
83 RingBuffer<delete_command_t>* DeletionQueue; ///< Contains commands to delete streams
84 RingBuffer<Stream::Handle>* GhostQueue; ///< Contains handles to streams that are not used anymore and weren't deletable immediately
85 unsigned int RefillStreamsPerRun; ///< How many streams should be refilled in each loop run
86 Stream* pStreams[CONFIG_MAX_STREAMS]; ///< Contains all disk streams (wether used or unused)
87 Stream* pCreatedStreams[CONFIG_MAX_STREAMS + 1]; ///< This is where the voice (audio thread) picks up it's meanwhile hopefully created disk stream.
88 static Stream* SLOT_RESERVED; ///< This value is used to mark an entry in pCreatedStreams[] as reserved.
89
90 // Methods
91 void CreateStream(create_command_t& Command);
92 void DeleteStream(delete_command_t& Command);
93 void RefillStreams();
94 Stream::Handle CreateHandle();
95 Stream::OrderID_t CreateOrderID();
96 };
97
98 }} // namespace LinuxSampler::gig
99
100 #endif // __LS_GIG_DISKTHREAD_H__

  ViewVC Help
Powered by ViewVC