encoderd: fix crash when filename is null (#29748)

Use publish_name for thread name and debugging messages
pull/29757/head
Kacper Rączy 2 years ago committed by GitHub
parent a18e97e954
commit 0bda43d71c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      system/loggerd/encoder/ffmpeg_encoder.cc
  2. 6
      system/loggerd/encoder/v4l_encoder.cc
  3. 1
      system/loggerd/loggerd.cc

@ -135,7 +135,7 @@ int FfmpegEncoder::encode_frame(VisionBuf* buf, VisionIpcBufExtra *extra) {
} }
if (env_debug_encoder) { if (env_debug_encoder) {
printf("%20s got %8d bytes flags %8x idx %4d id %8d\n", encoder_info.filename, pkt.size, pkt.flags, counter, extra->frame_id); printf("%20s got %8d bytes flags %8x idx %4d id %8d\n", encoder_info.publish_name, pkt.size, pkt.flags, counter, extra->frame_id);
} }
publisher_publish(this, segment_num, counter, *extra, publisher_publish(this, segment_num, counter, *extra,

@ -75,7 +75,7 @@ static void request_buffers(int fd, v4l2_buf_type buf_type, unsigned int count)
} }
void V4LEncoder::dequeue_handler(V4LEncoder *e) { void V4LEncoder::dequeue_handler(V4LEncoder *e) {
std::string dequeue_thread_name = "dq-"+std::string(e->encoder_info.filename); std::string dequeue_thread_name = "dq-"+std::string(e->encoder_info.publish_name);
util::set_thread_name(dequeue_thread_name.c_str()); util::set_thread_name(dequeue_thread_name.c_str());
e->segment_num++; e->segment_num++;
@ -105,7 +105,7 @@ void V4LEncoder::dequeue_handler(V4LEncoder *e) {
} }
if (env_debug_encoder >= 2) { if (env_debug_encoder >= 2) {
printf("%20s poll %x at %.2f ms\n", e->encoder_info.filename, pfd.revents, millis_since_boot()); printf("%20s poll %x at %.2f ms\n", e->encoder_info.publish_name, pfd.revents, millis_since_boot());
} }
int frame_id = -1; int frame_id = -1;
@ -133,7 +133,7 @@ void V4LEncoder::dequeue_handler(V4LEncoder *e) {
if (env_debug_encoder) { if (env_debug_encoder) {
printf("%20s got(%d) %6d bytes flags %8x idx %3d/%4d id %8d ts %ld lat %.2f ms (%lu frames free)\n", printf("%20s got(%d) %6d bytes flags %8x idx %3d/%4d id %8d ts %ld lat %.2f ms (%lu frames free)\n",
e->encoder_info.filename, index, bytesused, flags, e->segment_num, idx, frame_id, ts, millis_since_boot()-(ts/1000.), e->free_buf_in.size()); e->encoder_info.publish_name, index, bytesused, flags, e->segment_num, idx, frame_id, ts, millis_since_boot()-(ts/1000.), e->free_buf_in.size());
} }
// requeue the buffer // requeue the buffer

@ -116,6 +116,7 @@ int handle_encoder_msg(LoggerdState *s, Message *msg, std::string &name, struct
} }
// if we aren't actually recording, don't create the writer // if we aren't actually recording, don't create the writer
if (encoder_info.record) { if (encoder_info.record) {
assert(encoder_info.filename != NULL);
re.writer.reset(new VideoWriter(s->segment_path, re.writer.reset(new VideoWriter(s->segment_path,
encoder_info.filename, idx.getType() != cereal::EncodeIndex::Type::FULL_H_E_V_C, encoder_info.filename, idx.getType() != cereal::EncodeIndex::Type::FULL_H_E_V_C,
encoder_info.frame_width, encoder_info.frame_height, encoder_info.fps, idx.getType())); encoder_info.frame_width, encoder_info.frame_height, encoder_info.fps, idx.getType()));

Loading…
Cancel
Save