Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-42648

Windows: Wrong sample rates list and wrong nearestFormat decision

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.4.2
    • 5.3.2
    • Multimedia
    • None
    • Windows 7 64bit
    • 07606dde9a1f6b89f582ff8f1fbc53e2d4eb2c22

    Description

      On Windows 7 64bit, using QAudioOutput, trying to play the attached WAV file.
      It's a crappy audio: 6000Hz, 1 channel.
      The playback works fine on Linux with my code.
      Also, it plays fine on Windows with the 'player' example which uses the QMediaPlayer class.

      Here's the issue: QAudioDeviceInfo::isFormatSupported returns false on the file, cause on my audio card (M-Audio Fast Track Pro) the accepted sample rates go from 8000 to 96000.
      After that, I call QAudioDeviceInfo::nearestFormat to adjust the sample rate and it returns a sample rate of 48000 (instead of eventually 8000) !!

      In any case, this is all wrong. When I used my native implementation on Qt4, I went directly on WAVEOUT and I could play that file.
      This code didn't give any error on a sample rate == 6000:

      HWAVEOUT dev;
      WAVEFORMATEX fmt;
      fmt.wFormatTag = WAVE_FORMAT_PCM;
      fmt.wBitsPerSample = 16;
      fmt.nChannels = 1;
      fmt.nSamplesPerSec = (unsigned long)(6000);
      fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample/8;
      fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nChannels * fmt.wBitsPerSample/8;

      waveOutOpen (&dev, WAVE_MAPPER, &fmt, (DWORD)wave_callback, 0, CALLBACK_FUNCTION))

      So there are 2 issues here:

      • QAudioDeviceInfo stores wrong information of the actually supported sample rates. The last lines of code of QWindowsAudioDeviceInfo::updateLists() is this:
        if (sampleRatez.count() > 0)
        sampleRatez.prepend(8000);
        Guys, seriously ? This is blind shooting code !
      • QAudioDeviceInfo::nearestFormat should return the nearest format, and not a random one

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ylopes Yoann Lopes
            mcallegari79 Massimo Callegari
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes