A2B: Fix get & set with upstream direction
parent
cb22e622b3
commit
16b60d5ca0
|
|
@ -59,7 +59,7 @@ size_t A2BMessage::getSampleOffset(Direction dir, uint8_t channel, size_t frame)
|
||||||
size_t sampleOffset = static_cast<size_t>(frameSize * frame + 2 * channel * getBytesPerChannel());
|
size_t sampleOffset = static_cast<size_t>(frameSize * frame + 2 * channel * getBytesPerChannel());
|
||||||
|
|
||||||
if(dir == Direction::Upstream) {
|
if(dir == Direction::Upstream) {
|
||||||
sampleOffset++;
|
sampleOffset += getBytesPerChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
return sampleOffset;
|
return sampleOffset;
|
||||||
|
|
@ -152,7 +152,6 @@ PCMSample A2BMessage::getChannelSample(Direction dir, uint8_t channel, size_t fr
|
||||||
void A2BMessage::setChannelSample(Direction dir, uint8_t channel, size_t frame, PCMSample sampleToSet, PCMType pcmType) {
|
void A2BMessage::setChannelSample(Direction dir, uint8_t channel, size_t frame, PCMSample sampleToSet, PCMType pcmType) {
|
||||||
|
|
||||||
size_t sampleOffset = getSampleOffset(dir, channel, frame);
|
size_t sampleOffset = getSampleOffset(dir, channel, frame);
|
||||||
uint8_t* audioData = data.data();
|
|
||||||
uint32_t& uSample = *reinterpret_cast<uint32_t*>(&sampleToSet);
|
uint32_t& uSample = *reinterpret_cast<uint32_t*>(&sampleToSet);
|
||||||
|
|
||||||
// Align the bytes towards the most significant bit by multiplying using
|
// Align the bytes towards the most significant bit by multiplying using
|
||||||
|
|
@ -168,10 +167,10 @@ void A2BMessage::setChannelSample(Direction dir, uint8_t channel, size_t frame,
|
||||||
|
|
||||||
if(channelSize16) {
|
if(channelSize16) {
|
||||||
// Read the 2 most significant bytes of the sample
|
// Read the 2 most significant bytes of the sample
|
||||||
SAMPLE_TO_BYTES_16(audioData, sampleOffset, uSample)
|
SAMPLE_TO_BYTES_16(data, sampleOffset, uSample)
|
||||||
} else {
|
} else {
|
||||||
// Read the entire sample
|
// Read the entire sample
|
||||||
SAMPLE_TO_BYTES_32(audioData, sampleOffset, uSample);
|
SAMPLE_TO_BYTES_32(data, sampleOffset, uSample);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,21 @@ TEST_F(A2BEncoderDecoderTest, PacketEncoderTest)
|
||||||
|
|
||||||
packetEncoder->encode(*packetizer, bytestream, messagePtr);
|
packetEncoder->encode(*packetizer, bytestream, messagePtr);
|
||||||
EXPECT_EQ(bytestream, testBytes);
|
EXPECT_EQ(bytestream, testBytes);
|
||||||
|
|
||||||
|
message.setChannelSample(
|
||||||
|
icsneo::A2BMessage::Direction::Upstream,
|
||||||
|
static_cast<uint8_t>(1u),
|
||||||
|
0u,
|
||||||
|
-102,
|
||||||
|
icsneo::PCMType::L16
|
||||||
|
);
|
||||||
|
|
||||||
|
EXPECT_EQ(message.getChannelSample(
|
||||||
|
icsneo::A2BMessage::Direction::Upstream,
|
||||||
|
static_cast<uint8_t>(1u),
|
||||||
|
0u,
|
||||||
|
icsneo::PCMType::L16
|
||||||
|
), -102);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(A2BEncoderDecoderTest, PacketDecoderTest)
|
TEST_F(A2BEncoderDecoderTest, PacketDecoderTest)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue