Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. can't write to QIODevice timely.
Forum Updated to NodeBB v4.3 + New Features

can't write to QIODevice timely.

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 274 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QTier
    wrote on last edited by
    #1

    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);
    }
    

    }

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        ... and please properly format your code with the code tags so others can read it.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved