summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authormarxin <mliska@suse.cz>2019-02-21 20:57:39 +0100
committermarxin <mliska@suse.cz>2019-02-27 07:45:57 +0100
commite5f665c7187b6934a71169cab5075f899150f17a (patch)
treea42da38f0076409975980452e8264a60d94f747d /servers
parentce114e35dda4b3f282abb458f8409db2369b279e (diff)
Fix -Wsign-compare warnings.
I decided to modify code in a defensive way. Ideally functions like size() or length() should return an unsigned type.
Diffstat (limited to 'servers')
-rw-r--r--servers/audio/audio_stream.cpp8
-rw-r--r--servers/audio_server.cpp4
2 files changed, 6 insertions, 6 deletions
diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp
index bd98619e92..12ee98595d 100644
--- a/servers/audio/audio_stream.cpp
+++ b/servers/audio/audio_stream.cpp
@@ -138,7 +138,7 @@ void AudioStreamPlaybackMicrophone::_mix_internal(AudioFrame *p_buffer, int p_fr
Vector<int32_t> buf = AudioDriver::get_singleton()->get_input_buffer();
unsigned int input_size = AudioDriver::get_singleton()->get_input_size();
int mix_rate = AudioDriver::get_singleton()->get_mix_rate();
- int playback_delay = MIN(((50 * mix_rate) / 1000) * 2, buf.size() >> 1);
+ unsigned int playback_delay = MIN(((50 * mix_rate) / 1000) * 2, buf.size() >> 1);
#ifdef DEBUG_ENABLED
unsigned int input_position = AudioDriver::get_singleton()->get_input_position();
#endif
@@ -152,11 +152,11 @@ void AudioStreamPlaybackMicrophone::_mix_internal(AudioFrame *p_buffer, int p_fr
for (int i = 0; i < p_frames; i++) {
if (input_size > input_ofs) {
float l = (buf[input_ofs++] >> 16) / 32768.f;
- if (input_ofs >= buf.size()) {
+ if ((int)input_ofs >= buf.size()) {
input_ofs = 0;
}
float r = (buf[input_ofs++] >> 16) / 32768.f;
- if (input_ofs >= buf.size()) {
+ if ((int)input_ofs >= buf.size()) {
input_ofs = 0;
}
@@ -168,7 +168,7 @@ void AudioStreamPlaybackMicrophone::_mix_internal(AudioFrame *p_buffer, int p_fr
}
#ifdef DEBUG_ENABLED
- if (input_ofs > input_position && (input_ofs - input_position) < (p_frames * 2)) {
+ if (input_ofs > input_position && (int)(input_ofs - input_position) < (p_frames * 2)) {
print_verbose(String(get_class_name()) + " buffer underrun: input_position=" + itos(input_position) + " input_ofs=" + itos(input_ofs) + " input_size=" + itos(input_size));
}
#endif
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index a2e5813a4f..df6218ac79 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -91,10 +91,10 @@ void AudioDriver::input_buffer_init(int driver_buffer_frames) {
void AudioDriver::input_buffer_write(int32_t sample) {
input_buffer.write[input_position++] = sample;
- if (input_position >= input_buffer.size()) {
+ if ((int)input_position >= input_buffer.size()) {
input_position = 0;
}
- if (input_size < input_buffer.size()) {
+ if ((int)input_size < input_buffer.size()) {
input_size++;
}
}