microsoft / FFmpegInterop

This is a code sample to make it easier to use FFmpeg in Windows applications.
Apache License 2.0
1.29k stars 310 forks source link

MSFT: 49931784 - Disable FFmpeg logging in release builds #311

Closed brbeec closed 5 months ago

brbeec commented 5 months ago

Why is this change being made?

FFmpegInterop.dll registers a custom FFmpeg logging callback, FmpegInteropLogging::Log(), on DLL load. However, this is not safe to do in scenarios that have multiple DLLs using FFmpeg due to the following race condition:

Even if the default logging callback was restored on DLL unload, since there is no thread safety in the FFmpeg logging facility, log_callback in av_vlog() could become a dangling pointer.

What changed?

Disabled FFmpeg logging in release builds. Debug builds still register the custom logging callback on DLL load, but now also restore the default logging callback on DLL unload (which isn't thread safe and could still result in a crash).

How was the change tested?

For Ogg playback in Media Player with in-proc WME, I verified under a debugger that: