Merge branch 'release-0.3' into develop

This commit is contained in:
Flamefire committed 2013-10-21 15:51:10 +02:00
commit d14c8fd37e
2 files changed
+76 -22

No files matched your search

+8 -17
View File
@@ -40,7 +40,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
private float _FrameDuration; // frame time in s
private float _LastDecodedTime; // time of last decoded frame
private float _LastShownTime; // current video position
private float _LastShownTime; // time if the last shown frame in s
private float _Time;
private float _Gap;
@@ -123,12 +123,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
public bool GetFrame(ref CTexture frame, float time, out float videoTime)
{
if (_Paused)
{
videoTime = 0;
return false;
}
if (Loop)
{
lock (_MutexSyncSignals)
@@ -137,17 +131,17 @@ namespace Vocaluxe.Lib.Video.Acinerella
_LoopTimer.Restart();
}
}
else if (Math.Abs(_SetTime - time) > float.Epsilon)
else if (Math.Abs(_SetTime - time) >= 1f / 1000f) //Check 1 ms difference
{
lock (_MutexSyncSignals)
{
_SetTime = time;
}
}
else
else if (Math.Abs(_LastShownTime - time) < 1f / 1000 && frame != null) //Check 1 ms difference
{
videoTime = 0;
return false; //Check if this false is right. But should as we don't give a frame here
videoTime = _LastShownTime;
return true;
}
_UploadNewFrame(ref frame);
videoTime = _LastShownTime;
@@ -185,11 +179,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
}
_LastDecodedTime = _SkipTime;
lock (_MutexSyncSignals)
{
_LastShownTime = _LastDecodedTime;
}
lock (_MutexFramebuffer)
{
_Framebuffer.Clear();
@@ -425,13 +414,15 @@ namespace Vocaluxe.Lib.Video.Acinerella
float now = _SetTime + _Gap;
float maxEnd = now - _FrameDuration * 2; //Get only frames younger than 2
CFrame frame;
bool paused = _Paused;
while ((frame = _Framebuffer.Get()) != null)
{
float frameEnd = frame.Time + _FrameDuration;
//Don't show frames that are shown during or after now
if (frameEnd >= now)
break; //All following frames are after that one
if (paused) // Don't modify anything
break;
_Framebuffer.SetRead();
//Get the last(newest) possible frame and skip the rest to force in-order showing
if (frameEnd <= maxEnd)
+68 -5
View File
@@ -21,31 +21,94 @@ namespace Vocaluxe.Lib.Video
{
interface IVideoDecoder
{
/// <summary>
/// Initializes videodecoder. Got to be called before usage
/// </summary>
/// <returns>True on success, false if something went wrong.</returns>
bool Init();
/// <summary>
/// Close all video streams
/// </summary>
void CloseAll();
/// <summary>
/// Loads the file with the given file path.
/// </summary>
/// <param name="videoFileName">Absolute file path of the video file</param>
/// <returns>StreamID &gt;=0 on success or -1 on failure</returns>
int Load(string videoFileName);
/// <summary>
/// Closes the stream with the given ID
/// </summary>
/// <param name="streamID">ID of the stream</param>
/// <returns>true if stream was closed, false if stream doesn't exist or already closed</returns>
bool Close(int streamID);
/// <summary>
/// Gets the number of streams currently active
/// </summary>
/// <returns></returns>
int GetNumStreams();
/// <summary>
/// Gets the length of the video in s
/// </summary>
/// <param name="streamID">Id of the stream</param>
/// <returns>Length of the video in s</returns>
float GetLength(int streamID);
/// <summary>
/// Gets a frame of the video and sets the current video time
/// </summary>
/// <param name="streamID"></param>
/// <param name="frame"></param>
/// <param name="time"></param>
/// <param name="videoTime"></param>
/// <returns>True if frame is valid</returns>
/// <param name="streamID">Id of the stream</param>
/// <param name="frame">Reference to already initialized video texture (from previous calls). If null, one will be created.<br/>
/// Returns the current video frame which might be outdated if time != current (internal) video position or unchanged (even null) if none is available.</param>
/// <param name="time">The position in s of the video you want to get a frame of. If != current (internal) video position, it will seek to get to right position.<br/>
/// <b>Note:</b>Will be ignored for looped playback!</param>
/// <param name="videoTime">The actual position in s of the returned frame. Should be ~ time+VideoGap</param>
/// <returns>True if frame is valid, false: frame and videoTime might be unchanged or invalid</returns>
bool GetFrame(int streamID, ref CTexture frame, float time, out float videoTime);
/// <summary>
/// Seeks to given position
/// </summary>
/// <param name="streamID">Id of the stream</param>
/// <param name="start">Position to seek to</param>
/// <param name="gap">New video gap -> Actual position will be start+gap</param>
/// <returns>True on success</returns>
bool Skip(int streamID, float start, float gap);
/// <summary>
/// Set if the video should be looped
/// </summary>
/// <param name="streamID">Id of the stream</param>
/// <param name="loop">True if it should be looped</param>
void SetLoop(int streamID, bool loop);
/// <summary>
/// Pauses the video (no new frames will be decoded)
/// </summary>
/// <param name="streamID">Id of the stream</param>
void Pause(int streamID);
/// <summary>
/// Resumes a paused video
/// </summary>
/// <param name="streamID">Id of the stream</param>
void Resume(int streamID);
/// <summary>
/// Check if the given video is finished
/// </summary>
/// <param name="streamID">Id of the stream</param>
/// <returns>True if all frames are shown</returns>
bool Finished(int streamID);
/// <summary>
/// Do a step of the decoder in unthreaded decoders. Should be called once every frame.
/// </summary>
void Update();
}
}