mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-09 23:26:47 +02:00
refactoring
git-svn-id: svn://elaine/murooma/trunk@328 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
611b2a6c9f
commit
c40bfda64c
35 changed files with 192 additions and 178 deletions
|
@ -8,7 +8,7 @@ using namespace std;
|
|||
using namespace chronos;
|
||||
|
||||
|
||||
Stream::Stream(const SampleFormat& sampleFormat) : format(format_), format_(sampleFormat), sleep(0), median(0), shortMedian(0), lastUpdate(0), playedFrames(0)
|
||||
Stream::Stream(const msg::SampleFormat& sampleFormat) : format(format_), format_(sampleFormat), sleep(0), median(0), shortMedian(0), lastUpdate(0), playedFrames(0)
|
||||
{
|
||||
buffer.setSize(500);
|
||||
shortBuffer.setSize(100);
|
||||
|
@ -16,8 +16,6 @@ Stream::Stream(const SampleFormat& sampleFormat) : format(format_), format_(samp
|
|||
// cardBuffer.setSize(50);
|
||||
bufferMs = msec(500);
|
||||
|
||||
playedSamples = 0;
|
||||
playedSamplesTime = time_point_hrc::min();
|
||||
/*
|
||||
48000 x
|
||||
------- = -----
|
||||
|
@ -53,11 +51,11 @@ void Stream::clearChunks()
|
|||
}
|
||||
|
||||
|
||||
void Stream::addChunk(PcmChunk* chunk)
|
||||
void Stream::addChunk(msg::PcmChunk* chunk)
|
||||
{
|
||||
while (chunks.size() * chunk->duration<chronos::msec>().count() > 10000)
|
||||
chunks.pop();
|
||||
chunks.push(shared_ptr<PcmChunk>(chunk));
|
||||
chunks.push(shared_ptr<msg::PcmChunk>(chunk));
|
||||
// cout << "new chunk: " << chunk->getDuration() << ", Chunks: " << chunks.size() << "\n";
|
||||
}
|
||||
|
||||
|
@ -174,17 +172,6 @@ void Stream::resetBuffers()
|
|||
|
||||
bool Stream::getPlayerChunk(void* outputBuffer, const chronos::usec& outputBufferDacTime, unsigned long framesPerBuffer)
|
||||
{
|
||||
/*if (playedSamplesTime == time_point_hrc::min())
|
||||
playedSamplesTime = chronos::hrc::now() + outputBufferDacTime;
|
||||
else
|
||||
{
|
||||
playedSamples += framesPerBuffer;
|
||||
chronos::msec since = std::chrono::duration_cast<msec>(chronos::hrc::now() + outputBufferDacTime - playedSamplesTime);
|
||||
if (since.count() > 0)
|
||||
cout << (double)playedSamples / (double)since.count() << "\n";
|
||||
}
|
||||
*/
|
||||
|
||||
if (outputBufferDacTime > bufferMs)
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue