Results 1 to 4 of 4

Thread: QMediaPlayer - QThread::start: Failed to create thread

  1. #1
    Join Date
    Feb 2017
    Posts
    7
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default QMediaPlayer - QThread::start: Failed to create thread

    I develop an application which the user can play multiple sounds at the same time. For this I use QMediaPlayer in conjunction with a matrix to hold each sound separately. The code is simple, for each sound I use a code like this:

    Qt Code:
    1. media = new QMediaPlayer();
    2. media->setMedia(QUrl::fromLocalFile(QFileInfo("sound.mp3").absoluteFilePath()));
    3. media->play();
    To copy to clipboard, switch view to plain text mode 
    Everything is ok. But around playing the sound 115-125 (simultaneous sounds), the new sounds emit signal error(QMediaPlayer::ResourceError) with error code: QMediaPlayer::ResourceError - A media resource couldn't be resolved. Before emit error signal, it print on output this message: DirectShowPlayerService::doPlay: Unresolved error code 0x80004005 ()

    This is not a problem, because I delete those sounds as soon as I detect this error. The problem appears right after a couple of QMediaPlayer::ResourceError. If I create a new sound, an error message appear on output window: QThread::start: Failed to create thread. This error appear just after creating a new QMediaPlayer instance:

    Qt Code:
    1. qDebug() << "before media = new QMediaPlayer(); (FILE)";
    2. media = new QMediaPlayer();
    3. qDebug() << "after media = new QMediaPlayer(); (FILE)" << media->error
    To copy to clipboard, switch view to plain text mode 
    The output:

    before media = new QMediaPlayer(); (FILE)
    QThread::start: Failed to create thread
    after media = new QMediaPlayer(); (FILE) QMediaPlayer::NoError
    This last kind of QMediaPlayer instance emit no error. More than that, the state is QMediaPlayer::PlayingState. But if I try to delete it - delete(media) - or to set the media to a null QMediaContent - media->setMedia(QMediaContent()) - to make the player to discard all information relating to the current media source, the application freezes. Those two opperations works fine on he others sounds. If I don't delete this kind of QMediaPlayer, I end to have no room for sounds. Somehow QMediaPlayer has a limited number of instances and every QMediaPlayer that I cannot delete anymore fill this number and let no room for new instances of QMediaPlayer.

    The question is: how I can avoid this issue? If I limit the number of simultaneous sounds, what is the correct number of QMediaPlayer instances? If I set a limit, this limit can be too high for other machines. Or how to properly detect this malformed QMediaPlayer and properly delete it?

    Also, if I wait for the first QMediaPlayer::ResourceError signal to limit the number of sounds, this is sometimes too late, because the error signal is emitted a bit later and sometimes the application already create a malformed QMediaPlayer that I cannot delete anymore and this prevent the process to close.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QMediaPlayer - QThread::start: Failed to create thread

    Unresolved error code 0x80004005 ... This is not a problem
    This error code is due to some failure in a Microsoft COM module, probably DirectShow. Ignoring it probably results in all of the rest of your errors because the service is in an error state. By trying to play so many simultaneous sounds, you have probably reached some resource limit in the DirectShow server.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Feb 2017
    Posts
    7
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QMediaPlayer - QThread::start: Failed to create thread

    Quote Originally Posted by d_stranz View Post
    This error code is due to some failure in a Microsoft COM module, probably DirectShow. Ignoring it probably results in all of the rest of your errors because the service is in an error state. By trying to play so many simultaneous sounds, you have probably reached some resource limit in the DirectShow server.
    Thanks for the reply.
    When I create a new sound using QMediaPlayer() I am not ignoring this error. Like I say before, I delete this new sound because it emit error signal also. My plan was to use this signal to detect maximum number of sounds, but unfortunately this signal is emitted some times too late: user already request a new sound which can not be deleted.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QMediaPlayer - QThread::start: Failed to create thread

    When you are reaching the limitations of the underlying system, it is sometimes necessary to deal with that limitation on a lower level.

    E.g. by using the system framework directly or by using a different low level framework such as GStreamer.

    Cheers,
    _

Similar Threads

  1. Replies: 0
    Last Post: 1st April 2016, 06:38
  2. Replies: 1
    Last Post: 6th December 2015, 16:12
  3. Replies: 0
    Last Post: 15th October 2013, 09:32
  4. Replies: 1
    Last Post: 4th October 2012, 14:49
  5. QProcess - Failed to start
    By sankar in forum Qt Programming
    Replies: 8
    Last Post: 21st March 2011, 05:57

Tags for this Thread

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.