[Qt-interest] Phonon::MediaObject::setCurrentSource() sometimes hangs

Nikos Chantziaras realnc at arcor.de
Mon Mar 8 00:40:15 CET 2010


(I posted this on the kde-devel mailing list too.  I'm reposting here in 
hope someone might have an idea as to what's causing the problem.)


I've come across a weird problem with 
Phonon::MediaObject::setCurrentSource() sometimes hanging and never 
returning when used in combination with a QBuffer.  The code that hangs 
is this:


Phonon::MediaObject* getMedia(const QString& fname, int pos, int size)
{
   QFile file(fname);
   file.open(QIODevice::ReadOnly);
   file.seek(pos); // A *.wav file is embedded at that position
   Phonon::MediaObject* med = new Phonon::MediaObject(0);
   QBuffer* buf = new QBuffer(med);
   buf->setData(file.read(size)); // The embedded wav is 'size' bytes big
   Phonon::MediaSource src(buf);

   med->setCurrentSource(src);  // <-- This hangs

   return med;
}


Most of the time, the application hangs the second time the above gets 
called; med->setCurrentSource(src) never returns.  When the hang occurs, 
there's no CPU load, so I guess Phonon is waiting for something.

Everything works fine if I instead save file.read(size) into a new QFile 
and pass its fileName() to setCurrentSource().  However, in both cases, 
file.read(size) contains the exact same data.

Any hints as to what's going on?



More information about the Qt-interest-old mailing list