explicitly downcast
Tools like "sparse" check for missing downcasts, since implicit cast may be dangerous. Although that does not change the compiler result, it may make the code more readable (IMHO), because you always see when there may be data cut off. git-svn-id: https://svn.musicpd.org/mpd/trunk@7196 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
13c17c3d94
commit
66fe580642
@ -197,7 +197,7 @@ int parseAudioConfig(AudioFormat * audioFormat, char *conf)
|
||||
return -1;
|
||||
}
|
||||
|
||||
audioFormat->bits = strtol(test + 1, &test, 10);
|
||||
audioFormat->bits = (mpd_sint8)strtol(test + 1, &test, 10);
|
||||
|
||||
if (*test != ':') {
|
||||
ERROR("error parsing audio output format: %s\n", conf);
|
||||
@ -213,7 +213,7 @@ int parseAudioConfig(AudioFormat * audioFormat, char *conf)
|
||||
return -1;
|
||||
}
|
||||
|
||||
audioFormat->channels = strtol(test + 1, &test, 10);
|
||||
audioFormat->channels = (mpd_sint8)strtol(test + 1, &test, 10);
|
||||
|
||||
if (*test != '\0') {
|
||||
ERROR("error parsing audio output format: %s\n", conf);
|
||||
@ -428,7 +428,7 @@ void sendMetadataToAudioDevice(MpdTag * tag)
|
||||
|
||||
int enableAudioDevice(int fd, int device)
|
||||
{
|
||||
if (device < 0 || device >= audioOutputArraySize) {
|
||||
if (device >= audioOutputArraySize) {
|
||||
commandError(fd, ACK_ERROR_ARG, "audio output device id %i "
|
||||
"doesn't exist\n", device);
|
||||
return -1;
|
||||
@ -442,7 +442,7 @@ int enableAudioDevice(int fd, int device)
|
||||
|
||||
int disableAudioDevice(int fd, int device)
|
||||
{
|
||||
if (device < 0 || device >= audioOutputArraySize) {
|
||||
if (device >= audioOutputArraySize) {
|
||||
commandError(fd, ACK_ERROR_ARG, "audio output device id %i "
|
||||
"doesn't exist\n", device);
|
||||
return -1;
|
||||
|
@ -215,7 +215,7 @@ configure_hw:
|
||||
snd_strerror(-err));
|
||||
goto fail;
|
||||
}
|
||||
audioFormat->channels = channels;
|
||||
audioFormat->channels = (mpd_sint8)channels;
|
||||
|
||||
err = snd_pcm_hw_params_set_rate_near(ad->pcmHandle, hwparams,
|
||||
&sampleRate, NULL);
|
||||
|
@ -485,9 +485,9 @@ static int oss_openDevice(AudioOutput * audioOutput)
|
||||
OssData *od = audioOutput->data;
|
||||
AudioFormat *audioFormat = &audioOutput->outAudioFormat;
|
||||
|
||||
od->channels = audioFormat->channels;
|
||||
od->channels = (mpd_sint8)audioFormat->channels;
|
||||
od->sampleRate = audioFormat->sampleRate;
|
||||
od->bits = audioFormat->bits;
|
||||
od->bits = (mpd_sint8)audioFormat->bits;
|
||||
|
||||
if ((ret = oss_open(audioOutput)) < 0)
|
||||
return ret;
|
||||
|
@ -66,7 +66,7 @@ static int flacFindVorbisCommentFloat(const FLAC__StreamMetadata * block,
|
||||
comments[offset].entry[pos]);
|
||||
tmp = p[len];
|
||||
p[len] = '\0';
|
||||
*fl = atof((char *)p);
|
||||
*fl = (float)atof((char *)p);
|
||||
p[len] = tmp;
|
||||
|
||||
return 1;
|
||||
@ -170,9 +170,9 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
|
||||
|
||||
switch (block->type) {
|
||||
case FLAC__METADATA_TYPE_STREAMINFO:
|
||||
dc->audioFormat.bits = si->bits_per_sample;
|
||||
dc->audioFormat.bits = (mpd_sint8)si->bits_per_sample;
|
||||
dc->audioFormat.sampleRate = si->sample_rate;
|
||||
dc->audioFormat.channels = si->channels;
|
||||
dc->audioFormat.channels = (mpd_sint8)si->channels;
|
||||
dc->totalTime = ((float)si->total_samples) / (si->sample_rate);
|
||||
getOutputAudioFormat(&(dc->audioFormat),
|
||||
&(data->cb->audioFormat));
|
||||
|
@ -67,9 +67,9 @@ static int audiofile_decode(OutputBuffer * cb, DecoderControl * dc, char *path)
|
||||
afSetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK,
|
||||
AF_SAMPFMT_TWOSCOMP, 16);
|
||||
afGetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
|
||||
dc->audioFormat.bits = bits;
|
||||
dc->audioFormat.sampleRate = afGetRate(af_fp, AF_DEFAULT_TRACK);
|
||||
dc->audioFormat.channels = afGetVirtualChannels(af_fp, AF_DEFAULT_TRACK);
|
||||
dc->audioFormat.bits = (mpd_uint8)bits;
|
||||
dc->audioFormat.sampleRate = (unsigned int)afGetRate(af_fp, AF_DEFAULT_TRACK);
|
||||
dc->audioFormat.channels = (mpd_uint8)afGetVirtualChannels(af_fp, AF_DEFAULT_TRACK);
|
||||
getOutputAudioFormat(&(dc->audioFormat), &(cb->audioFormat));
|
||||
|
||||
frame_count = afGetFrameCount(af_fp, AF_DEFAULT_TRACK);
|
||||
@ -77,7 +77,7 @@ static int audiofile_decode(OutputBuffer * cb, DecoderControl * dc, char *path)
|
||||
dc->totalTime =
|
||||
((float)frame_count / (float)dc->audioFormat.sampleRate);
|
||||
|
||||
bitRate = st.st_size * 8.0 / dc->totalTime / 1000.0 + 0.5;
|
||||
bitRate = (mpd_uint16)(st.st_size * 8.0 / dc->totalTime / 1000.0 + 0.5);
|
||||
|
||||
if (dc->audioFormat.bits != 8 && dc->audioFormat.bits != 16) {
|
||||
ERROR("Only 8 and 16-bit files are supported. %s is %i-bit\n",
|
||||
|
Loading…
Reference in New Issue
Block a user