Results 1 to 3 of 3

Thread: Phonon issues with DirectSound9

  1. #1
    Join Date
    Jan 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Phonon issues with DirectSound9

    Hi,

    I have two problems with using Phonon on Windows XP with Direct Sound 9 backend.
    I'm using Qt version 4.4.1 that I compiled on my own machine using Visual Studio 2005 SP1. The phonon framework compiled alright and has DS9 backend (DirectX SDK: February 2007).

    First problem (and most important):

    Whenever I play a sound file (PCM or MP3, doesn't matter) using Phonon, the sound is played successfully, but a thread remains open even after the MediaObject is deleted. This happens every single time a sound is played. I want to be able to play multiple sounds at once, so I create a new path (using a new MediaObject) for each sound file I play. Analyzing the application threads (using ProcessExplorer, or the Visual Studio threads window) I get the following after playing 10 times a sound.

    RPCRT4.dll!I_RpcBCacheFree+0x5ea
    RPCRT4.dll!I_RpcBCacheFree+0x5ea
    PhononMixingTest.exe!WinMainCRTStartup
    quartz.dll!CCallbackThread::ThreadProc() + 0xeb bytes
    quartz.dll!CCallbackThread::ThreadProc() + 0xeb bytes
    quartz.dll!CCallbackThread::ThreadProc() + 0xeb bytes
    quartz.dll!CCallbackThread::ThreadProc() + 0xeb bytes
    quartz.dll!CCallbackThread::ThreadProc() + 0xeb bytes
    quartz.dll!CCallbackThread::ThreadProc() + 0xeb bytes
    quartz.dll!CCallbackThread::ThreadProc() + 0xeb bytes
    quartz.dll!CCallbackThread::ThreadProc() + 0xeb bytes
    quartz.dll!CCallbackThread::ThreadProc() + 0xeb bytes
    quartz.dll!CCallbackThread::ThreadProc() + 0xeb bytes
    quartz.dll!CCallbackThread::ThreadProc() + 0xeb bytes
    ADVAPI32.dll!RegDeleteKeyW+0xfd

    The first time I play a sound it leaves 2 hanging threads, after that only 1 for each time a sound is played. In CCallbackThread::ThreadProc() it hangs on a call to WaitForMultipleObjects.

    Here is the code that plays the sound file:

    Qt Code:
    1. void PhononMixingTest::PlayClicked()
    2. {
    3. QString soundFilePath = ui.fileLineEdit_->text();
    4. if (soundFilePath.isEmpty())
    5. {
    6. return;
    7. }
    8.  
    9. Phonon::AudioOutput* audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    10. Phonon::MediaObject* mediaObject = new Phonon::MediaObject(this);
    11. Phonon::createPath(mediaObject, audioOutput);
    12. connect (mediaObject, SIGNAL(finished()), this, SLOT(SoundFinishedPlaying()));
    13. mediaObject->setCurrentSource(soundFilePath);
    14. mediaObject->play();
    15. }
    16.  
    17. void PhononMixingTest::SoundFinishedPlaying()
    18. {
    19. Phonon::MediaObject* mediaObject = qobject_cast<Phonon::MediaObject*>(sender());
    20. if (mediaObject)
    21. {
    22. mediaObject->stop();
    23. mediaObject->clearQueue();
    24. mediaObject->deleteLater();
    25. }
    26. }
    To copy to clipboard, switch view to plain text mode 

    I do not know if I'm doing this the right way, because I don't fully understand who is responsible for the ownership of the MediaObject and the AudioOutput. By the way, the threads remain open even after the parent of the MediaObject and AudioOutput is deleted.

    Second problem:

    Sometimes when playing multiple sounds at once in debug mode, I get the following assert failure:
    ASSERT: "!isEmpty()" in file ../../src/corelib/tools/qlist.h, line 230

    The call stack is given below:

    > QtCored4.dll!qt_message_output(QtMsgType msgType=QtFatalMsg, const char * buf=0x02d1dc40) Line 2035 C++
    QtCored4.dll!qFatal(const char * msg=0x67234b2c, ...) Line 2241 + 0xe bytes C++
    QtCored4.dll!qt_assert(const char * assertion=0x010b257c, const char * file=0x010b1e78, int line=230) Line 1809 + 0x16 bytes C++
    phonon_ds9d4.dll!QList<Phonon::DS9::WorkerThread:: Work>::first() Line 230 + 0x2d bytes C++
    phonon_ds9d4.dll!QList<Phonon::DS9::WorkerThread:: Work>::takeFirst() Line 392 + 0x2d bytes C++
    phonon_ds9d4.dll!QQueue<Phonon::DS9::WorkerThread: :Work>::dequeue() Line 40 + 0x1c bytes C++
    phonon_ds9d4.dll!Phonon::DS9::WorkerThread::dequeu eWork() Line 56 + 0xf bytes C++
    phonon_ds9d4.dll!Phonon::DS9::WorkerThread::handle Task() Line 184 + 0xf bytes C++
    phonon_ds9d4.dll!Phonon::DS9::WorkerThread::run() Line 79 C++
    QtCored4.dll!QThreadPrivate::start(void * arg=0x00b4b5a8) Line 235 C++
    msvcr80d.dll!__beginthreadex() + 0x221 bytes
    msvcr80d.dll!__beginthreadex() + 0x1c7 bytes
    kernel32.dll!_BaseThreadStart@8() + 0x37 bytes

    It seems to be some kind of synchronization problem for accessing the phonon work queue.

    Maybe I'm using the Phonon framework the wrong way. So if you have any ideea about what I'm doing wrong or what should I try to fix these problems, I would much appreciate your help. Thank you.

  2. #2
    Join Date
    Jan 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Follow-up

    I've tried this also with Qt 4.5.0-beta1 together with DirectX SDK November 2008 (latest) and it behaves the same (both for debug and release configurations).
    Has anyone tried this? Does it happen to you also?

  3. #3
    Join Date
    Jan 2008
    Location
    Russia, Chelyabinsk
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Follow-up

    i have some troubles with phonon, too.

    Qt 4.4.3 / MS VC++ 2008 Express Edition / Windows Vista

    I've tried using phonon 4.3.0 from kde.org. nothing happes

    I've got memory leak.

    wav file: 4 bit per sample, 22050 Hz, codec IMA ADPCM, bitrate 88 kbps
    Qt Code:
    1. QString mp = "F:/sounds/" + filename;
    2. _CrtMemState _state, _state2, _s3;
    3. _CrtMemCheckpoint(&_state);
    4.  
    5. _music->setCurrentSource(mp);
    6.  
    7. _CrtMemCheckpoint(&_state2);
    8.  
    9. _CrtMemDifference(&_s3, &_state, &_state2);
    10. _CrtMemDumpStatistics(&_s3);
    11. _CrtMemDumpAllObjectsSince (&_state);
    12.  
    13. _music->play();
    To copy to clipboard, switch view to plain text mode 

    Memory dump:
    Qt Code:
    1. 0 bytes in 0 Free Blocks.
    2. 296 bytes in 7 Normal Blocks.
    3. 0 bytes in 0 CRT Blocks.
    4. 0 bytes in 0 Ignore Blocks.
    5. 0 bytes in 0 Client Blocks.
    6. Largest number used: 0 bytes.
    7. Total allocations: 4086 bytes.
    8. Dumping objects ->
    9. {218294} normal block at 0x00F34898, 40 bytes long.
    10. Data: < uM > 00 00 00 00 04 00 CD CD E8 75 4D 01 00 00 00 00
    11. {218293} normal block at 0x00F34C60, 40 bytes long.
    12. Data: < > 01 00 00 00 05 00 00 00 01 00 00 00 04 00 00 00
    13. {218292} normal block at 0x033B6A60, 66 bytes long.
    14. Data: < rj; > 01 00 00 00 17 00 00 00 17 00 00 00 72 6A 3B 03
    15. {218290} normal block at 0x00F34840, 40 bytes long.
    16. Data: < MM > 01 00 00 00 03 00 CD CD A8 4D 4D 01 00 00 00 00
    17. {218287} normal block at 0x00EE4D30, 12 bytes long.
    18. Data: <P > 50 A4 F3 00 B8 B0 F3 00 B8 B0 F3 00
    19. {218274} normal block at 0x00F346E0, 40 bytes long.
    20. Data: < MM > 02 00 00 00 02 00 CD CD A8 4D 4D 01 00 00 00 00
    21. {218270} normal block at 0x02FD2BD0, 128 bytes long.
    22. Data: < 6 + > 01 00 00 00 36 00 00 00 18 00 00 00 E2 2B FD 02
    23. {218267} normal block at 0x0341DB38, 30 bytes long.
    24. Data: < J A > 01 00 00 00 05 00 00 00 05 00 00 00 4A DB 41 03
    25. {218266} normal block at 0x030FD2D0, 28 bytes long.
    26. Data: < > 01 00 00 00 04 00 00 00 04 00 00 00 E2 D2 0F 03
    27. {218265} normal block at 0x00F41AB0, 88 bytes long.
    28. Data: < 0g 0g> 01 00 00 00 D0 D2 0F 03 20 16 30 67 20 16 30 67
    29. {218217} normal block at 0x0339FF10, 40 bytes long.
    30. Data: <0Z > 30 5A 04 10 02 00 00 00 00 00 00 00 B0 1A F4 00
    31. Object dump complete.
    To copy to clipboard, switch view to plain text mode 
    I can do something wrong? Or this is phonon bug?
    So you can code punk?

Similar Threads

  1. 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, 11:14

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.