35 |
if (!SampleCount) return 0; |
if (!SampleCount) return 0; |
36 |
if (!pRingBuffer->write_space()) return 0; |
if (!pRingBuffer->write_space()) return 0; |
37 |
|
|
38 |
|
::gig::Sample* pSample = pDimRgn->pSample; |
39 |
long total_readsamples = 0, readsamples = 0; |
long total_readsamples = 0, readsamples = 0; |
40 |
long samplestoread = SampleCount / pSample->Channels; |
long samplestoread = SampleCount / pSample->Channels; |
41 |
sample_t* pBuf = pRingBuffer->get_write_ptr(); |
sample_t* pBuf = pRingBuffer->get_write_ptr(); |
43 |
|
|
44 |
// refill the disk stream buffer |
// refill the disk stream buffer |
45 |
if (this->DoLoop) { // honor looping |
if (this->DoLoop) { // honor looping |
46 |
total_readsamples = pSample->ReadAndLoop(pBuf, samplestoread, &this->PlaybackState, pDecompressionBuffer); |
total_readsamples = pSample->ReadAndLoop(pBuf, samplestoread, &this->PlaybackState, pDimRgn, pDecompressionBuffer); |
47 |
endofsamplereached = (this->PlaybackState.position >= pSample->SamplesTotal); |
endofsamplereached = (this->PlaybackState.position >= pSample->SamplesTotal); |
48 |
dmsg(5,("Refilled stream %d with %d (SamplePos: %d)", this->hThis, total_readsamples, this->PlaybackState.position)); |
dmsg(5,("Refilled stream %d with %d (SamplePos: %d)", this->hThis, total_readsamples, this->PlaybackState.position)); |
49 |
} |
} |
84 |
this->pExportReference = NULL; |
this->pExportReference = NULL; |
85 |
this->State = state_unused; |
this->State = state_unused; |
86 |
this->hThis = 0; |
this->hThis = 0; |
87 |
this->pSample = NULL; |
this->pDimRgn = NULL; |
88 |
this->SampleOffset = 0; |
this->SampleOffset = 0; |
89 |
this->PlaybackState.position = 0; |
this->PlaybackState.position = 0; |
90 |
this->PlaybackState.reverse = false; |
this->PlaybackState.reverse = false; |
102 |
} |
} |
103 |
|
|
104 |
/// Called by disk thread to activate the disk stream. |
/// Called by disk thread to activate the disk stream. |
105 |
void Stream::Launch(Stream::Handle hStream, reference_t* pExportReference, ::gig::Sample* pSample, unsigned long SampleOffset, bool DoLoop) { |
void Stream::Launch(Stream::Handle hStream, reference_t* pExportReference, ::gig::DimensionRegion* pDimRgn, unsigned long SampleOffset, bool DoLoop) { |
106 |
UnusedStreams--; |
UnusedStreams--; |
107 |
this->pExportReference = pExportReference; |
this->pExportReference = pExportReference; |
108 |
this->hThis = hStream; |
this->hThis = hStream; |
109 |
this->pSample = pSample; |
this->pDimRgn = pDimRgn; |
110 |
this->SampleOffset = SampleOffset; |
this->SampleOffset = SampleOffset; |
111 |
this->PlaybackState.position = SampleOffset; |
this->PlaybackState.position = SampleOffset; |
112 |
this->PlaybackState.reverse = false; |
this->PlaybackState.reverse = false; |
113 |
this->PlaybackState.loop_cycles_left = pSample->LoopPlayCount; |
this->PlaybackState.loop_cycles_left = pDimRgn->pSample->LoopPlayCount; |
114 |
this->DoLoop = DoLoop; |
this->DoLoop = DoLoop; |
115 |
SetState(state_active); |
SetState(state_active); |
116 |
} |
} |