/[svn]/linuxsampler/trunk/src/engines/gig/Stream.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/gig/Stream.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 56 by schoenebeck, Tue Apr 27 09:21:58 2004 UTC revision 393 by persson, Sun Feb 20 12:30:36 2005 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   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  *   *   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  *   *   it under the terms of the GNU General Public License as published by  *
# Line 25  Line 26 
26  namespace LinuxSampler { namespace gig {  namespace LinuxSampler { namespace gig {
27    
28      uint Stream::UnusedStreams = 0;      uint Stream::UnusedStreams = 0;
29        uint Stream::TotalStreams = 0;
30    
31      /// Returns number of refilled sample points or a value < 0 on error.      /// Returns number of refilled sample points or a value < 0 on error.
32      int Stream::ReadAhead(unsigned long SampleCount) {      int Stream::ReadAhead(unsigned long SampleCount) {
# Line 40  namespace LinuxSampler { namespace gig { Line 42  namespace LinuxSampler { namespace gig {
42    
43          // refill the disk stream buffer          // refill the disk stream buffer
44          if (this->DoLoop) { // honor looping          if (this->DoLoop) { // honor looping
45              total_readsamples  = pSample->ReadAndLoop(pBuf, samplestoread, &this->PlaybackState);              total_readsamples  = pSample->ReadAndLoop(pBuf, samplestoread, &this->PlaybackState, pDecompressionBuffer);
46              endofsamplereached = (this->PlaybackState.position >= pSample->SamplesTotal);              endofsamplereached = (this->PlaybackState.position >= pSample->SamplesTotal);
47              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));
48          }          }
# Line 49  namespace LinuxSampler { namespace gig { Line 51  namespace LinuxSampler { namespace gig {
51              pSample->SetPos(this->SampleOffset); // recover old position              pSample->SetPos(this->SampleOffset); // recover old position
52    
53              do {              do {
54                  readsamples        = pSample->Read(&pBuf[total_readsamples * pSample->Channels], samplestoread);                  readsamples        = pSample->Read(&pBuf[total_readsamples * pSample->Channels], samplestoread, pDecompressionBuffer);
55                  samplestoread     -= readsamples;                  samplestoread     -= readsamples;
56                  total_readsamples += readsamples;                  total_readsamples += readsamples;
57              } while (samplestoread && readsamples > 0);              } while (samplestoread && readsamples > 0);
# Line 73  namespace LinuxSampler { namespace gig { Line 75  namespace LinuxSampler { namespace gig {
75      }      }
76    
77      void Stream::WriteSilence(unsigned long SilenceSampleWords) {      void Stream::WriteSilence(unsigned long SilenceSampleWords) {
78          memset(pRingBuffer->get_write_ptr(), 0, SilenceSampleWords);          memset(pRingBuffer->get_write_ptr(), 0, SilenceSampleWords * 2);
79          pRingBuffer->increment_write_ptr_with_wrap(SilenceSampleWords);          pRingBuffer->increment_write_ptr_with_wrap(SilenceSampleWords * 2);
80      }      }
81    
82      Stream::Stream(uint BufferSize, uint BufferWrapElements) {      Stream::Stream( ::gig::buffer_t* pDecompressionBuffer, uint BufferSize, uint BufferWrapElements) {
83          this->pExportReference               = NULL;          this->pExportReference       = NULL;
84          this->State                          = state_unused;          this->State                  = state_unused;
85          this->hThis                          = 0;          this->hThis                  = 0;
86          this->pSample                        = NULL;          this->pSample                = NULL;
87          this->SampleOffset                   = 0;          this->SampleOffset           = 0;
88          this->PlaybackState.position         = 0;          this->PlaybackState.position = 0;
89          this->PlaybackState.reverse          = false;          this->PlaybackState.reverse  = false;
90          this->pRingBuffer                    = new RingBuffer<sample_t>(BufferSize, BufferWrapElements);          this->pRingBuffer            = new RingBuffer<sample_t>(BufferSize, BufferWrapElements);
91            this->pDecompressionBuffer   = pDecompressionBuffer;
92          UnusedStreams++;          UnusedStreams++;
93            TotalStreams++;
94      }      }
95    
96      Stream::~Stream() {      Stream::~Stream() {
97          Reset();          Reset();
98          if (pRingBuffer) delete pRingBuffer;          if (pRingBuffer) delete pRingBuffer;
99            UnusedStreams--;
100            TotalStreams--;
101      }      }
102    
103      /// Called by disk thread to activate the disk stream.      /// Called by disk thread to activate the disk stream.

Legend:
Removed from v.56  
changed lines
  Added in v.393

  ViewVC Help
Powered by ViewVC