void MallocFrameAllocator::release_frame(Frame frame)
{
+ if (frame.overflow > 0) {
+ printf("%d bytes overflow after last (malloc) frame\n", int(frame.overflow));
+ }
unique_lock<mutex> lock(freelist_mutex);
freelist.push(unique_ptr<uint8_t[]>(frame.data));
}
uint16_t timecode = (start[1] << 8) | start[0];
if (current_video_frame.len > 0) {
+ // If format is 0x0800 (no signal), add a fake (empty) audio
+ // frame to get it out of the queue.
+ // TODO: Figure out if there are other formats that come with
+ // no audio, and treat them the same.
+ if (format == 0x0800) {
+ FrameAllocator::Frame fake_audio_frame = audio_frame_allocator->alloc_frame();
+ if (fake_audio_frame.data == nullptr) {
+ // Oh well, it's just a no-signal frame anyway.
+ printf("Couldn't allocate fake audio frame, also dropping no-signal video frame.\n");
+ current_video_frame.owner->release_frame(current_video_frame);
+ current_video_frame = video_frame_allocator->alloc_frame();
+ return;
+ }
+ queue_frame(format, timecode, fake_audio_frame, &pending_audio_frames);
+ }
//dump_frame();
queue_frame(format, timecode, current_video_frame, &pending_video_frames);
}
int bytes = end - start;
if (current_frame->len + bytes > current_frame->size) {
- printf("%d bytes overflow after last %s frame\n",
- int(current_frame->len + bytes - current_frame->size), frame_type_name);
+ current_frame->overflow = current_frame->len + bytes - current_frame->size;
+ current_frame->len = current_frame->size;
+ if (current_frame->overflow > 1048576) {
+ printf("%d bytes overflow after last %s frame\n",
+ int(current_frame->overflow), frame_type_name);
+ current_frame->overflow = 0;
+ }
//dump_frame();
} else {
if (current_frame->interleaved) {