X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fmixer.cpp;h=76ab1bab21c4c47d136160f96e93fbe40b21b3d1;hb=afd3391c734ec861d2be4f543e596ad98d6b557e;hp=465e96708c716c80302f40a7d3ad8987a7d5214e;hpb=f1d8decc4a0e0d94f83c97c4488cf3bd423951d2;p=nageru diff --git a/nageru/mixer.cpp b/nageru/mixer.cpp index 465e967..76ab1ba 100644 --- a/nageru/mixer.cpp +++ b/nageru/mixer.cpp @@ -568,6 +568,15 @@ void Mixer::configure_card(unsigned card_index, CaptureInterface *capture, CardT card->capture->set_frame_callback(bind(&Mixer::bm_frame, this, card_index, _1, _2, _3, _4, _5, _6, _7)); if (card->frame_allocator == nullptr) { card->frame_allocator.reset(new PBOFrameAllocator(pixel_format, 8 << 20, global_flags.width, global_flags.height, card_index, mjpeg_encoder.get())); // 8 MB. + } else { + // The format could have changed, but we cannot reset the allocator + // and create a new one from scratch, since there may be allocated + // frames from it that expect to call release_frame() on it. + // Instead, ask the allocator to create new frames for us and discard + // any old ones as they come back. This takes the mutex while + // allocating, but nothing should really be sending frames in there + // right now anyway (start_bm_capture() has not been called yet). + card->frame_allocator->reconfigure(pixel_format, 8 << 20, global_flags.width, global_flags.height, card_index, mjpeg_encoder.get()); } card->capture->set_video_frame_allocator(card->frame_allocator.get()); if (card->surface == nullptr) {