23 |
#ifndef __DISKTHREAD_H__ |
#ifndef __DISKTHREAD_H__ |
24 |
#define __DISKTHREAD_H__ |
#define __DISKTHREAD_H__ |
25 |
|
|
26 |
#define MAX_BUF_PERCENT 0.8 |
#define REFILL_STREAMS_PER_RUN 4 ///< number of streams that should be refilled with each disk thread cycle |
27 |
#define MIN_REFILL_SIZE 1024 |
#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 |
#define MAX_REFILL_SIZE 65536 ///< maximum of samples a buffer should be refilled in one cycle (256kB, as 16 bit stereo) |
29 |
// the diskstream ringbuffer size (256kB as sample_t is 16bit) |
#define STREAM_BUFFER_SIZE 131072 ///< the diskstream ringbuffer size (256kB as sample_t is 16bit) |
30 |
#define STREAM_BUFFER_SIZE 131072 |
#define MAX_INPUT_STREAMS 100 ///< number of streams that should be allocated |
|
#define MAX_INPUT_STREAMS 100 |
|
31 |
|
|
32 |
#include <stdio.h> |
#include <stdio.h> |
33 |
#include <stdlib.h> |
#include <stdlib.h> |
61 |
private: |
private: |
62 |
// Private Types |
// Private Types |
63 |
struct create_command_t { |
struct create_command_t { |
64 |
|
Stream::OrderID_t OrderID; |
65 |
|
Stream::Handle hStream; |
66 |
Stream::reference_t* pStreamRef; |
Stream::reference_t* pStreamRef; |
67 |
gig::Sample* pSample; |
gig::Sample* pSample; |
68 |
unsigned long SampleOffset; |
unsigned long SampleOffset; |
74 |
}; |
}; |
75 |
|
|
76 |
// Attributes |
// Attributes |
77 |
bool IsIdle; |
bool IsIdle; |
78 |
uint Streams; |
uint Streams; |
79 |
RingBuffer<create_command_t>* CreationQueue; |
RingBuffer<create_command_t>* CreationQueue; ///< Contains commands to create streams |
80 |
RingBuffer<delete_command_t>* DeletionQueue; |
RingBuffer<delete_command_t>* DeletionQueue; ///< Contains commands to delete streams |
81 |
unsigned int RefillStreamsPerRun; // how many streams should be refilled in each loop run |
RingBuffer<Stream::Handle>* GhostQueue; ///< Contains handles to streams that are not used anymore and weren't deletable immediately |
82 |
Stream* pStreams[MAX_INPUT_STREAMS]; ///< Contains all disk streams (wether used or unused) |
unsigned int RefillStreamsPerRun; ///< How many streams should be refilled in each loop run |
83 |
Stream* pCreatedStreams[MAX_INPUT_STREAMS + 1]; ///< This is where the voice (audio thread) picks up it's meanwhile hopefully created disk stream. |
Stream* pStreams[MAX_INPUT_STREAMS]; ///< Contains all disk streams (wether used or unused) |
84 |
|
Stream* pCreatedStreams[MAX_INPUT_STREAMS + 1]; ///< This is where the voice (audio thread) picks up it's meanwhile hopefully created disk stream. |
85 |
|
static Stream* SLOT_RESERVED; ///< This value is used to mark an entry in pCreatedStreams[] as reserved. |
86 |
|
|
87 |
// Methods |
// Methods |
88 |
void CreateStream(create_command_t& Command); |
void CreateStream(create_command_t& Command); |
89 |
void DeleteStream(delete_command_t& Command); |
void DeleteStream(delete_command_t& Command); |
90 |
void RefillStreams(); |
void RefillStreams(); |
91 |
Stream::Handle CreateHandle(); |
Stream::Handle CreateHandle(); |
92 |
Stream::OrderID_t CreateOrderID(); |
Stream::OrderID_t CreateOrderID(); |
93 |
}; |
}; |
94 |
|
|
95 |
#endif // __DISKTHREAD_H__ |
#endif // __DISKTHREAD_H__ |