avutil/log: use thread wrappers for the locking functionality