/[svn]/linuxsampler/tags/v0_1_0/src/diskthread.h
ViewVC logotype

Annotation of /linuxsampler/tags/v0_1_0/src/diskthread.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 41 - (hide annotations) (download) (as text)
Wed Mar 31 10:28:42 2004 UTC (20 years, 2 months ago) by schoenebeck
Original Path: linuxsampler/trunk/src/diskthread.h
File MIME type: text/x-c++hdr
File size: 5207 byte(s)
removed unnecessary dependencies

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

  ViewVC Help
Powered by ViewVC