Answered
0
0

I was under the impression that a driver GUID would be the same if I were to ask for the GUID of the same driver multiple times. Consider the following program:

#include <fmod.hpp>
#include <fmod_errors.h>

#include <iostream>
#include <cstdio>

int main()
{
    FMOD_RESULT result;
    FMOD::System *system;
    unsigned int version = 0;
    int numOutDevices = 0;
    int numInDevices = 0;

    result = FMOD::System_Create(&system);      // Create the main system object.
    if (result != FMOD_OK)
    {
        std::cout << "System_Create failed: " << result << 
            " - " << FMOD_ErrorString(result) << std::endl;
        return 3;
    }

        if (system->getVersion(&version) != FMOD_OK || version < FMOD_VERSION)
    {
        std::cout << "Dynamic library does not match header!\n";
        return 1;
    }

    result = system->init(100, FMOD_INIT_NORMAL, 0);    // Initialize FMOD.
    if (result != FMOD_OK)
    {
        std::cout << "System init failed: " << result << 
            " - " << FMOD_ErrorString(result) << std::endl;

        return 2;
    }

    system->getNumDrivers(&numOutDevices);
    system->getRecordNumDrivers(&numInDevices);

    for (int i = 0; i < numOutDevices; ++i) {
        char name[100];
        FMOD_GUID guid;
        char guidString[38];

        system->getDriverInfo(i, name, sizeof(name), &guid);

        std::cout << "Out Device: " << name << "\n";

        sprintf(guidString, "{%08X-%04X-%04X-%02X%02X%02X%02X%02X%02X%02X%02X}",
            guid.Data1, guid.Data2, guid.Data3,
            guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
            guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);

        std::cout << guidString << std::endl;
    }

    return 0;
}

Just for example… one run of this code generates this for a specific device:

Out Device: KAVE XTD Headset Analog Surround 7.1
{9E358520-7FFD-0000-9812400000000000}

Then on the very next run, generates this:

Out Device: KAVE XTD Headset Analog Surround 7.1
{435A2060-7FFF-0000-9812400000000000}

Is this correct behavior?

  • You must to post comments
Best Answer
0
0

This is due to the Linux output modes not returning any GUID information, so your guid variable is retaining its uninitialized state. If you memset it before calling the function it will always come out as zero.

For Linux (as a work around) I’d recommend using the driver name directly (or as a hash) for the unique identifier.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.