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
* according to channel_order[] values */
int i;
unsigned int i;
int *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)
{
#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;
if (ordered_channels)
return ordered_channels[chn];
@ -271,7 +271,7 @@ static const char *get_channel_name(int chn)
#ifdef CONFIG_SUPPORT_CHMAP
if (channel_map) {
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]);
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 res;
int chn;
unsigned int chn;
int8_t *samp8 = (int8_t*) frames;
int16_t *samp16 = (int16_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) {
for(chn=0;chn<channels;chn++) {
if (chn==channel) {
if (chn==(unsigned int)channel) {
res = generate(arg);
} else {
res.i = 0;
@ -765,7 +765,7 @@ static int setup_wav_file(int chn)
return check_wav_file(chn, given_test_wav_file);
#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;
if (channel >= 0 && channel < MAX_CHANNELS)
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 /= channels;
for (size = 0; size < bufsize; size += 2) {
int chn;
unsigned int chn;
for (chn = 0; chn < channels; chn++) {
if (chn == channel) {
if (chn == (unsigned int)channel) {
if (fread(buf, 2, 1, wavfp) != 1)
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)
{
int err, n;
unsigned int cnt;
int n;
int err;
fflush(stdout);
if (test_type == TEST_WAV) {
int bufsize = snd_pcm_frames_to_bytes(handle, period_size);
n = 0;
while ((err = read_wav((uint16_t *)frames, channel, n, bufsize)) > 0 && !in_aborting) {
n += err;
cnt = 0;
while ((err = read_wav((uint16_t *)frames, channel, cnt, bufsize)) > 0 && !in_aborting) {
cnt += err;
if ((err = write_buffer(handle, frames,
snd_pcm_bytes_to_frames(handle, err * channels))) < 0)
break;
}
if (buffer_size > n && !in_aborting) {
if (buffer_size > cnt && !in_aborting) {
snd_pcm_drain(handle);
snd_pcm_prepare(handle);
}
@ -975,7 +977,7 @@ int main(int argc, char *argv[]) {
snd_pcm_hw_params_t *hwparams;
snd_pcm_sw_params_t *swparams;
uint8_t *frames;
int chn;
unsigned int chn;
const int *fmt;
double time1,time2,time3;
unsigned int n, nloops;