libcamera: control_serializer: Simplify serialization of ControlValue

Use the ControlValue::data() function to access raw data stored in the
control value and simplify serialization.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.binghm@ideasonboard.com>
This commit is contained in:
Laurent Pinchart 2020-02-16 00:03:04 +02:00
parent 44ff5a18e4
commit 5467d61925

View file

@ -146,40 +146,7 @@ size_t ControlSerializer::binarySize(const ControlList &list)
void ControlSerializer::store(const ControlValue &value, void ControlSerializer::store(const ControlValue &value,
ByteStreamBuffer &buffer) ByteStreamBuffer &buffer)
{ {
switch (value.type()) { buffer.write(value.data());
case ControlTypeBool: {
bool data = value.get<bool>();
buffer.write(&data);
break;
}
case ControlTypeByte: {
uint8_t data = value.get<uint8_t>();
buffer.write(&data);
break;
}
case ControlTypeInteger32: {
int32_t data = value.get<int32_t>();
buffer.write(&data);
break;
}
case ControlTypeInteger64: {
uint64_t data = value.get<int64_t>();
buffer.write(&data);
break;
}
case ControlTypeFloat: {
float data = value.get<float>();
buffer.write(&data);
break;
}
default:
break;
}
} }
void ControlSerializer::store(const ControlRange &range, void ControlSerializer::store(const ControlRange &range,