ThomArmax / HUPnP

Fork of Herqq UPnP (HUPnP), a software library for building UPnP devices and control points conforming to the UPnP Device Architecture version 1.1
GNU General Public License v3.0
4 stars 5 forks source link

[Qt5] HControlPoint : Application stucked when discovering devices with some Qt5 versions (FUTEX_WAIT) #4

Open ThomArmax opened 8 years ago

ThomArmax commented 8 years ago

strace give the following log :

futex(0x9cb120, FUTEX_WAIT, 2, NULL

With my system default Qt version (5.4.1) I have no issue, but with Qt 5.4.3 for Raspberry PI (built with Yocto), the application seems to be blocked after having discovering one UPnP device.

The code I use to produce this issue :

#include <QCoreApplication>
#include <QDebug>
#include <HUpnpCore/HControlPoint>
#include <HUpnpCore/HControlPointConfiguration>
#include <HUpnpCore/HDeviceInfo>
#include <HUpnpCore/HClientService>
#include <HUpnpCore/HServiceInfo>
#include <HUpnpCore/HServiceId>
#include <HUpnpAv/HMediaBrowser>

using namespace Herqq::Upnp;
using namespace Herqq::Upnp::Av;

class Browser :public QObject {
    Q_OBJECT
public:
    Browser(QObject * parent = 0) : QObject(parent), browser(new HMediaBrowser(this)) {
        connect(browser,
                SIGNAL(objectsBrowsed(Herqq::Upnp::Av::HMediaBrowser*,QSet<QString>)),
                this,
                SLOT(onObjectsBrowsed(Herqq::Upnp::Av::HMediaBrowser*,QSet<QString>)));
        connect(browser,
                SIGNAL(browseComplete(Herqq::Upnp::Av::HMediaBrowser*)),
                this,
                SLOT(onBrowseComplete(Herqq::Upnp::Av::HMediaBrowser*)));
        connect(browser,
                SIGNAL(browseFailed(Herqq::Upnp::Av::HMediaBrowser*)),
                this,
                SLOT(onBrowseFailed(Herqq::Upnp::Av::HMediaBrowser*)));
    }
public slots:
    void browseDevice(Herqq::Upnp::HClientDevice* device) {
        qDebug() << Q_FUNC_INFO << "Device" << device->info().friendlyName();
        HClientServices servs = device->services();
        HClientService * cds = NULL;
        foreach(HClientService* serv, servs) {
            qDebug() << "     " << serv->info().serviceId().toString();
            if(QString::compare(serv->info().serviceId().toString(),
                                "urn:upnp-org:serviceId:ContentDirectory") == 0)
                cds = serv;
        }
        if (cds) {
            browser->reset(cds);
            browser->browseRoot();
        }
        else {
            qDebug() << "No Content Directory Service in" << device->info().friendlyName();
        }
    }

private slots:
    void onObjectsBrowsed(Herqq::Upnp::Av::HMediaBrowser*,QSet<QString>) {
        qDebug() << Q_FUNC_INFO;
    }

    void onBrowseFailed (Herqq::Upnp::Av::HMediaBrowser *) {
        qDebug() << Q_FUNC_INFO;
    }

    void onBrowseComplete (Herqq::Upnp::Av::HMediaBrowser *) {
        qDebug() << Q_FUNC_INFO;
    }

private:
    HMediaBrowser * browser;
};

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    HControlPointConfiguration ctrPtConf;
    HControlPoint ctrPt(ctrPtConf);
    Browser browser;

    QObject::connect(&ctrPt,
                     SIGNAL(rootDeviceOnline(Herqq::Upnp::HClientDevice*)),
                     &browser,
                     SLOT(browseDevice(Herqq::Upnp::HClientDevice*))
                     );

    ctrPt.init();

    return a.exec();
}

#include "main.moc"
ThomArmax commented 8 years ago

Actually, it's not a HUPnP issue. It is a Qt configuration issue. It seems that when Qt is not compiled with glib, this issue occur, but not when Qt is built against glib