speaker-test: fix the verbose compilation warnings for latest gcc

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2023-08-30 12:51:16 +02:00
parent 1843540e27
commit ed98b06dc2

View file

@ -226,7 +226,7 @@ static int *order_channels(void)
{ {
/* create a (playback order => channel number) table with channels ordered /* create a (playback order => channel number) table with channels ordered
* according to channel_order[] values */ * according to channel_order[] values */
int i; unsigned int i;
int *ordered_chs; int *ordered_chs;
ordered_chs = calloc(channel_map->channels, sizeof(*ordered_chs)); ordered_chs = calloc(channel_map->channels, sizeof(*ordered_chs));
@ -245,7 +245,7 @@ static int *order_channels(void)
static int get_speaker_channel(int chn) static int get_speaker_channel(int chn)
{ {
#ifdef CONFIG_SUPPORT_CHMAP #ifdef CONFIG_SUPPORT_CHMAP
if (channel_map_set || (ordered_channels && chn >= channel_map->channels)) if (channel_map_set || (ordered_channels && (unsigned int)chn >= channel_map->channels))
return chn; return chn;
if (ordered_channels) if (ordered_channels)
return ordered_channels[chn]; return ordered_channels[chn];
@ -271,7 +271,7 @@ static const char *get_channel_name(int chn)
#ifdef CONFIG_SUPPORT_CHMAP #ifdef CONFIG_SUPPORT_CHMAP
if (channel_map) { if (channel_map) {
const char *name = NULL; const char *name = NULL;
if (chn < channel_map->channels) if ((unsigned int)chn < channel_map->channels)
name = snd_pcm_chmap_long_name(channel_map->pos[chn]); name = snd_pcm_chmap_long_name(channel_map->pos[chn]);
return name ? name : "Unknown"; return name ? name : "Unknown";
} }
@ -302,7 +302,7 @@ static void do_generate(uint8_t *frames, int channel, int count,
value_t (*generate)(void *), void *arg) value_t (*generate)(void *), void *arg)
{ {
value_t res; value_t res;
int chn; unsigned int chn;
int8_t *samp8 = (int8_t*) frames; int8_t *samp8 = (int8_t*) frames;
int16_t *samp16 = (int16_t*) frames; int16_t *samp16 = (int16_t*) frames;
int32_t *samp32 = (int32_t*) frames; int32_t *samp32 = (int32_t*) frames;
@ -310,7 +310,7 @@ static void do_generate(uint8_t *frames, int channel, int count,
while (count-- > 0) { while (count-- > 0) {
for(chn=0;chn<channels;chn++) { for(chn=0;chn<channels;chn++) {
if (chn==channel) { if (chn==(unsigned int)channel) {
res = generate(arg); res = generate(arg);
} else { } else {
res.i = 0; res.i = 0;
@ -765,7 +765,7 @@ static int setup_wav_file(int chn)
return check_wav_file(chn, given_test_wav_file); return check_wav_file(chn, given_test_wav_file);
#ifdef CONFIG_SUPPORT_CHMAP #ifdef CONFIG_SUPPORT_CHMAP
if (channel_map && chn < channel_map->channels) { if (channel_map && (unsigned int)chn < channel_map->channels) {
int channel = channel_map->pos[chn] - SND_CHMAP_FL; int channel = channel_map->pos[chn] - SND_CHMAP_FL;
if (channel >= 0 && channel < MAX_CHANNELS) if (channel >= 0 && channel < MAX_CHANNELS)
return check_wav_file(chn, wavs[channel]); return check_wav_file(chn, wavs[channel]);
@ -804,9 +804,9 @@ static int read_wav(uint16_t *buf, int channel, int offset, int bufsize)
bufsize = wav_file_size[channel] - offset; bufsize = wav_file_size[channel] - offset;
bufsize /= channels; bufsize /= channels;
for (size = 0; size < bufsize; size += 2) { for (size = 0; size < bufsize; size += 2) {
int chn; unsigned int chn;
for (chn = 0; chn < channels; chn++) { for (chn = 0; chn < channels; chn++) {
if (chn == channel) { if (chn == (unsigned int)channel) {
if (fread(buf, 2, 1, wavfp) != 1) if (fread(buf, 2, 1, wavfp) != 1)
return size; return size;
} }
@ -870,19 +870,21 @@ static void init_loop(void)
static int write_loop(snd_pcm_t *handle, int channel, int periods, uint8_t *frames) static int write_loop(snd_pcm_t *handle, int channel, int periods, uint8_t *frames)
{ {
int err, n; unsigned int cnt;
int n;
int err;
fflush(stdout); fflush(stdout);
if (test_type == TEST_WAV) { if (test_type == TEST_WAV) {
int bufsize = snd_pcm_frames_to_bytes(handle, period_size); int bufsize = snd_pcm_frames_to_bytes(handle, period_size);
n = 0; cnt = 0;
while ((err = read_wav((uint16_t *)frames, channel, n, bufsize)) > 0 && !in_aborting) { while ((err = read_wav((uint16_t *)frames, channel, cnt, bufsize)) > 0 && !in_aborting) {
n += err; cnt += err;
if ((err = write_buffer(handle, frames, if ((err = write_buffer(handle, frames,
snd_pcm_bytes_to_frames(handle, err * channels))) < 0) snd_pcm_bytes_to_frames(handle, err * channels))) < 0)
break; break;
} }
if (buffer_size > n && !in_aborting) { if (buffer_size > cnt && !in_aborting) {
snd_pcm_drain(handle); snd_pcm_drain(handle);
snd_pcm_prepare(handle); snd_pcm_prepare(handle);
} }
@ -975,7 +977,7 @@ int main(int argc, char *argv[]) {
snd_pcm_hw_params_t *hwparams; snd_pcm_hw_params_t *hwparams;
snd_pcm_sw_params_t *swparams; snd_pcm_sw_params_t *swparams;
uint8_t *frames; uint8_t *frames;
int chn; unsigned int chn;
const int *fmt; const int *fmt;
double time1,time2,time3; double time1,time2,time3;
unsigned int n, nloops; unsigned int n, nloops;