mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-24 21:53:37 +02: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
@@ -76,8 +76,10 @@ CSFML_AUDIO_API void sfSoundRecorder_destroy(sfSoundRecorder* soundRecorder);
|
||||
/// \param soundRecorder Sound recorder object
|
||||
/// \param sampleRate Desired capture rate, in number of samples per second
|
||||
///
|
||||
/// \return True, if start of capture was successful
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_AUDIO_API void sfSoundRecorder_start(sfSoundRecorder* soundRecorder, unsigned int sampleRate);
|
||||
CSFML_AUDIO_API sfBool sfSoundRecorder_start(sfSoundRecorder* soundRecorder, unsigned int sampleRate);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Stop the capture of a sound recorder
|
||||
@@ -132,5 +134,56 @@ CSFML_AUDIO_API sfBool sfSoundRecorder_isAvailable(void);
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_AUDIO_API void sfSoundRecorder_setProcessingInterval(sfSoundRecorder* soundRecorder, sfTime interval);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a list of the names of all availabe audio capture devices
|
||||
///
|
||||
/// This function returns an array of strings (null terminated),
|
||||
/// containing the names of all availabe audio capture devices.
|
||||
/// If no devices are available then NULL is returned.
|
||||
///
|
||||
/// \param count Pointer to a variable that will be filled with the number of modes in the array
|
||||
///
|
||||
/// \return An array of strings containing the names
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_AUDIO_API const char** sfSoundRecorder_getAvailableDevices(size_t* count);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the name of the default audio capture device
|
||||
///
|
||||
/// This function returns the name of the default audio
|
||||
/// capture device. If none is available, NULL is returned.
|
||||
///
|
||||
/// \return The name of the default audio capture device (null terminated)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_AUDIO_API const char* sfSoundRecorder_getDefaultDevice();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the audio capture device
|
||||
///
|
||||
/// This function sets the audio capture device to the device
|
||||
/// with the given name. It can be called on the fly (i.e:
|
||||
/// while recording). If you do so while recording and
|
||||
/// opening the device fails, it stops the recording.
|
||||
///
|
||||
/// \param soundRecorder Sound recorder object
|
||||
/// \param The name of the audio capture device
|
||||
///
|
||||
/// \return sfTrue, if it was able to set the requested device
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_AUDIO_API sfBool sfSoundRecorder_setDevice(sfSoundRecorder* soundRecorder, const char* name);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the name of the current audio capture device
|
||||
///
|
||||
/// \param soundRecorder Sound recorder object
|
||||
///
|
||||
/// \return The name of the current audio capture device
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_AUDIO_API const char* sfSoundRecorder_getDevice(sfSoundRecorder* soundRecorder);
|
||||
|
||||
|
||||
#endif // SFML_SOUNDRECORDER_H
|
||||
@@ -258,8 +258,6 @@ CSFML_GRAPHICS_API sfBool sfRenderWindow_setActive(sfRenderWindow* renderWindow,
|
||||
/// is free to deny the request.
|
||||
/// This is not to be confused with sfWindow_setActive().
|
||||
///
|
||||
/// \see hasFocus
|
||||
///
|
||||
///////////////////////////////////////////////////////////
|
||||
CSFML_GRAPHICS_API void sfRenderWindow_requestFocus(sfRenderWindow* renderWindow);
|
||||
|
||||
@@ -271,7 +269,6 @@ CSFML_GRAPHICS_API void sfRenderWindow_requestFocus(sfRenderWindow* renderWindow
|
||||
/// events.
|
||||
///
|
||||
/// \return True if window has focus, false otherwise
|
||||
/// \see requestFocus
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_GRAPHICS_API sfBool sfRenderWindow_hasFocus(const sfRenderWindow* renderWindow);
|
||||
|
||||
@@ -370,8 +370,6 @@ CSFML_WINDOW_API sfBool sfWindow_setActive(sfWindow* window, sfBool active);
|
||||
/// is free to deny the request.
|
||||
/// This is not to be confused with sfWindow_setActive().
|
||||
///
|
||||
/// \see hasFocus
|
||||
///
|
||||
///////////////////////////////////////////////////////////
|
||||
CSFML_WINDOW_API void sfWindow_requestFocus(sfWindow* window);
|
||||
|
||||
@@ -383,7 +381,6 @@ CSFML_WINDOW_API void sfWindow_requestFocus(sfWindow* window);
|
||||
/// events.
|
||||
///
|
||||
/// \return True if window has focus, false otherwise
|
||||
/// \see requestFocus
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_WINDOW_API sfBool sfWindow_hasFocus(const sfWindow* window);
|
||||
|
||||
@@ -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