Fix frontend handling during a device switch.

This commit is contained in:
Rolf Ahrenberg 2016-01-21 21:01:15 +02:00
parent c13f98a622
commit 7bc2ff53bd
3 changed files with 61 additions and 78 deletions

View File

@ -534,3 +534,4 @@ VDR Plugin 'femon' Revision History
2015-XX-XX: Version 2.3.0 2015-XX-XX: Version 2.3.0
- Updated for vdr-2.3.1. - Updated for vdr-2.3.1.
- Fixed frontend handling during a device switch.

127
osd.c
View File

@ -721,40 +721,7 @@ void cFemonOsd::Show(void)
LOCK_CHANNELS_READ; LOCK_CHANNELS_READ;
const cChannel *channel = Channels->GetByNumber(cDevice::CurrentChannel()); const cChannel *channel = Channels->GetByNumber(cDevice::CurrentChannel());
deviceSourceM = DEVICESOURCE_DVBAPI; AttachFrontend();
if (channel) {
if (channel->IsSourceType('I'))
deviceSourceM = DEVICESOURCE_IPTV;
else if (channel->IsSourceType('V'))
deviceSourceM = DEVICESOURCE_PVRINPUT;
}
if (deviceSourceM == DEVICESOURCE_DVBAPI) {
if (!strstr(*cDevice::ActualDevice()->DeviceType(), SATIP_DEVICE)) {
cDvbDevice *dev = getDvbDevice(cDevice::ActualDevice());
frontendM = dev ? open(*cString::sprintf(FRONTEND_DEVICE, dev->Adapter(), dev->Frontend()), O_RDONLY | O_NONBLOCK) : -1;
if (frontendM >= 0) {
if (ioctl(frontendM, FE_GET_INFO, &frontendInfoM) < 0) {
if (!FemonConfig.GetUseSvdrp())
error("%s Cannot read frontend info", __PRETTY_FUNCTION__);
close(frontendM);
frontendM = -1;
memset(&frontendInfoM, 0, sizeof(frontendInfoM));
return;
}
}
else if (FemonConfig.GetUseSvdrp()) {
if (!SvdrpConnect() || !SvdrpTune())
return;
}
else {
error("%s Cannot open frontend device", __PRETTY_FUNCTION__);
return;
}
}
}
else
frontendM = -1;
osdM = cOsdProvider::NewOsd(osdLeftM, osdTopM); osdM = cOsdProvider::NewOsd(osdLeftM, osdTopM);
if (osdM) { if (osdM) {
@ -783,6 +750,55 @@ void cFemonOsd::Show(void)
} }
} }
bool cFemonOsd::AttachFrontend(void)
{
debug1("%s", __PRETTY_FUNCTION__);
LOCK_CHANNELS_READ;
const cChannel *channel = Channels->GetByNumber(cDevice::CurrentChannel());
if (frontendM >= 0) {
close(frontendM);
frontendM = -1;
}
deviceSourceM = DEVICESOURCE_DVBAPI;
if (channel) {
if (channel->IsSourceType('I'))
deviceSourceM = DEVICESOURCE_IPTV;
else if (channel->IsSourceType('V'))
deviceSourceM = DEVICESOURCE_PVRINPUT;
}
if (deviceSourceM == DEVICESOURCE_DVBAPI) {
if (!strstr(*cDevice::ActualDevice()->DeviceType(), SATIP_DEVICE)) {
cDvbDevice *dev = getDvbDevice(cDevice::ActualDevice());
frontendM = dev ? open(*cString::sprintf(FRONTEND_DEVICE, dev->Adapter(), dev->Frontend()), O_RDONLY | O_NONBLOCK) : -1;
if (frontendM >= 0) {
if (ioctl(frontendM, FE_GET_INFO, &frontendInfoM) < 0) {
if (!FemonConfig.GetUseSvdrp())
error("%s Cannot read frontend info", __PRETTY_FUNCTION__);
close(frontendM);
frontendM = -1;
memset(&frontendInfoM, 0, sizeof(frontendInfoM));
return false;
}
}
else if (FemonConfig.GetUseSvdrp()) {
if (!SvdrpConnect() || !SvdrpTune())
return false;
}
else {
error("%s Cannot open frontend device", __PRETTY_FUNCTION__);
return false;
}
}
}
else
frontendM = -1;
return true;
}
void cFemonOsd::ChannelSwitch(const cDevice * deviceP, int channelNumberP, bool liveViewP) void cFemonOsd::ChannelSwitch(const cDevice * deviceP, int channelNumberP, bool liveViewP)
{ {
debug1("%s (%d, %d, %d)", __PRETTY_FUNCTION__, deviceP->DeviceNumber(), channelNumberP, liveViewP); debug1("%s (%d, %d, %d)", __PRETTY_FUNCTION__, deviceP->DeviceNumber(), channelNumberP, liveViewP);
@ -801,42 +817,7 @@ void cFemonOsd::ChannelSwitch(const cDevice * deviceP, int channelNumberP, bool
return; return;
} }
if (channel && FemonConfig.GetAnalyzeStream()) { if (channel && FemonConfig.GetAnalyzeStream() && AttachFrontend()) {
deviceSourceM = DEVICESOURCE_DVBAPI;
if (channel->IsSourceType('I'))
deviceSourceM = DEVICESOURCE_IPTV;
else if (channel->IsSourceType('V'))
deviceSourceM = DEVICESOURCE_PVRINPUT;
if (frontendM >= 0) {
close(frontendM);
frontendM = -1;
}
if (deviceSourceM == DEVICESOURCE_DVBAPI) {
if (!strstr(*cDevice::ActualDevice()->DeviceType(), SATIP_DEVICE)) {
cDvbDevice *dev = getDvbDevice(cDevice::ActualDevice());
frontendM = dev ? open(*cString::sprintf(FRONTEND_DEVICE, dev->Adapter(), dev->Frontend()), O_RDONLY | O_NONBLOCK) : -1;
if (frontendM >= 0) {
if (ioctl(frontendM, FE_GET_INFO, &frontendInfoM) < 0) {
if (!FemonConfig.GetUseSvdrp())
error("%s Cannot read frontend info", __PRETTY_FUNCTION__);
close(frontendM);
frontendM = -1;
memset(&frontendInfoM, 0, sizeof(frontendInfoM));
return;
}
}
else if (FemonConfig.GetUseSvdrp()) {
if (!SvdrpConnect() || !SvdrpTune())
return;
}
else {
error("%s Cannot open frontend device", __PRETTY_FUNCTION__);
return;
}
}
if (receiverM) { if (receiverM) {
receiverM->Deactivate(); receiverM->Deactivate();
DELETENULL(receiverM); DELETENULL(receiverM);
@ -845,7 +826,6 @@ void cFemonOsd::ChannelSwitch(const cDevice * deviceP, int channelNumberP, bool
cDevice::ActualDevice()->AttachReceiver(receiverM); cDevice::ActualDevice()->AttachReceiver(receiverM);
} }
} }
}
void cFemonOsd::SetAudioTrack(int indexP, const char * const *tracksP) void cFemonOsd::SetAudioTrack(int indexP, const char * const *tracksP)
{ {
@ -945,12 +925,13 @@ bool cFemonOsd::DeviceSwitch(int directionP)
d->CamSlot()->Assign(NULL); d->CamSlot()->Assign(NULL);
d->SwitchChannel(channel, false); d->SwitchChannel(channel, false);
cControl::Launch(new cTransferControl(d, channel)); cControl::Launch(new cTransferControl(d, channel));
return (true); AttachFrontend();
return true;
} }
} }
} }
} }
return (false); return false;
} }
bool cFemonOsd::SvdrpConnect(void) bool cFemonOsd::SvdrpConnect(void)

1
osd.h
View File

@ -72,6 +72,7 @@ private:
cCondWait sleepM; cCondWait sleepM;
cMutex mutexM; cMutex mutexM;
bool AttachFrontend(void);
void DrawStatusWindow(void); void DrawStatusWindow(void);
void DrawInfoWindow(void); void DrawInfoWindow(void);
bool SvdrpConnect(void); bool SvdrpConnect(void);