diff options
author | Johns <johns98@gmx.net> | 2013-01-05 17:17:50 +0100 |
---|---|---|
committer | Johns <johns98@gmx.net> | 2013-01-05 17:17:50 +0100 |
commit | 6a3a560857dfac4e2a34ae17fd54247b32559d64 (patch) | |
tree | d13d92dec04e3699f975511f44392569715f5865 | |
parent | 8ee1e84b2eecc2959e6592613df20e5340336d7f (diff) | |
download | vdr-plugin-softhddevice-6a3a560857dfac4e2a34ae17fd54247b32559d64.tar.gz vdr-plugin-softhddevice-6a3a560857dfac4e2a34ae17fd54247b32559d64.tar.bz2 |
Adds PIP channel switch functions.
-rw-r--r-- | softhddevice.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/softhddevice.cpp b/softhddevice.cpp index 06fe3aa..a46006a 100644 --- a/softhddevice.cpp +++ b/softhddevice.cpp @@ -1505,6 +1505,7 @@ void cSoftReceiver::Receive(uchar * data, int size) ////////////////////////////////////////////////////////////////////////////// static cSoftReceiver *PipReceiver; ///< PIP receiver +static const cChannel *PipChannel; ///< current PIP channel /** ** Prepare new PIP. @@ -1530,6 +1531,7 @@ static void NewPip(void) device->AttachReceiver(receiver); fprintf(stderr, "pip: attached\n"); PipReceiver = receiver; + PipChannel = channel; } } @@ -1539,9 +1541,72 @@ static void NewPip(void) static void DelPip(void) { fprintf(stderr, "pip: stopped\n"); + delete PipReceiver; PipReceiver = NULL; + PipChannel = NULL; +} + +/** +** Switch PIP to next available channel. +** +** @param direction direction of channel switch +*/ +static void PipNextAvailableChannel(int direction) +{ + const cChannel *channel; + + channel = PipChannel; + while (channel) { + channel = direction > 0 ? Channels.Next(channel) + : Channels.Prev(channel); + if (!channel && Setup.ChannelsWrap) { + channel = direction > 0 ? Channels.First() : Channels.Last(); + } + if (channel && !channel->GroupSep() + && cDevice::GetDevice(channel, 1, false, true)) { + cDevice *device; + cSoftReceiver *receiver; + + DelPip(); + + if ((device = cDevice::GetDevice(channel, 1, false))) { + fprintf(stderr, "pip: %p %p\n", channel, device); + + delete PipReceiver; + + PipReceiver = NULL; + + device->SwitchChannel(channel, false); + receiver = new cSoftReceiver(channel); + device->AttachReceiver(receiver); + fprintf(stderr, "pip: attached\n"); + PipReceiver = receiver; + PipChannel = channel; + } + return; + } + } +} + +/** +** Swap PIP channels. +*/ +static void SwapPipChannels(void) +{ + const cChannel *channel; + + fprintf(stderr, "pip: switch channel\n"); + + channel = PipChannel; + + DelPip(); + NewPip(); + + if (channel) { + Channels.SwitchTo(channel->Number()); + } } /** @@ -1824,6 +1889,15 @@ eOSState cSoftHdMenu::ProcessKey(eKeys key) case osUser2: NewPip(); return osEnd; + case osUser4: + PipNextAvailableChannel(-1); + return osEnd; + case osUser5: + PipNextAvailableChannel(1); + return osEnd; + case osUser6: + SwapPipChannels(); + return osEnd; case osUser7: SwapPipPosition(); return osEnd; |