mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-03 16:48:52 +02:00
made SampleFormat not inherit from BaseMessage
This commit is contained in:
parent
eed7f287fb
commit
c4094a2175
18 changed files with 25 additions and 63 deletions
|
@ -20,10 +20,7 @@
|
|||
#define SAMPLE_FORMAT_H
|
||||
|
||||
#include <string>
|
||||
#include "message.h"
|
||||
|
||||
namespace msg
|
||||
{
|
||||
|
||||
/**
|
||||
* sample and frame as defined in alsa:
|
||||
|
@ -36,7 +33,7 @@ namespace msg
|
|||
* To sustain 2x 44.1 KHz analog rate - the system must be capable of data transfer rate, in Bytes/sec:
|
||||
* Bps_rate = (num_channels) * (1 sample in bytes) * (analog_rate) = (1 frame) * (analog_rate) = ( 2 channels ) * (2 bytes/sample) * (44100 samples/sec) = 2*2*44100 = 176400 Bytes/sec (link to formula img)
|
||||
*/
|
||||
class SampleFormat : public BaseMessage
|
||||
class SampleFormat
|
||||
{
|
||||
public:
|
||||
SampleFormat();
|
||||
|
@ -72,34 +69,8 @@ public:
|
|||
{
|
||||
return (double)rate/1000000000.;
|
||||
}
|
||||
|
||||
virtual void read(std::istream& stream)
|
||||
{
|
||||
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));
|
||||
stream.read(reinterpret_cast<char *>(&frameSize), sizeof(uint16_t));
|
||||
}
|
||||
|
||||
virtual uint32_t getSize() const
|
||||
{
|
||||
return sizeof(int32_t) + 4*sizeof(int16_t);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void doserialize(std::ostream& stream) const
|
||||
{
|
||||
stream.write(reinterpret_cast<const char *>(&rate), sizeof(uint32_t));
|
||||
stream.write(reinterpret_cast<const char *>(&bits), sizeof(uint16_t));
|
||||
stream.write(reinterpret_cast<const char *>(&channels), sizeof(uint16_t));
|
||||
stream.write(reinterpret_cast<const char *>(&sampleSize), sizeof(uint16_t));
|
||||
stream.write(reinterpret_cast<const char *>(&frameSize), sizeof(uint16_t));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue