Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QAudioDeviceInfo - no formats available



  • Hi,

    I wrote a simple test code
    @ QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);

    foreach(QAudioDeviceInfo deviceInfo, devices)
    {
        printf("Name: %s\n", deviceInfo.deviceName().toLatin1().constData());
    
        printList(deviceInfo.supportedByteOrders(),  "Orders: ");
        printList(deviceInfo.supportedChannelCounts(),"Channs: ");
        printList(deviceInfo.supportedCodecs(),      "Codecs: ");
        printList(deviceInfo.supportedSampleRates(), "Rates : ");
        printList(deviceInfo.supportedSampleSizes(), "Sizes : ");
        printList(deviceInfo.supportedSampleTypes(), "Types : ");
    }
    

    @

    Being run on my PC (WinXP SP3), it prints valid information (two devices, about 20 formats per each). But on my friend's PC (Windows 7) it prints one device (Logitech webcam) and NO formats for it!

    It's interesting that on friend's PC webcam's name starts with zero character. If we see Qt's sources, we can read
    @void QAudioDeviceInfoInternal::updateLists()
    {
    ....
    WAVEINCAPS woc;
    unsigned long iNumDevs,i;
    iNumDevs = waveInGetNumDevs();
    for(i=0;i<iNumDevs;i++) {
    if(waveInGetDevCaps(i, &woc, sizeof(WAVEINCAPS))
    == MMSYSERR_NOERROR) {
    tmp = QString((const QChar *)woc.szPname);
    if(tmp.compare(device) == 0) { // <---
    match = true;
    fmt = woc.dwFormats;
    break;
    }
    if(base) {
    match = true;
    fmt = woc.dwFormats;
    break;
    }
    }
    }@

    I surmise, the string comparsion fails here.

    How to avoid it???

    Thanks for all!


Log in to reply