File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -716,12 +716,25 @@ static int LockCallBack(void **mutex, AVLockOp op)
716
716
static ImplMutex _mutex;
717
717
static bool _initialized = false ;
718
718
719
+ class AutoLock
720
+ {
721
+ public:
722
+ AutoLock (ImplMutex& m) : mutex(&m) { mutex->lock (); }
723
+ ~AutoLock () { mutex->unlock (); }
724
+ protected:
725
+ ImplMutex* mutex;
726
+ private:
727
+ AutoLock (const AutoLock&); // disabled
728
+ AutoLock& operator = (const AutoLock&); // disabled
729
+ };
730
+
731
+
719
732
class InternalFFMpegRegister
720
733
{
721
734
public:
722
735
InternalFFMpegRegister ()
723
736
{
724
- _mutex. lock ();
737
+ AutoLock lock (_mutex );
725
738
if (!_initialized)
726
739
{
727
740
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 13, 0)
@@ -738,7 +751,6 @@ class InternalFFMpegRegister
738
751
739
752
_initialized = true ;
740
753
}
741
- _mutex.unlock ();
742
754
}
743
755
744
756
~InternalFFMpegRegister ()
@@ -752,6 +764,7 @@ static InternalFFMpegRegister _init;
752
764
753
765
bool CvCapture_FFMPEG::open ( const char * _filename )
754
766
{
767
+ AutoLock lock (_mutex);
755
768
unsigned i;
756
769
bool valid = false ;
757
770
You can’t perform that action at this time.
0 commit comments