[FFmpeg-devel] Patch: Enable OpenCL with Win32 threads

Matt Oliver protogonoi at gmail.com
Thu Apr 17 05:46:36 CEST 2014


>
> Could this just be integrated in the pthread_mutex_lock win32 wrapper
> code to emulate PTHREAD_MUTEX_INITIALIZER?


It probably shouldn't as it adds extra checks that are not necessary if you
did the appropriate _init calls anyway (also I did it wrong ;) ). Win32
already does an internal check on the -1 waiters value which is what I used
in the first patch that added a static initialisation for win32.


> this is not thread safe at all
>
> thread #1  avpriv_atomic_cas
> thread #2                    avpriv_atomic_cas (if skiped) LOCK_OPENCL use
> of uninitialized mutex
>
> please see the existing code, that sets up global mutexes
> in the lock manager for example
>

This is one of those things were I knew that and knew better but for some
reason did it anyway (good reason not to submit patches late at night). It
needed a second atomic and wait to work properly. Anyway attached is a
patch that initialises in the same way the existing lock manager does which
should be more acceptable and consistent with existing code. Its a little
more complicated than static initialisation but if the first static patch
with the win32 static initializer isnt suitable then this seems the most
consistent way to support all native thread implementations.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: opencl-add-support-for-non-pthread-locking.patch
Type: application/octet-stream
Size: 4026 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140417/f7f5f9b0/attachment.obj>


More information about the ffmpeg-devel mailing list