Skip to content
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