can't write to QIODevice timely.
-
pcm’s length nbytes = 4096,nsize = 2048.
when I set periodSize = 4096 , there is a murmur.
when I set periodSize = 2048, write two times , there is noise. but when I write the first 2048 B , or the last 2048 B independently, it is clear, but I clearly feels like it is fast forwarding.my code as fllowing:
void AudioDevice::device_out(const char* pcm,qint64 nbytes)
{
//int32_t delay = 1000000 / (double) audioOut->format().sampleRate();
int32_t nsize = audioOut->periodSize();
int32_t nleft = nbytes;
int32_t nb = 0;while( 0 != nleft){ if(audioOut->bytesFree() >= nsize){ nleft = (nleft > nsize) ? nsize : nleft; nb += audio_device->write(pcm + nb, nleft); nleft = nbytes - nb; } else av_usleep(10); }
}
-
Hi and welcome to devnet,
What are you writing to ?
What does this QIODevice represent ?
Which OS are you on ?
Which version of Qt are you using ?
What exactly are you trying to achieve ? -
... and please properly format your code with the code tags so others can read it.