Revert "Remove unnecessary lock"

This reverts commit c96fac02c2.
This commit is contained in:
Flamefire committed 2014-12-02 22:08:55 +01:00
1 parent cd59b82b7b
commit d8cad8fd2c
1 file changed
+41
@@ -190,6 +190,8 @@ namespace Vocaluxe.Lib.Video.Acinerella
#endif
#endif
private static readonly Object _Lock = new Object();
// Defines the type of an Acinerella media stream. Currently only video and
// audio streams are supported, subtitle and data streams will be marked as
// "unknown".
@@ -200,9 +202,12 @@ namespace Vocaluxe.Lib.Video.Acinerella
private static extern IntPtr _ac_init();
public static IntPtr AcInit()
{
lock (_Lock)
{
return _ac_init();
}
}
// Frees an Acinerella instance.
//procedure ac_free(inst: PAc_instance); cdecl; external ac_dll;
@@ -210,9 +215,12 @@ namespace Vocaluxe.Lib.Video.Acinerella
private static extern void _ac_free(IntPtr pAcInstance);
public static void AcFree(IntPtr pAcInstance)
{
lock (_Lock)
{
_ac_free(pAcInstance);
}
}
// Opens a media file.
// @param(inst specifies the Acinerella Instance the stream should be opened for)
@@ -265,9 +273,12 @@ namespace Vocaluxe.Lib.Video.Acinerella
// ReSharper disable UnusedMethodReturnValue.Global
public static Int32 AcOpen2(IntPtr pAcInstance, string filename)
// ReSharper restore UnusedMethodReturnValue.Global
{
lock (_Lock)
{
return _ac_open2(pAcInstance, filename);
}
}
// Closes an opened media file.
//procedure ac_close(inst: PAc_instance);cdecl; external ac_dll;
@@ -275,9 +286,12 @@ namespace Vocaluxe.Lib.Video.Acinerella
private static extern void _ac_close(IntPtr pAcInstance);
public static void AcClose(IntPtr pAcInstance)
{
lock (_Lock)
{
_ac_close(pAcInstance);
}
}
// Stores information in "pInfo" about stream number "nb".
//procedure ac_get_stream_info(inst: PAc_instance; nb: integer; pinfo: PAc_stream_info); cdecl; external ac_dll;
@@ -285,9 +299,12 @@ namespace Vocaluxe.Lib.Video.Acinerella
private static extern void _ac_get_stream_info(IntPtr pAcInstance, Int32 nb, out SACStreamInfo info);
public static void AcGetStreamInfo(IntPtr pAcInstance, Int32 nb, out SACStreamInfo info)
{
lock (_Lock)
{
_ac_get_stream_info(pAcInstance, nb, out info);
}
}
// Reads a package from an opened media file.
//function ac_read_package(inst: PAc_instance): PAc_package; cdecl; external ac_dll;
@@ -303,17 +320,23 @@ namespace Vocaluxe.Lib.Video.Acinerella
private static extern IntPtr _ac_create_video_decoder(IntPtr pAcInstance);
public static IntPtr AcCreateVideoDecoder(IntPtr pAcInstance)
{
lock (_Lock)
{
return _ac_create_video_decoder(pAcInstance);
}
}
[DllImport(_AcDll, EntryPoint = "ac_create_audio_decoder", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
private static extern IntPtr _ac_create_audio_decoder(IntPtr pAcInstance);
public static IntPtr AcCreateAudioDecoder(IntPtr pAcInstance)
{
lock (_Lock)
{
return _ac_create_audio_decoder(pAcInstance);
}
}
// Frees an created decoder.
//procedure ac_free_decoder(pDecoder: PAc_decoder); cdecl; external ac_dll;
@@ -321,9 +344,12 @@ namespace Vocaluxe.Lib.Video.Acinerella
private static extern void _ac_free_decoder(IntPtr pAcDecoder);
public static void AcFreeDecoder(IntPtr pAcDecoder)
{
lock (_Lock)
{
_ac_free_decoder(pAcDecoder);
}
}
// Decodes a package using the specified decoder. The decodec data is stored in the
// "buffer" property of the decoder.
@@ -332,33 +358,45 @@ namespace Vocaluxe.Lib.Video.Acinerella
private static extern Int32 _ac_decode_package(IntPtr pAcPackage, IntPtr pAcDecoder);
public static bool AcDecodePackage(IntPtr pAcPackage, IntPtr pAcDecoder)
{
lock (_Lock)
{
return _ac_decode_package(pAcPackage, pAcDecoder) != 0;
}
}
[DllImport(_AcDll, EntryPoint = "ac_get_audio_frame", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
private static extern Int32 _ac_get_audio_frame(IntPtr pAcInstance, IntPtr pAcDecoder);
public static bool AcGetAudioFrame(IntPtr pAcInstance, IntPtr pAcDecoder)
{
lock (_Lock)
{
return _ac_get_audio_frame(pAcInstance, pAcDecoder) != 0;
}
}
[DllImport(_AcDll, EntryPoint = "ac_get_frame", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
private static extern Int32 _ac_get_frame(IntPtr pAcInstance, IntPtr pAcDecoder);
public static bool AcGetFrame(IntPtr pAcInstance, IntPtr pAcDecoder)
{
lock (_Lock)
{
return _ac_get_frame(pAcInstance, pAcDecoder) != 0;
}
}
[DllImport(_AcDll, EntryPoint = "ac_skip_frames", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
private static extern Int32 _ac_skip_frames(IntPtr pAcInstance, IntPtr pAcDecoder, Int32 num);
public static bool AcSkipFrames(IntPtr pAcInstance, IntPtr pAcDecoder, Int32 num)
{
lock (_Lock)
{
return _ac_skip_frames(pAcInstance, pAcDecoder, num) != 0;
}
}
// Seeks to the given target position in the file. The seek funtion is not able to seek a single audio/video stream
// but seeks the whole file forward. The deocder parameter is only used as an timecode reference.
@@ -369,9 +407,12 @@ namespace Vocaluxe.Lib.Video.Acinerella
private static extern Int32 _ac_seek(IntPtr pAcDecoder, Int32 dir, Int64 targetPos);
public static bool AcSeek(IntPtr pAcDecoder, Int32 dir, Int64 targetPos)
{
lock (_Lock)
{
return _ac_seek(pAcDecoder, dir, targetPos) != 0;
}
}
//function ac_probe_input_buffer(buf: PChar; bufsize: Integer; filename: PChar;
//var score_max: Integer): PAc_proberesult; cdecl; external ac_dll;