avutil/log: fix race between setting and using the log callback

Found-by: wm4
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>