mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-26 13:06:13 +01:00
Updated SoundRecorder to support multiple recording devices
This commit is contained in:
1 parent
302048d29e
commit
58781d458e
5 files changed
+104
-11
No files matched your search
@@ -48,9 +48,9 @@ void sfSoundRecorder_destroy(sfSoundRecorder* soundRecorder)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfSoundRecorder_start(sfSoundRecorder* soundRecorder, unsigned int sampleRate)
|
||||
sfBool sfSoundRecorder_start(sfSoundRecorder* soundRecorder, unsigned int sampleRate)
|
||||
{
|
||||
CSFML_CALL(soundRecorder, start(sampleRate));
|
||||
CSFML_CALL_RETURN(soundRecorder, start(sampleRate), sfFalse);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ unsigned int sfSoundRecorder_getSampleRate(const sfSoundRecorder* soundRecorder)
|
||||
////////////////////////////////////////////////////////////
|
||||
sfBool sfSoundRecorder_isAvailable(void)
|
||||
{
|
||||
return sf::SoundRecorder::isAvailable() ? sfTrue : sfFalse;
|
||||
return sf::SoundRecorder::isAvailable();
|
||||
}
|
||||
|
||||
|
||||
@@ -80,3 +80,48 @@ void sfSoundRecorder_setProcessingInterval(sfSoundRecorder* soundRecorder, sfTim
|
||||
{
|
||||
CSFML_CALL(soundRecorder, setProcessingInterval(interval));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const char** 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())
|
||||
{
|
||||
for (std::vector<std::string>::const_iterator it = stringDevices.begin(); it != stringDevices.end(); ++it)
|
||||
{
|
||||
cstringDevices.push_back(it->c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (count)
|
||||
*count = cstringDevices.size();
|
||||
|
||||
return !cstringDevices.empty() ? &cstringDevices[0] : NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const char* sfSoundRecorder_getDefaultDevice()
|
||||
{
|
||||
static std::string defaultDevice = sf::SoundRecorder::getDefaultDevice();
|
||||
|
||||
return !defaultDevice.empty() ? defaultDevice.c_str() : NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
sfBool sfSoundRecorder_setDevice(sfSoundRecorder* soundRecorder, const char* name)
|
||||
{
|
||||
CSFML_CALL_RETURN(soundRecorder, setDevice(name), sfFalse);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const char* sfSoundRecorder_getDevice(sfSoundRecorder* soundRecorder)
|
||||
{
|
||||
CSFML_CHECK(soundRecorder);
|
||||
|
||||
soundRecorder->DeviceName = soundRecorder->This.getDevice();
|
||||
|
||||
return soundRecorder->DeviceName.c_str();
|
||||
}
|
||||
@@ -88,7 +88,7 @@ private :
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Internal structure of sfPacket
|
||||
// Internal structure of sfSoundRecorder
|
||||
////////////////////////////////////////////////////////////
|
||||
struct sfSoundRecorder
|
||||
{
|
||||
@@ -101,6 +101,7 @@ struct sfSoundRecorder
|
||||
}
|
||||
|
||||
sfSoundRecorderImpl This;
|
||||
std::string DeviceName;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user