Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DviSubscription assertion failure
01-10-2012, 09:50 AM
Post: #1
DviSubscription assertion failure
I'm trying to create a simple C# media server with ohNet, but I receive an assertion failure from the framework; here's the portion of code that make the exception (both in Windows and Linux):

Code:
private void button1_Click(object sender, EventArgs e)
{
    if (started)
    {
        Stop();
    }
    else
    {
        Start();
    }

    started = !started;
}

private void Stop()
{
    device.SetDisabled(() => {
        device = null;
        provider = null;
        library = null;
    });
}

private void Start()
{
    var initParams = new InitParams
                         {
                         };

    library = Library.Create(initParams);
    DeviceStack ds = library.StartDv();

    //device = new DvDeviceFactory(ds).CreateDeviceStandard(udn);
    device = new DvDeviceStandard(udn);

    device.SetAttribute("Upnp.Domain", "schemas-upnp-org");
    device.SetAttribute("Upnp.Type", "MediaServer");
    device.SetAttribute("Upnp.Version", "1");
    device.SetAttribute("Upnp.FriendlyName", "My Media Server");
    device.SetAttribute("Upnp.Manufacturer", "Atropo");
    device.SetAttribute("Upnp.ModelName", "My Media Server");
    // TODO: To be completed

    provider = new MyContentDirectory(device);

    device.SetEnabled();
}

and here's the exception (from Linux):
Code:
Assertion failed. OpenHome/Net/Device/DviSubscription.cpp:192

I'm testing the code with "UPnP Tester"; actually it recognize the service, but after that my program crash. I've tried to use VLC too, and the behaviour is the same (recognition and crash).

What I'm missing?

Thanks in advance,
Sergio
Find all posts by this user
01-10-2012, 12:23 PM
Post: #2
RE: DviSubscription assertion failure
(01-10-2012 09:50 AM)Atropo Wrote:  I'm trying to create a simple C# media server with ohNet, but I receive an assertion failure from the framework;

[snip]

and here's the exception (from Linux):
Code:
Assertion failed. OpenHome/Net/Device/DviSubscription.cpp:192

What I'm missing?

Welcome to the forum Sergio.

This assertion is signalling that one or more properties (aka evented state variables) in a service haven't been initialised. Each service has a provider base class generated for it; these classes have a SetProperty[EventedStateVariableName] function. You just need to call this for each property.

You can initialise properties at any point before SetEnabled is called on their containing DvDevice. The normal place to do this is in the constructor for the relevant provider class. See ProviderTestBasic in OpenHome/Net/Bindings/Cs/Device/Tests/TestBasicDv.cs for an example.
Find all posts by this user
01-10-2012, 01:39 PM
Post: #3
RE: DviSubscription assertion failure
(01-10-2012 12:23 PM)simonc Wrote:  Welcome to the forum Sergio.
Blush Sorry, I forgot to say 'hi' to the forum!!! Blush

(01-10-2012 12:23 PM)simonc Wrote:  This assertion is signalling that one or more properties (aka evented state variables) in a service haven't been initialised. Each service has a provider base class generated for it; these classes have a SetProperty[EventedStateVariableName] function. You just need to call this for each property.

You can initialise properties at any point before SetEnabled is called on their containing DvDevice. The normal place to do this is in the constructor for the relevant provider class. See ProviderTestBasic in OpenHome/Net/Bindings/Cs/Device/Tests/TestBasicDv.cs for an example.

Thank you so much; I thought that EnableProperty[EventedStateVaraibleName] function was sufficient to... enable it! However your solution absolutely works!!! Big Grin

Thanks again,
Sergio
Find all posts by this user
01-10-2012, 02:37 PM
Post: #4
RE: DviSubscription assertion failure
(01-10-2012 01:39 PM)Atropo Wrote:  Thank you so much; I thought that EnableProperty[EventedStateVaraibleName] function was sufficient to... enable it! However your solution absolutely works!!! Big Grin

Glad you got it working. EnableProperty[EventedStateVaraibleName] just adds a property to the serviceStateTable in the service xml. (Which is needed because the media server spec defines some optional state variables.) You still need to choose an initial state for each of the properties after enabling them.

One other potential gotcha in this area - its best practice to enable/initialise all properties before enabling any actions. (This becomes important when actions have arguments with related state variables...)
Find all posts by this user


Forum Jump: