SFML community forums

Help => Audio => Topic started by: tienery on February 23, 2016, 08:51:39 pm

Title: SoundRecorder::getAvailableDevices() only prints "true"
Post by: tienery on February 23, 2016, 08:51:39 pm
Using the sf::SoundRecorder::getAvailableDevices() seems to be only printing "true" in the output:

(http://i.imgur.com/9YqlZ0O.png)

The implementation is in C++, because Haxe does not handle std::vector's that well, but whether this is a bug in the core or just simply my implementation I'm unsure. The below code is the C++ implementation by extracting the results of the getAvailableDevices() function and adding each element into a native Haxe Array. I would not have thought this would affect the output of the results, but "true" is all I'm getting, which seems rather unusual.

Calling getDefaultDevice(), however, does get the result you expect.

    Array< ::String > SoundHelper::getAvailableDevices()
    {
        std::vector<std::string> devices = sf::SoundRecorder::getAvailableDevices();
        Array< ::String > values = Array_obj< ::String >::__new();
       
        for (int i = 0; i < devices.size(); i++)
        {
            const char* n_v = devices[i].c_str();
            String v = n_v;
            values->push(v);
        }
       
        return values;
    }
Title: Re: SoundRecorder::getAvailableDevices() only prints "true"
Post by: Nexus on February 23, 2016, 09:17:41 pm
It would be interesting to reproduce this issue in a minimal C++ application without Haxe, to verify it's a problem in SFML. See also this post (http://en.sfml-dev.org/forums/index.php?topic=5559.msg36368#msg36368).
Title: Re: SoundRecorder::getAvailableDevices() only prints "true"
Post by: tienery on February 23, 2016, 10:26:42 pm
Okay, yeah, I have done so but have been getting different results than before. Instead of three "true"'s I get nothing:

std::vector<std::string> values = sf::SoundRecorder::getAvailableDevices();
std::cout << values.size();
 

Result:

(http://i.imgur.com/WaTxArh.png)
Title: Re: SoundRecorder::getAvailableDevices() only prints "true"
Post by: Notion on November 01, 2019, 04:01:56 pm
Very same problem here, while isAvailable() returns true, the vector<std::string> has a size of 0. Any way to solve or workaround? Or does audio recording simply not work?