audio_format: unsigned integers

"bits" and "channels" cannot be negative.
This commit is contained in:
Max Kellermann 2008-10-10 14:03:33 +02:00
parent 817a033f55
commit 6101dc6c76
6 changed files with 15 additions and 15 deletions

View File

@ -150,7 +150,7 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf)
return -1; return -1;
} }
audioFormat->bits = (int8_t)strtol(test + 1, &test, 10); audioFormat->bits = (uint8_t)strtoul(test + 1, &test, 10);
if (*test != ':') { if (*test != ':') {
ERROR("error parsing audio output format: %s\n", conf); ERROR("error parsing audio output format: %s\n", conf);
@ -161,12 +161,12 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf)
case 16: case 16:
break; break;
default: default:
ERROR("bits %i can not be used for audio output\n", ERROR("bits %u can not be used for audio output\n",
(int)audioFormat->bits); audioFormat->bits);
return -1; return -1;
} }
audioFormat->channels = (int8_t)strtol(test + 1, &test, 10); audioFormat->channels = (uint8_t)strtoul(test + 1, &test, 10);
if (*test != '\0') { if (*test != '\0') {
ERROR("error parsing audio output format: %s\n", conf); ERROR("error parsing audio output format: %s\n", conf);

View File

@ -153,7 +153,7 @@ static int alsa_openDevice(void *data, struct audio_format *audioFormat)
unsigned int buffer_time; unsigned int buffer_time;
if ((bitformat = get_bitformat(audioFormat)) == SND_PCM_FORMAT_UNKNOWN) if ((bitformat = get_bitformat(audioFormat)) == SND_PCM_FORMAT_UNKNOWN)
ERROR("ALSA device \"%s\" doesn't support %i bit audio\n", ERROR("ALSA device \"%s\" doesn't support %u bit audio\n",
ad->device, audioFormat->bits); ad->device, audioFormat->bits);
err = snd_pcm_open(&ad->pcmHandle, ad->device, err = snd_pcm_open(&ad->pcmHandle, ad->device,
@ -201,7 +201,7 @@ configure_hw:
err = snd_pcm_hw_params_set_format(ad->pcmHandle, hwparams, bitformat); err = snd_pcm_hw_params_set_format(ad->pcmHandle, hwparams, bitformat);
if (err < 0) { if (err < 0) {
ERROR("ALSA device \"%s\" does not support %i bit audio: " ERROR("ALSA device \"%s\" does not support %u bit audio: "
"%s\n", ad->device, audioFormat->bits, snd_strerror(-err)); "%s\n", ad->device, audioFormat->bits, snd_strerror(-err));
goto fail; goto fail;
} }
@ -290,8 +290,8 @@ configure_hw:
ad->sampleSize = audio_format_sample_size(audioFormat) * audioFormat->channels; ad->sampleSize = audio_format_sample_size(audioFormat) * audioFormat->channels;
DEBUG("ALSA device \"%s\" will be playing %i bit, %i channel audio at " DEBUG("ALSA device \"%s\" will be playing %i bit, %u channel audio at "
"%i Hz\n", ad->device, (int)audioFormat->bits, "%i Hz\n", ad->device, audioFormat->bits,
channels, sampleRate); channels, sampleRate);
return 0; return 0;

View File

@ -111,7 +111,7 @@ static void mvp_finishDriver(struct audio_output *audioOutput)
} }
static int mvp_setPcmParams(MvpData * md, unsigned long rate, int channels, static int mvp_setPcmParams(MvpData * md, unsigned long rate, int channels,
int big_endian, int bits) int big_endian, unsigned bits)
{ {
int iloop; int iloop;
int mix[5]; int mix[5];

View File

@ -252,7 +252,7 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
char temp[11]; char temp[11];
memset(temp, 0, sizeof(temp)); memset(temp, 0, sizeof(temp));
snprintf(temp, sizeof(temp), "%d", sd->audio_format.channels); snprintf(temp, sizeof(temp), "%u", sd->audio_format.channels);
shout_set_audio_info(sd->shout_conn, SHOUT_AI_CHANNELS, temp); shout_set_audio_info(sd->shout_conn, SHOUT_AI_CHANNELS, temp);
snprintf(temp, sizeof(temp), "%d", sd->audio_format.sampleRate); snprintf(temp, sizeof(temp), "%d", sd->audio_format.sampleRate);

View File

@ -24,8 +24,8 @@
struct audio_format { struct audio_format {
uint32_t sampleRate; uint32_t sampleRate;
int8_t bits; uint8_t bits;
int8_t channels; uint8_t channels;
}; };
static inline void audio_format_clear(struct audio_format *af) static inline void audio_format_clear(struct audio_format *af)

View File

@ -113,7 +113,7 @@ void pcm_volumeChange(char *buffer, int bufferSize,
break; break;
default: default:
FATAL("%i bits not supported by pcm_volumeChange!\n", FATAL("%u bits not supported by pcm_volumeChange!\n",
format->bits); format->bits);
} }
} }
@ -188,7 +188,7 @@ static void pcm_add(char *buffer1, const char *buffer2, size_t size,
break; break;
default: default:
FATAL("%i bits not supported by pcm_add!\n", format->bits); FATAL("%u bits not supported by pcm_add!\n", format->bits);
} }
} }
@ -436,7 +436,7 @@ pcm_convert_24_to_16(int16_t *out, const int32_t *in,
} }
} }
static const char *pcm_convertTo16bit(int8_t bits, const char *inBuffer, static const char *pcm_convertTo16bit(uint8_t bits, const char *inBuffer,
size_t inSize, size_t *outSize) size_t inSize, size_t *outSize)
{ {
static char *buf; static char *buf;