Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/CSFML/Audio/SoundRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ CSFML_AUDIO_API bool sfSoundRecorder_isAvailable(void);
/// \return An array of strings containing the names
///
////////////////////////////////////////////////////////////
CSFML_AUDIO_API const char** sfSoundRecorder_getAvailableDevices(size_t* count);
CSFML_AUDIO_API const char* const* sfSoundRecorder_getAvailableDevices(size_t* count);

////////////////////////////////////////////////////////////
/// \brief Get the name of the default audio capture device
Expand Down
19 changes: 9 additions & 10 deletions src/CSFML/Audio/SoundRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,17 @@ bool sfSoundRecorder_isAvailable()


////////////////////////////////////////////////////////////
const char** sfSoundRecorder_getAvailableDevices(size_t* count)
const char* const* sfSoundRecorder_getAvailableDevices(size_t* count)
{
static std::vector<std::string> stringDevices = sf::SoundRecorder::getAvailableDevices();
static std::vector<const char*> cstringDevices;

if (cstringDevices.empty() && !stringDevices.empty())
static const auto cstringDevices = []
{
static const std::vector<std::string> stringDevices = sf::SoundRecorder::getAvailableDevices();
std::vector<const char*> devices;
devices.reserve(stringDevices.size());
for (const auto& stringDevice : stringDevices)
{
cstringDevices.push_back(stringDevice.c_str());
}
}
devices.push_back(stringDevice.c_str());
return devices;
}();

if (count)
*count = cstringDevices.size();
Expand All @@ -104,7 +103,7 @@ const char** sfSoundRecorder_getAvailableDevices(size_t* count)
////////////////////////////////////////////////////////////
const char* sfSoundRecorder_getDefaultDevice()
{
static std::string defaultDevice = sf::SoundRecorder::getDefaultDevice();
static const std::string defaultDevice = sf::SoundRecorder::getDefaultDevice();

return !defaultDevice.empty() ? defaultDevice.c_str() : nullptr;
}
Expand Down
11 changes: 5 additions & 6 deletions src/CSFML/Window/VideoMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ sfVideoMode sfVideoMode_getDesktopMode()
////////////////////////////////////////////////////////////
const sfVideoMode* sfVideoMode_getFullscreenModes(size_t* count)
{
static std::vector<sfVideoMode> modes;

// Populate the array on first call
if (modes.empty())
static const auto modes = []
{
std::vector<sfVideoMode> videomodes;
for (const auto& mode : sf::VideoMode::getFullscreenModes())
modes.push_back(convertVideoMode(mode));
}
videomodes.push_back(convertVideoMode(mode));
return videomodes;
}();

if (count)
*count = modes.size();
Expand Down
2 changes: 1 addition & 1 deletion src/CSFML/Window/Vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ sfVulkanFunctionPointer sfVulkan_getFunction(const char* name)
////////////////////////////////////////////////////////////
const char* const* sfVulkan_getGraphicsRequiredInstanceExtensions(size_t* count)
{
static std::vector<const char*> extensions = sf::Vulkan::getGraphicsRequiredInstanceExtensions();
static const std::vector<const char*> extensions = sf::Vulkan::getGraphicsRequiredInstanceExtensions();

if (count)
*count = extensions.size();
Expand Down