36 |
#include "global.h" |
#include "global.h" |
37 |
#include "ringbuffer.h" |
#include "ringbuffer.h" |
38 |
#include "gig.h" |
#include "gig.h" |
39 |
|
|
|
#define STREAM_END_SILENCE_SAMPLES |
|
40 |
class Stream { |
class Stream { |
41 |
public: |
public: |
42 |
// Member Types |
// Member Types |
100 |
inline static uint GetUnusedStreams() { return UnusedStreams; } |
inline static uint GetUnusedStreams() { return UnusedStreams; } |
101 |
protected: |
protected: |
102 |
// Methods |
// Methods |
103 |
void Launch(reference_t* pExportReference, gig::Sample* pSample, unsigned long SampleOffset); |
void Launch(Stream::Handle hStream, reference_t* pExportReference, gig::Sample* pSample, unsigned long SampleOffset); |
104 |
inline void Kill() { pExportReference = NULL; Reset(); } ///< Will be called by disk thread after a 'deletion' command from the audio thread (within the voice class) |
inline void Kill() { pExportReference = NULL; Reset(); } ///< Will be called by disk thread after a 'deletion' command from the audio thread (within the voice class) |
105 |
inline Stream::Handle GetHandle() { |
inline Stream::Handle GetHandle() { return hThis; } |
106 |
return (pExportReference) ? pExportReference->hStream : 0; |
inline Stream::state_t GetState() { return State; } |
|
} |
|
|
inline Stream::state_t GetState() { return State; } |
|
107 |
friend class DiskThread; // only the disk thread should be able to launch and most important kill a disk stream to avoid race conditions |
friend class DiskThread; // only the disk thread should be able to launch and most important kill a disk stream to avoid race conditions |
108 |
private: |
private: |
109 |
// Attributes |
// Attributes |
110 |
reference_t* pExportReference; |
reference_t* pExportReference; |
111 |
state_t State; |
state_t State; |
112 |
|
Stream::Handle hThis; |
113 |
gig::Sample* pSample; |
gig::Sample* pSample; |
114 |
unsigned long SampleOffset; |
unsigned long SampleOffset; |
115 |
RingBuffer<sample_t>* pRingBuffer; |
RingBuffer<sample_t>* pRingBuffer; |
121 |
inline void Reset() { |
inline void Reset() { |
122 |
pSample = NULL; |
pSample = NULL; |
123 |
SampleOffset = 0; |
SampleOffset = 0; |
124 |
|
hThis = 0; |
125 |
pRingBuffer->init(); // reset ringbuffer |
pRingBuffer->init(); // reset ringbuffer |
126 |
if (State != state_unused) { |
if (State != state_unused) { |
127 |
// we can't do 'SetPos(state_unused)' here, due to possible race conditions) |
// we can't do 'SetPos(state_unused)' here, due to possible race conditions) |