From 852d3672252bd13b8337b1f28c05fa457a3f1b7f Mon Sep 17 00:00:00 2001 From: Johns Date: Thu, 16 Feb 2012 15:31:53 +0100 Subject: Adds trick speed support. --- softhddev.c | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'softhddev.c') diff --git a/softhddev.c b/softhddev.c index 7ec3bd4..85a9b1a 100644 --- a/softhddev.c +++ b/softhddev.c @@ -470,16 +470,6 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id) return osize; } -/** -** Turns off audio while replaying. -*/ -void Mute(void) -{ - SkipAudio = 1; - AudioFlushBuffers(); - //AudioSetVolume(0); -} - /** ** Set volume of audio device. ** @@ -513,8 +503,11 @@ static AVPacket VideoPacketRb[VIDEO_PACKET_MAX]; static int VideoPacketWrite; ///< write pointer static int VideoPacketRead; ///< read pointer atomic_t VideoPacketsFilled; ///< how many of the buffer is used + static volatile char VideoClearBuffers; ///< clear video buffers static volatile char SkipVideo; ///< skip video +static volatile char VideoTrickSpeed; ///< current trick speed +static volatile char VideoTrickCounter; ///< current trick speed counter #ifdef DEBUG static int VideoMaxPacketSize; ///< biggest used packet buffer @@ -722,6 +715,13 @@ int VideoDecode(void) VideoClearBuffers = 0; return 1; } + if (VideoTrickSpeed) { + if (VideoTrickCounter++ < VideoTrickSpeed * 2) { + usleep(5 * 1000); + return 1; + } + VideoTrickCounter = 0; + } filled = atomic_read(&VideoPacketsFilled); if (!filled) { @@ -1225,6 +1225,21 @@ void SetPlayMode(void) NewAudioStream = 1; } } + Play(); +} + +/** +** Set trick play speed. +** +** Every single frame shall then be displayed the given number of +** times. +** +** @param speed trick speed +*/ +void TrickSpeed(int speed) +{ + VideoTrickSpeed = speed; + VideoTrickCounter = 0; StreamFreezed = 0; } @@ -1251,6 +1266,8 @@ void Clear(void) */ void Play(void) { + VideoTrickSpeed = 0; + VideoTrickCounter = 0; StreamFreezed = 0; SkipAudio = 0; AudioPlay(); @@ -1265,6 +1282,16 @@ void Freeze(void) AudioPause(); } +/** +** Turns off audio while replaying. +*/ +void Mute(void) +{ + SkipAudio = 1; + AudioFlushBuffers(); + //AudioSetVolume(0); +} + /** ** Display the given I-frame as a still picture. ** -- cgit v1.2.3