
Originally Posted by
d_stranz
I assume you meant
QIODevice. It would be nice if you could post your code for that to help others who might experience the same problem in the future and come across this thread looking for an answer.
The siruation was roughly as sketched below, a derived class from QIODevice was used and sound was output under Linux and silence was output under Windows
Under windows, the AudioSink that was use to embed the derived QIODevice class gave state Idle under Window and Active under Linux
The read function implemented in the derived QIOdevice class always gives the required amount of bytes back, taken from abuffer and a shortage, if appearing, filled with o bytes.
The original version differs from the one given below by not having impmented the "bytesAvailable" function and the "sze" function.
After implementing the bytesAvailable function itworked fine. Appparently the Windows version of AudioSink - when started- first looks at the bytesAvailable function, while the
same class in the Linux version does not.
The amount returned by the bytesAvailable function did not matter, as long as the (virtual) function is reimplemented and returns a value > 0 it works fine (again, given that the read function always returns the
requested amount
In both cases it was version 6.8.1.
Qt_AudioDevice::~Qt_AudioDevice () {
close ();
}
void Qt_AudioDevice::start () {
}
// we always return "maxSize" bytes
qint64 Qt_AudioDevice::readData (char* buffer, qint64 maxSize) {
// "maxSize" is the requested size in bytes
// "amount" is in uint8_t's
amount = Buffer -> getDataFromBuffer (buffer, maxSize);
if (amount < maxSize) {
for (int i = amount; i < maxSize; i ++)
buffer [i] = (char)(0);
}
}
// usused here
qint64 Qt_AudioDevice::writeData (const char* data, qint64 len) {
Q_UNUSED (data);
Q_UNUSED (len);
return 0;
}
qint64 Qt_AudioDevice::bytesAvailable () const {
return 32768;
}
Qt_AudioDevice::~Qt_AudioDevice () {
close ();
}
void Qt_AudioDevice::start () {
bool b = open (QIODevice::ReadOnly);
}
// we always return "maxSize" bytes
qint64 Qt_AudioDevice::readData (char* buffer, qint64 maxSize) {
// "maxSize" is the requested size in bytes
// "amount" is in uint8_t's
amount = Buffer -> getDataFromBuffer (buffer, maxSize);
if (amount < maxSize) {
for (int i = amount; i < maxSize; i ++)
buffer [i] = (char)(0);
}
}
// usused here
qint64 Qt_AudioDevice::writeData (const char* data, qint64 len) {
Q_UNUSED (data);
Q_UNUSED (len);
return 0;
}
qint64 Qt_AudioDevice::bytesAvailable () const {
return 32768;
}
To copy to clipboard, switch view to plain text mode
Bookmarks