Adds trick speed support.

This commit is contained in:
Johns 2012-02-16 15:31:53 +01:00
parent a7f0cf6d6f
commit 852d367225
4 changed files with 72 additions and 20 deletions

View File

@ -1,3 +1,8 @@
User johns
Date:
Adds trick speed support.
User johns User johns
Date: Thu Feb 16 09:59:14 CET 2012 Date: Thu Feb 16 09:59:14 CET 2012

View File

@ -470,16 +470,6 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
return osize; return osize;
} }
/**
** Turns off audio while replaying.
*/
void Mute(void)
{
SkipAudio = 1;
AudioFlushBuffers();
//AudioSetVolume(0);
}
/** /**
** Set volume of audio device. ** Set volume of audio device.
** **
@ -513,8 +503,11 @@ static AVPacket VideoPacketRb[VIDEO_PACKET_MAX];
static int VideoPacketWrite; ///< write pointer static int VideoPacketWrite; ///< write pointer
static int VideoPacketRead; ///< read pointer static int VideoPacketRead; ///< read pointer
atomic_t VideoPacketsFilled; ///< how many of the buffer is used atomic_t VideoPacketsFilled; ///< how many of the buffer is used
static volatile char VideoClearBuffers; ///< clear video buffers static volatile char VideoClearBuffers; ///< clear video buffers
static volatile char SkipVideo; ///< skip video static volatile char SkipVideo; ///< skip video
static volatile char VideoTrickSpeed; ///< current trick speed
static volatile char VideoTrickCounter; ///< current trick speed counter
#ifdef DEBUG #ifdef DEBUG
static int VideoMaxPacketSize; ///< biggest used packet buffer static int VideoMaxPacketSize; ///< biggest used packet buffer
@ -722,6 +715,13 @@ int VideoDecode(void)
VideoClearBuffers = 0; VideoClearBuffers = 0;
return 1; return 1;
} }
if (VideoTrickSpeed) {
if (VideoTrickCounter++ < VideoTrickSpeed * 2) {
usleep(5 * 1000);
return 1;
}
VideoTrickCounter = 0;
}
filled = atomic_read(&VideoPacketsFilled); filled = atomic_read(&VideoPacketsFilled);
if (!filled) { if (!filled) {
@ -1225,6 +1225,21 @@ void SetPlayMode(void)
NewAudioStream = 1; 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; StreamFreezed = 0;
} }
@ -1251,6 +1266,8 @@ void Clear(void)
*/ */
void Play(void) void Play(void)
{ {
VideoTrickSpeed = 0;
VideoTrickCounter = 0;
StreamFreezed = 0; StreamFreezed = 0;
SkipAudio = 0; SkipAudio = 0;
AudioPlay(); AudioPlay();
@ -1265,6 +1282,16 @@ void Freeze(void)
AudioPause(); AudioPause();
} }
/**
** Turns off audio while replaying.
*/
void Mute(void)
{
SkipAudio = 1;
AudioFlushBuffers();
//AudioSetVolume(0);
}
/** /**
** Display the given I-frame as a still picture. ** Display the given I-frame as a still picture.
** **

View File

@ -37,8 +37,6 @@ extern "C"
/// C plugin play audio packet /// C plugin play audio packet
extern int PlayAudio(const uint8_t *, int, uint8_t); extern int PlayAudio(const uint8_t *, int, uint8_t);
/// C plugin mute audio
extern void Mute(void);
/// C plugin set audio volume /// C plugin set audio volume
extern void SetVolumeDevice(int); extern void SetVolumeDevice(int);
@ -51,12 +49,16 @@ extern "C"
/// C plugin set play mode /// C plugin set play mode
extern void SetPlayMode(void); extern void SetPlayMode(void);
/// C plugin set trick speed
extern void TrickSpeed(int);
/// C plugin clears all video and audio data from the device /// C plugin clears all video and audio data from the device
extern void Clear(void); extern void Clear(void);
/// C plugin sets the device into play mode /// C plugin sets the device into play mode
extern void Play(void); extern void Play(void);
/// C plugin sets the device into "freeze frame" mode /// C plugin sets the device into "freeze frame" mode
extern void Freeze(void); extern void Freeze(void);
/// C plugin mute audio
extern void Mute(void);
/// C plugin display I-frame as a still picture. /// C plugin display I-frame as a still picture.
extern void StillPicture(const uint8_t *, int); extern void StillPicture(const uint8_t *, int);
/// C plugin poll if ready /// C plugin poll if ready

View File

@ -42,7 +42,7 @@ extern "C"
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
static const char *const VERSION = "0.4.8"; static const char *const VERSION = "0.4.9";
static const char *const DESCRIPTION = static const char *const DESCRIPTION =
trNOOP("A software and GPU emulated HD device"); trNOOP("A software and GPU emulated HD device");
@ -144,9 +144,12 @@ extern "C" void FeedKeyPress(const char *keymap, const char *key, int repeat,
// OSD // OSD
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/**
** Soft device plugin OSD class.
*/
class cSoftOsd:public cOsd class cSoftOsd:public cOsd
{ {
int Level; ///< level: subtitle //int Level; ///< level: subtitle
public: public:
cSoftOsd(int, int, uint); cSoftOsd(int, int, uint);
@ -167,7 +170,7 @@ static volatile char OsdDirty; ///< flag force redraw everything
*/ */
void cSoftOsd::SetActive(bool on) void cSoftOsd::SetActive(bool on)
{ {
dsyslog("[softhddev]%s: %d\n", __FUNCTION__, on); //dsyslog("[softhddev]%s: %d\n", __FUNCTION__, on);
if (Active() == on) { if (Active() == on) {
return; // already active, no action return; // already active, no action
@ -188,7 +191,7 @@ cSoftOsd::cSoftOsd(int left, int top, uint level)
OsdHeight(), left, top, level); OsdHeight(), left, top, level);
*/ */
this->Level = level; //this->Level = level;
SetActive(true); SetActive(true);
} }
@ -334,6 +337,9 @@ void cSoftOsd::Flush(void)
// OSD provider // OSD provider
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/**
** Soft device plugin OSD provider class.
*/
class cSoftOsdProvider:public cOsdProvider class cSoftOsdProvider:public cOsdProvider
{ {
private: private:
@ -357,12 +363,13 @@ cOsd *cSoftOsdProvider::CreateOsd(int left, int top, uint level)
{ {
//dsyslog("[softhddev]%s: %d, %d, %d\n", __FUNCTION__, left, top, level); //dsyslog("[softhddev]%s: %d, %d, %d\n", __FUNCTION__, left, top, level);
Osd = new cSoftOsd(left, top, level); return Osd = new cSoftOsd(left, top, level);
return Osd;
} }
/** /**
** Returns true if this OSD provider is able to handle a true color OSD. ** Check if this OSD provider is able to handle a true color OSD.
**
** @returns true we are able to handle a true color OSD.
*/ */
bool cSoftOsdProvider::ProvidesTrueColor(void) bool cSoftOsdProvider::ProvidesTrueColor(void)
{ {
@ -810,13 +817,21 @@ int64_t cSoftHdDevice::GetSTC(void)
/** /**
** Set trick play speed. ** Set trick play speed.
** **
** Every single frame shall then be displayed the given number of
** times.
**
** @param speed trick speed ** @param speed trick speed
*/ */
void cSoftHdDevice::TrickSpeed(int speed) void cSoftHdDevice::TrickSpeed(int speed)
{ {
dsyslog("[softhddev]%s: %d\n", __FUNCTION__, speed); dsyslog("[softhddev]%s: %d\n", __FUNCTION__, speed);
::TrickSpeed(speed);
} }
/**
** Clears all video and audio data from the device.
*/
void cSoftHdDevice::Clear(void) void cSoftHdDevice::Clear(void)
{ {
dsyslog("[softhddev]%s:\n", __FUNCTION__); dsyslog("[softhddev]%s:\n", __FUNCTION__);
@ -825,6 +840,9 @@ void cSoftHdDevice::Clear(void)
::Clear(); ::Clear();
} }
/**
** Sets the device into play mode (after a previous trick mode)
*/
void cSoftHdDevice::Play(void) void cSoftHdDevice::Play(void)
{ {
dsyslog("[softhddev]%s:\n", __FUNCTION__); dsyslog("[softhddev]%s:\n", __FUNCTION__);