mirror of
https://projects.vdr-developer.org/git/vdr-plugin-softhddevice.git
synced 2023-10-10 19:16:51 +02:00
Fix bug: 100% cpu use with plugins like mp3.
This commit is contained in:
parent
2561214c3e
commit
c17af0e958
@ -1,6 +1,7 @@
|
||||
User johns
|
||||
Date:
|
||||
|
||||
Fix bug: 100% cpu use with plugins like mp3.
|
||||
Wakeup display thread on channel switch, osd can now be shown without
|
||||
video.
|
||||
Makes 60Hz display mode configurable with setup.conf.
|
||||
|
23
softhddev.c
23
softhddev.c
@ -75,6 +75,8 @@ static AudioDecoder *MyAudioDecoder; ///< audio decoder
|
||||
static enum CodecID AudioCodecID; ///< current codec id
|
||||
static int AudioChannelID; ///< current audio channel id
|
||||
|
||||
/// Minimum free space in audio buffer 8 packets for 8 channels
|
||||
#define AUDIO_MIN_BUFFER_FREE (3072 * 8 * 8)
|
||||
#define AUDIO_BUFFER_SIZE (512 * 1024) ///< audio PES buffer default size
|
||||
static AVPacket AudioAvPkt[1]; ///< audio a/v packet
|
||||
|
||||
@ -864,7 +866,7 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
|
||||
NewAudioStream = 0;
|
||||
}
|
||||
// Don't overrun audio buffers on replay
|
||||
if (AudioFreeBytes() < 3072 * 8 * 8) { // 8 channels 8 packets
|
||||
if (AudioFreeBytes() < AUDIO_MIN_BUFFER_FREE) {
|
||||
return 0;
|
||||
}
|
||||
// PES header 0x00 0x00 0x01 ID
|
||||
@ -1058,7 +1060,7 @@ int PlayTsAudio(const uint8_t * data, int size)
|
||||
return size;
|
||||
}
|
||||
// Don't overrun audio buffers on replay
|
||||
if (AudioFreeBytes() < 3072 * 8 * 8) { // 8 channels 8 packets
|
||||
if (AudioFreeBytes() < AUDIO_MIN_BUFFER_FREE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1827,7 +1829,7 @@ uint8_t *GrabImage(int *size, int jpeg, int quality, int width, int height)
|
||||
/**
|
||||
** Set play mode, called on channel switch.
|
||||
*/
|
||||
void SetPlayMode(void)
|
||||
int SetPlayMode(int play_mode)
|
||||
{
|
||||
if (ConfigStartSuspended) { // ignore first call, if start suspended
|
||||
ConfigStartSuspended = 0;
|
||||
@ -1835,18 +1837,23 @@ void SetPlayMode(void)
|
||||
}
|
||||
Resume();
|
||||
VideoDisplayWakeup();
|
||||
if (MyVideoDecoder) {
|
||||
if (MyVideoDecoder) { // tell video parser we have new stream
|
||||
if (VideoCodecID != CODEC_ID_NONE) {
|
||||
NewVideoStream = 1;
|
||||
VideoSwitch = GetMsTicks();
|
||||
}
|
||||
}
|
||||
if (MyAudioDecoder) {
|
||||
if (MyAudioDecoder) { // tell audio parser we have new stream
|
||||
if (AudioCodecID != CODEC_ID_NONE) {
|
||||
NewAudioStream = 1;
|
||||
}
|
||||
}
|
||||
if (play_mode == 2 || play_mode == 3 ) {
|
||||
Debug(3, "softhddev: FIXME: audio only, silence video errors\n");
|
||||
}
|
||||
Play();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1990,11 +1997,13 @@ void StillPicture(const uint8_t * data, int size)
|
||||
int Poll(int timeout)
|
||||
{
|
||||
// buffers are too full
|
||||
if (atomic_read(&VideoPacketsFilled) >= VIDEO_PACKET_MAX * 2 / 3) {
|
||||
if ( atomic_read(&VideoPacketsFilled) >= VIDEO_PACKET_MAX * 2 / 3
|
||||
|| AudioFreeBytes() < AUDIO_MIN_BUFFER_FREE * 2) {
|
||||
if (timeout) { // let display thread work
|
||||
usleep(timeout * 1000);
|
||||
}
|
||||
return atomic_read(&VideoPacketsFilled) < VIDEO_PACKET_MAX * 2 / 3;
|
||||
return atomic_read(&VideoPacketsFilled) < VIDEO_PACKET_MAX * 2 / 3
|
||||
&& AudioFreeBytes() > AUDIO_MIN_BUFFER_FREE;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ extern "C"
|
||||
extern uint8_t *GrabImage(int *, int, int, int, int);
|
||||
|
||||
/// C plugin set play mode
|
||||
extern void SetPlayMode(void);
|
||||
extern int SetPlayMode(int);
|
||||
/// C plugin set trick speed
|
||||
extern void TrickSpeed(int);
|
||||
/// C plugin clears all video and audio data from the device
|
||||
|
@ -295,7 +295,7 @@ void cSoftOsd::Flush(void)
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (w > bitmap->Width() || h > bitmap->Height()) {
|
||||
esyslog(tr("softhddev: dirty area too big\n"));
|
||||
esyslog(tr("[softhddev]: dirty area too big\n"));
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
@ -742,7 +742,7 @@ static void HandleHotkey(int code)
|
||||
CodecSetAudioPassthrough(ConfigAudioPassthrough ^= 1);
|
||||
break;
|
||||
default:
|
||||
esyslog(tr("softhddev: hot key %d is not supported\n"), code);
|
||||
esyslog(tr("[softhddev]: hot key %d is not supported\n"), code);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -954,8 +954,8 @@ bool cSoftHdDevice::SetPlayMode(ePlayMode play_mode)
|
||||
dsyslog("[softhddev] playmode not implemented... %d\n", play_mode);
|
||||
break;
|
||||
}
|
||||
::SetPlayMode();
|
||||
return true;
|
||||
|
||||
return ::SetPlayMode(play_mode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user