Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: cReceivers in plugins



On Fri, May 09, 2003 at 12:14:57PM +0200, Andreas Schultz wrote:
> Klaus Schmidinger wrote:
> 
> [...]
> 
> >If no channel switch happens, what's the point in attaching a cReceiver?
> 
> There is point in attaching a cReceiver, but there are good reasons to 
> attach cPlayer classes which could IMHO suffer from the same problem. 
> After all, there are people who use DXR3 based systems as vdr player or 
> network stream receiver devices.
> 
> >The clean way _is_ to implement a cStatus class and monitor the device(s)
> >there.
> 
> maybe, but i don't think a ChannelSwitch event should count or be used 
> as a "this device i alive" indication.

The only problem I've detected was that within the transfer mode the
used primary device does not provide the choosen channel.  Therefore
I use something like this:

...

void cMyStatus::ChannelSwitch(const cDevice *Device, int ChannelNumber)
{
    cChannel *channel = NULL;
    cDevice *PrimaryDevice = cDevice::PrimaryDevice();

    // LiveView is only on the primary device possible, isn't it?
    if (!Device->IsPrimaryDevice())
        goto out;

    if (myReceiver) {
        PrimaryDevice->Detach(myReceiver);
        delete myReceiver;
        myReceiver = NULL;
        Dpid = 0x1FFF;
    }

    // If we're noticed only for channel switch or
    // a replay is running we're done
    if (!ChannelNumber || replaying)
        goto out;

    // No channel, no audio
    if (!(channel = Channels.GetByNumber(ChannelNumber)))
        goto out;

    // Sanity check not be attached in transfer mode
    // in this case the replay part should have taken the data
    if (!PrimaryDevice->ProvidesChannel(channel, Setup.PrimaryLimit))
        goto out;

    // Valid pid for AC3 to be attached too?
    if ((Dpid = channel->Dpid1()) && (Dpid < 0x1FFF)) {
        myReceiver = new cMyReceiver(Dpid);
        if (!myReceiver) {
            esyslog("ERROR: out of memory");
            Dpid = 0x1FFF;
        } else
            PrimaryDevice->AttachReceiver(myReceiver);
    }
out:
    return;
}

void cMyStatus::Replaying(const cControl *Control, const char *Name)
{
    replaying = (Name != NULL);
    cDevice *PrimaryDevice = cDevice::PrimaryDevice();

    if (replaying && myReceiver) {
        PrimaryDevice->Detach(myReceiver);
        delete myReceiver;
        myReceiver = NULL;
        Dpid = 0x1FFF;
    } // else
      // (re)attaching will be done by ChannelSwitch()
}

....

        Werner


-- 
Info:
To unsubscribe send a mail to ecartis@linuxtv.org with "unsubscribe vdr" as subject.



Home | Main Index | Thread Index