mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-24 11:57:37 +02:00
added start function to wireChunk
This commit is contained in:
parent
d51cb125fc
commit
063ed462f9
3 changed files with 24 additions and 19 deletions
|
@ -27,17 +27,17 @@ using namespace std;
|
|||
namespace msg
|
||||
{
|
||||
|
||||
PcmChunk::PcmChunk(const SampleFormat& sampleFormat, size_t ms) : WireChunk(sampleFormat.rate*sampleFormat.frameSize*ms / 1000), format(sampleFormat), idx(0)
|
||||
PcmChunk::PcmChunk(const SampleFormat& sampleFormat, size_t ms) : WireChunk(sampleFormat.rate*sampleFormat.frameSize*ms / 1000), format(sampleFormat), idx_(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PcmChunk::PcmChunk(const PcmChunk& pcmChunk) : WireChunk(pcmChunk), format(pcmChunk.format), idx(0)
|
||||
PcmChunk::PcmChunk(const PcmChunk& pcmChunk) : WireChunk(pcmChunk), format(pcmChunk.format), idx_(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PcmChunk::PcmChunk() : WireChunk(), idx(0)
|
||||
PcmChunk::PcmChunk() : WireChunk(), idx_(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -50,12 +50,12 @@ PcmChunk::~PcmChunk()
|
|||
|
||||
int PcmChunk::seek(int frames)
|
||||
{
|
||||
idx += frames;
|
||||
if (idx > getFrameCount())
|
||||
idx = getFrameCount();
|
||||
if (idx < 0)
|
||||
idx = 0;
|
||||
return idx;
|
||||
idx_ += frames;
|
||||
if (idx_ > getFrameCount())
|
||||
idx_ = getFrameCount();
|
||||
if (idx_ < 0)
|
||||
idx_ = 0;
|
||||
return idx_;
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,14 +63,14 @@ int PcmChunk::readFrames(void* outputBuffer, size_t frameCount)
|
|||
{
|
||||
//logd << "read: " << frameCount << ", total: " << (wireChunk->length / format.frameSize) << ", idx: " << idx;// << std::endl;
|
||||
int result = frameCount;
|
||||
if (idx + frameCount > (payloadSize / format.frameSize))
|
||||
result = (payloadSize / format.frameSize) - idx;
|
||||
if (idx_ + frameCount > (payloadSize / format.frameSize))
|
||||
result = (payloadSize / format.frameSize) - idx_;
|
||||
|
||||
//logd << ", from: " << format.frameSize*idx << ", to: " << format.frameSize*idx + format.frameSize*result;
|
||||
if (outputBuffer != NULL)
|
||||
memcpy((char*)outputBuffer, (char*)(payload) + format.frameSize*idx, format.frameSize*result);
|
||||
memcpy((char*)outputBuffer, (char*)(payload) + format.frameSize*idx_, format.frameSize*result);
|
||||
|
||||
idx += result;
|
||||
idx_ += result;
|
||||
//logd << ", new idx: " << idx << ", result: " << result << ", wireChunk->length: " << wireChunk->length << ", format.frameSize: " << format.frameSize << "\n";//std::endl;
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue