Hi all
I want to play some QSound objects via QThread but i couldnt do it.It make a failure notice.
It says ;
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QApplication(0xbefffd10), parent's thread is QThread(0x8d93a0), current thread is myThread(0xbAlignment trap: deneme (957) PC=01
efffcd0)
Bus error
void myThread::run()
{
printf("thread is running\n");
forever{
printf("thread is in forever loop\n");
mutex.lock();
bool MultiSound = this->MultiSound;
int SingleSType = this->SingleSType;
int mFrequency = this->mFrequency;
bool GSoundType= this->GSoundType;
mutex.unlock();
if(!MultiSound)
{
if(sound->isAvailable())
{
sound->play();
}
}
if(abort)
return;
}
mutex.lock();
if(!restart)
condition.wait(&mutex);
mutex.unlock();
}
QSound sound = new QSound("a.wav");;
void myThread::run()
{
printf("thread is running\n");
forever{
printf("thread is in forever loop\n");
mutex.lock();
bool MultiSound = this->MultiSound;
int SingleSType = this->SingleSType;
int mFrequency = this->mFrequency;
bool GSoundType= this->GSoundType;
mutex.unlock();
if(!MultiSound)
{
if(sound->isAvailable())
{
sound->play();
}
}
if(abort)
return;
}
mutex.lock();
if(!restart)
condition.wait(&mutex);
mutex.unlock();
}
To copy to clipboard, switch view to plain text mode
Do you have any suggestion?
Bookmarks