Commit 65ed768f authored by François Grisez's avatar François Grisez
Browse files

Change volume percentage variable type from double to float

parent aa8c0587
......@@ -578,7 +578,7 @@ MS2_PUBLIC void audio_stream_mute_rtp(AudioStream *stream, bool_t val);
* @param stream The audio stream.
* @param gain Percentage of the max supported volume gain. Valid values are in [0.0 : 1.0].
*/
MS2_PUBLIC void audio_stream_set_sound_card_input_gain(AudioStream *stream, double gain);
MS2_PUBLIC void audio_stream_set_sound_card_input_gain(AudioStream *stream, float gain);
/**
* @brief Get microphone volume gain.
......@@ -587,7 +587,7 @@ MS2_PUBLIC void audio_stream_set_sound_card_input_gain(AudioStream *stream, doub
* @return double Volume gain in percentage of the max suppored gain.
* Valid returned values are in [0.0 : 1.0]. A negative value is returned in case of failure.
*/
MS2_PUBLIC double audio_stream_get_sound_card_input_gain(const AudioStream *stream);
MS2_PUBLIC float audio_stream_get_sound_card_input_gain(const AudioStream *stream);
/**
* @brief Set speaker volume gain.
......@@ -597,7 +597,7 @@ MS2_PUBLIC double audio_stream_get_sound_card_input_gain(const AudioStream *stre
* @param stream The audio stream.
* @param gain Percentage of the max supported volume gain. Valid values are in [0.0 : 1.0].
*/
MS2_PUBLIC void audio_stream_set_sound_card_output_gain(AudioStream *stream, double volume);
MS2_PUBLIC void audio_stream_set_sound_card_output_gain(AudioStream *stream, float volume);
/**
* @brief Get speaker volume gain.
......@@ -606,7 +606,7 @@ MS2_PUBLIC void audio_stream_set_sound_card_output_gain(AudioStream *stream, dou
* @return Volume gain in percentage of the max suppored gain.
* Valid returned values are in [0.0 : 1.0]. A negative value is returned in case of failure.
*/
MS2_PUBLIC double audio_stream_get_sound_card_output_gain(const AudioStream *stream);
MS2_PUBLIC float audio_stream_get_sound_card_output_gain(const AudioStream *stream);
/**
* enable noise gate, must be done before start()
......
......@@ -272,17 +272,17 @@ typedef enum _MSRecorderState MSRecorderState;
/** Interface definitions for audio capture */
/* Start numbering from the end for hacks */
#define MS_AUDIO_CAPTURE_SET_VOLUME_GAIN \
MS_FILTER_METHOD(MSFilterAudioCaptureInterface, 0, double)
MS_FILTER_METHOD(MSFilterAudioCaptureInterface, 0, float)
#define MS_AUDIO_CAPTURE_GET_VOLUME_GAIN \
MS_FILTER_METHOD(MSFilterAudioCaptureInterface, 1, double)
MS_FILTER_METHOD(MSFilterAudioCaptureInterface, 1, float)
#define MS_AUDIO_CAPTURE_FORCE_SPEAKER_STATE \
MS_FILTER_METHOD(MSFilterAudioCaptureInterface, 255, bool_t)
/** Interface definitions for audio playback */
#define MS_AUDIO_PLAYBACK_SET_VOLUME_GAIN \
MS_FILTER_METHOD(MSFilterAudioPlaybackInterface, 0, double)
MS_FILTER_METHOD(MSFilterAudioPlaybackInterface, 0, float)
#define MS_AUDIO_PLAYBACK_GET_VOLUME_GAIN \
MS_FILTER_METHOD(MSFilterAudioPlaybackInterface, 1, double)
MS_FILTER_METHOD(MSFilterAudioPlaybackInterface, 1, float)
/** Interface definitions for audio encoder */
#define MS_AUDIO_ENCODER_SET_PTIME \
......
......@@ -614,7 +614,7 @@ static int pulse_read_get_nchannels(MSFilter *f, void *arg){
static int pulse_read_set_volume(MSFilter *f, void *arg) {
Stream *s = (Stream *)f->data;
const double *volume = (const double *)arg;
const float *volume = (const float *)arg;
bool_t success;
ms_filter_lock(f);
success = stream_set_volume(s, *volume);
......@@ -625,9 +625,12 @@ static int pulse_read_set_volume(MSFilter *f, void *arg) {
static int pulse_read_get_volume(MSFilter *f, void *arg) {
Stream *s = (Stream *)f->data;
bool_t success;
double volume;
ms_filter_lock(f);
success = stream_get_volume(s, (double *)arg);
success = stream_get_volume(s, &volume);
ms_filter_unlock(f);
if(success) *(float *)arg = (float)volume;
return success ? 0 : -1;
}
......
......@@ -1420,7 +1420,7 @@ void audio_stream_set_mic_gain(AudioStream *stream, float gain){
"Use audio_stream_enable_gain_control() before starting the stream.");
}
void audio_stream_set_sound_card_input_gain(AudioStream *stream, double volume) {
void audio_stream_set_sound_card_input_gain(AudioStream *stream, float volume) {
if (stream->soundread) {
if(ms_filter_implements_interface(stream->soundread, MSFilterAudioCaptureInterface)) {
ms_filter_call_method(stream->soundread, MS_AUDIO_CAPTURE_SET_VOLUME_GAIN, &volume);
......@@ -1430,23 +1430,23 @@ void audio_stream_set_sound_card_input_gain(AudioStream *stream, double volume)
}
}
double audio_stream_get_sound_card_input_gain(const AudioStream *stream) {
double volume;
float audio_stream_get_sound_card_input_gain(const AudioStream *stream) {
float volume;
if(stream->soundread == NULL) {
ms_error("Cannot get input volume: no input filter");
return -1.0;
return -1.0f;
}
if(!ms_filter_implements_interface(stream->soundread, MSFilterAudioCaptureInterface)) {
return -1.0;
return -1.0f;
}
if(ms_filter_call_method(stream->soundread, MS_AUDIO_CAPTURE_GET_VOLUME_GAIN, &volume) < 0) {
volume = -1.0;
volume = -1.0f;
}
return volume;
}
void audio_stream_set_sound_card_output_gain(AudioStream *stream, double volume) {
void audio_stream_set_sound_card_output_gain(AudioStream *stream, float volume) {
if (stream->soundwrite) {
if(ms_filter_implements_interface(stream->soundwrite, MSFilterAudioPlaybackInterface)) {
ms_filter_call_method(stream->soundwrite, MS_AUDIO_PLAYBACK_SET_VOLUME_GAIN, &volume);
......@@ -1456,18 +1456,18 @@ void audio_stream_set_sound_card_output_gain(AudioStream *stream, double volume)
}
}
double audio_stream_get_sound_card_output_gain(const AudioStream *stream) {
double volume;
float audio_stream_get_sound_card_output_gain(const AudioStream *stream) {
float volume;
if(stream->soundwrite == NULL) {
ms_error("Cannot get output volume: no output filter");
return -1.0;
return -1.0f;
}
if(!ms_filter_implements_interface(stream->soundwrite, MSFilterAudioCaptureInterface)) {
return -1.0;
return -1.0f;
}
if(ms_filter_call_method(stream->soundwrite, MS_AUDIO_PLAYBACK_GET_VOLUME_GAIN, &volume) < 0) {
volume = -1.0;
volume = -1.0f;
}
return volume;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment