Results 1 to 6 of 6

Thread: Phonon on multiple threads

  1. #1
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Phonon on multiple threads

    Hi all,
    yesterday i got multiple instances of phonon playing on the same main thread without problems, but if this happen on differents threads, its simply crash:

    X Error: BadDrawable (invalid Pixmap or Window parameter) 9
    Extension: 140 (Uknown extension)
    Minor opcode: 9 (Unknown request)
    Resource id: 0x3400590

    What do i need to get it working properly?
    protect X11 from concurrent rendering?

    ** Im using phonon-4.2 with gstreamer backend.

    thanks in advance,
    Rafael Savignon.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Phonon on multiple threads

    You can't access widgets (like the VideoWidget from Phonon) from non-main thread and there is no way around it currently. You have to do the playing in the main thread.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    Savignon (25th February 2009)

  4. #3
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Phonon on multiple threads

    I was taking a look at phonon backend implementation of gstreamer and it's seems to be using pixmap in some way to render video frames on to VideoWidget, and this could be the reason why this kind of problem is happening, maybe another backend could use diferent rendering mechanism to avoid this concurrence problem, like using non-platform dependent rendering resource, as same as we use QImage instead of QPixmap for rendering ?

    thanks,
    Rafael.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Phonon on multiple threads

    QImage doesn't use GUI resources, it's just a data object. With Phonon eventually you'll have to access gui resources which is a straight way to a crash when done from a worker thread. Why do you need to do use Phonon from another thread?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #5
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Phonon on multiple threads

    My application has a "event thread" that creates several "media objects", which are phonon objects. Thus, they will be child of that "event thread" and not of the gui-thread.

    I was wondering, if i move the phonon objects to gui-thread could solve my problem, calling:

    phononObj->moveToThread(QApplication::instance()->thread());

    catch the QEvent::ThreadChange , notifying QApplication Thread that its has a new QObject on its adress space, after that controll the moved phononObj trought signals/slots.

    is it possible ?, if yes does exist any other way to bypass it ?
    many thanks,
    Rafael.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Phonon on multiple threads

    Quote Originally Posted by Savignon View Post
    My application has a "event thread" that creates several "media objects", which are phonon objects. Thus, they will be child of that "event thread" and not of the gui-thread.
    They will be handled by the thread you tell Qt to use.

    I was wondering, if i move the phonon objects to gui-thread could solve my problem, calling:

    phononObj->moveToThread(QApplication::instance()->thread());
    Yes, you can. Just make sure the object doesn't have a parent and delete it when you don't need it to avoid a memory leak (or reparent it to an object from within the main thread).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 8
    Last Post: 27th March 2013, 11:51
  2. I cannot run the phonon demos in the PXA270!Can someone help me?
    By Justin_W in forum Qt for Embedded and Mobile
    Replies: 8
    Last Post: 19th February 2010, 10:14
  3. Phonon issues with DirectSound9
    By Zoltán in forum Qt Programming
    Replies: 2
    Last Post: 2nd February 2009, 02:48
  4. Waiting for multiple threads
    By Bebee in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2008, 17:21
  5. Organizing multiple threads
    By vratojr in forum Qt Programming
    Replies: 3
    Last Post: 25th May 2006, 09:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.