Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, January 2007
Strange problem with QSound and NAS


Message 1 in thread

Hi There,

I just made a little application to try to play a file. I have NAS 1.8
compiled and installed on the same box (SUSE 10.1, gcc/g++ 4.0.2 running on
a Pentium 2GHz i386).

The code is pretty simple (it is not nice, I just started to play with
that).

What happens is that when the play() method is called, I got the following
error message (I started nasd before):
Audio Error of failed request:  BadBucket (invalid Bucket parameter)
  Major opcode of failed request:  7 (Au_GetBucketAttributes)
  Serial number of failed request:  2
  Current serial number in output stream:  2

What is this?

On the other hand, I found that on Windows the isFinished method always
returns true (even when playing a five minutes wav). What is wrong with that
and how should that be handled?

Thanks,
Sandor


#include <QCoreApplication>

#include <iostream>
#include <QSound>
#include <QThread>

class SleeperThread : public QThread {
public:
	static void SleepMs(const unsigned long &msecs)
{QThread::msleep(msecs);}
	static void SleepS(const unsigned long &secs) {QThread::msleep(secs
* 1000);}
};

int main(int argc, char *argv[]) {
    QCoreApplication app(argc, argv);
    
	if (!QSound::isAvailable()) {
		printf("Qt Sound is not available.\n");
		return -1;
	}

	printf("Qt Sound is available.\n\n");

	printf("Playing:\n");
	
	for (int i = 1; i < argc; i++) {
		printf("%s\n", argv[i]);
		QSound Sound(argv[i]);
		Sound.setLoops(1);
		printf("Loops:%d\n", Sound.loops());
		Sound.play();
		printf("Started to play\n");
		while (!Sound.isFinished()) {
			printf("Still playing...\n");
			SleeperThread::SleepMs(1000);
		}
		SleeperThread::SleepMs(1000);
		Sound.stop();
	}

    
    return 0;
}