Skip to content

Events type is bytes, not bytearray #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,15 @@ void Decoder::decode_bytes(
if (decoder) {
decoder->setTimeBase(timeBase);
decoder->setTimeMultiplier(1); // report in usecs instead of nanoseconds
const size_t bufSize = PyByteArray_GET_SIZE(events.ptr());
// for some reason this returns a bad pointer
// const uint8_t *buf = reinterpret_cast<uint8_t *>(PyByteArray_AsString(events.ptr()));
// TODO(Bernd): avoid the memory copy here
const std::string foo(events); // creates unnecessary copy!
delete cdEvents_; // in case events have not been picked up
cdEvents_ = new std::vector<EventCD>();
delete extTrigEvents_; // in case events have not been picked up
extTrigEvents_ = new std::vector<EventExtTrig>();
// TODO(Bernd): use hack here to avoid initializing the memory
cdEvents_->reserve(maxSizeCD_);
extTrigEvents_->reserve(maxSizeExtTrig_);
const uint8_t * buf = reinterpret_cast<const uint8_t *>(&foo[0]);
decoder->decode(buf, bufSize, this);
const uint8_t * buf = reinterpret_cast<const uint8_t *>(PyBytes_AsString(events.ptr()));
decoder->decode(buf, PyBytes_Size(events.ptr()), this);
}
}

Expand Down