mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-21 04:56:13 +02:00
ogg rate, 32bit rate
git-svn-id: svn://elaine/murooma/trunk@288 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
983ded3d29
commit
831f07a657
4 changed files with 14 additions and 23 deletions
|
@ -1,6 +1,7 @@
|
|||
#ifndef TIME_PROVIDER_H
|
||||
#define TIME_PROVIDER_H
|
||||
|
||||
#include <atomic>
|
||||
#include "doubleBuffer.h"
|
||||
|
||||
class TimeProvider
|
||||
|
@ -18,15 +19,12 @@ public:
|
|||
long getDiffToServerMs();
|
||||
|
||||
private:
|
||||
TimeProvider(); // Constructor? (the {} brackets) are needed here.
|
||||
// Dont forget to declare these two. You want to make sure they
|
||||
// are unaccessable otherwise you may accidently get copies of
|
||||
// your singleton appearing.
|
||||
TimeProvider(TimeProvider const&); // Don't Implement
|
||||
TimeProvider();
|
||||
TimeProvider(TimeProvider const&); // Don't Implement
|
||||
void operator=(TimeProvider const&); // Don't implement
|
||||
|
||||
DoubleBuffer<long> diffBuffer;
|
||||
long diffToServer;
|
||||
std::atomic<long> diffToServer;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ SampleFormat::SampleFormat(const std::string& format) : BaseMessage(message_type
|
|||
}
|
||||
|
||||
|
||||
SampleFormat::SampleFormat(uint16_t sampleRate, uint16_t bitsPerSample, uint16_t channelCount) : BaseMessage(message_type::sampleformat)
|
||||
SampleFormat::SampleFormat(uint32_t sampleRate, uint16_t bitsPerSample, uint16_t channelCount) : BaseMessage(message_type::sampleformat)
|
||||
{
|
||||
setFormat(sampleRate, bitsPerSample, channelCount);
|
||||
}
|
||||
|
@ -28,13 +28,13 @@ void SampleFormat::setFormat(const std::string& format)
|
|||
boost::split(strs, format, boost::is_any_of(":"));
|
||||
if (strs.size() == 3)
|
||||
setFormat(
|
||||
boost::lexical_cast<uint16_t>(strs[0]),
|
||||
boost::lexical_cast<uint32_t>(strs[0]),
|
||||
boost::lexical_cast<uint16_t>(strs[1]),
|
||||
boost::lexical_cast<uint16_t>(strs[2]));
|
||||
}
|
||||
|
||||
|
||||
void SampleFormat::setFormat(uint16_t rate, uint16_t bits, uint16_t channels)
|
||||
void SampleFormat::setFormat(uint32_t rate, uint16_t bits, uint16_t channels)
|
||||
{
|
||||
this->rate = rate;
|
||||
this->bits = bits;
|
||||
|
|
|
@ -10,12 +10,12 @@ class SampleFormat : public BaseMessage
|
|||
public:
|
||||
SampleFormat();
|
||||
SampleFormat(const std::string& format);
|
||||
SampleFormat(uint16_t rate, uint16_t bits, uint16_t channels);
|
||||
SampleFormat(uint32_t rate, uint16_t bits, uint16_t channels);
|
||||
|
||||
void setFormat(const std::string& format);
|
||||
void setFormat(uint16_t rate, uint16_t bits, uint16_t channels);
|
||||
void setFormat(uint32_t rate, uint16_t bits, uint16_t channels);
|
||||
|
||||
uint16_t rate;
|
||||
uint32_t rate;
|
||||
uint16_t bits;
|
||||
uint16_t channels;
|
||||
|
||||
|
@ -29,7 +29,7 @@ public:
|
|||
|
||||
virtual void read(std::istream& stream)
|
||||
{
|
||||
stream.read(reinterpret_cast<char *>(&rate), sizeof(uint16_t));
|
||||
stream.read(reinterpret_cast<char *>(&rate), sizeof(uint32_t));
|
||||
stream.read(reinterpret_cast<char *>(&bits), sizeof(uint16_t));
|
||||
stream.read(reinterpret_cast<char *>(&channels), sizeof(uint16_t));
|
||||
stream.read(reinterpret_cast<char *>(&sampleSize), sizeof(uint16_t));
|
||||
|
@ -38,26 +38,19 @@ public:
|
|||
|
||||
virtual uint32_t getSize()
|
||||
{
|
||||
return 5*sizeof(int16_t);
|
||||
return sizeof(int32_t) + 4*sizeof(int16_t);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void doserialize(std::ostream& stream)
|
||||
{
|
||||
stream.write(reinterpret_cast<char *>(&rate), sizeof(uint16_t));
|
||||
stream.write(reinterpret_cast<char *>(&rate), sizeof(uint32_t));
|
||||
stream.write(reinterpret_cast<char *>(&bits), sizeof(uint16_t));
|
||||
stream.write(reinterpret_cast<char *>(&channels), sizeof(uint16_t));
|
||||
stream.write(reinterpret_cast<char *>(&sampleSize), sizeof(uint16_t));
|
||||
stream.write(reinterpret_cast<char *>(&frameSize), sizeof(uint16_t));
|
||||
}
|
||||
|
||||
/*private:
|
||||
uint16_t rate_;
|
||||
uint16_t bits_;
|
||||
uint16_t channels_;
|
||||
uint16_t bytes_;
|
||||
uint16_t frameSize_;
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ double OggEncoder::encode(PcmChunk* chunk)
|
|||
res = os.granulepos;
|
||||
else
|
||||
res = os.granulepos - lastGranulepos;
|
||||
res /= 48.;
|
||||
res /= (sampleFormat.rate / 1000.);
|
||||
lastGranulepos = os.granulepos;
|
||||
chunk->payload = (char*)realloc(chunk->payload, pos);
|
||||
chunk->payloadSize = pos;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue