From fcbcdd9869e3147fe4a30ba808af294f680c9373 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 29 Sep 2008 02:35:09 -0700 Subject: Switch to C99 types (retaining compat with old compilers) Seeing the "mpd_" prefix _everywhere_ is mind-numbing as the mind needs to retrain itself to skip over the first 4 tokens of a type to get to its meaning. So avoid having extra characters on my terminal to make it easier to follow code at 2:30 am in the morning. Please report any new issues you may come across on Free toolchains. I realize how difficult it can be to build/maintain cross-compiling toolchains and I have no intention of forcing people to upgrade their toolchains to build mpd. Tested with gcc 2.95.4 and and gcc 4.3.1 on x86-32. --- src/audio.c | 6 ++-- src/audioOutputs/audioOutput_alsa.c | 2 +- src/audioOutputs/audioOutput_oss.c | 4 +-- src/audioOutputs/audioOutput_shout.c | 2 +- src/audio_format.h | 6 ++-- src/charConv.c | 6 ++-- src/command.c | 6 ++-- src/dbUtils.c | 2 +- src/inputPlugins/_flac_common.c | 4 +-- src/inputPlugins/aac_plugin.c | 4 +-- src/inputPlugins/audiofile_plugin.c | 8 ++--- src/inputPlugins/mp3_plugin.c | 10 +++--- src/inputPlugins/mp4_plugin.c | 2 +- src/inputPlugins/mpc_plugin.c | 10 +++--- src/locate.c | 4 +-- src/locate.h | 2 +- src/metadata_pipe.c | 8 ++--- src/mpd_types.h | 51 ++++++++++++++++++++-------- src/os_compat.h | 9 +---- src/outputBuffer.c | 18 +++++----- src/outputBuffer.h | 6 ++-- src/outputBuffer_accessors.h | 4 +-- src/outputBuffer_ob_send.h | 6 ++-- src/pcm_utils.c | 64 ++++++++++++++++++------------------ src/pcm_utils.h | 6 ++-- src/playlist.c | 12 +++---- src/playlist.h | 4 +-- src/replayGain.c | 10 +++--- src/song.h | 2 +- src/tag.c | 2 +- src/tag.h | 2 +- 31 files changed, 150 insertions(+), 132 deletions(-) (limited to 'src') diff --git a/src/audio.c b/src/audio.c index a10f5cf42..2f457829b 100644 --- a/src/audio.c +++ b/src/audio.c @@ -44,7 +44,7 @@ enum ad_state { and enable in playAudio() routine */ static enum ad_state *audioDeviceStates; -static mpd_uint8 audioOpened; +static uint8_t audioOpened; static size_t audioBufferSize; static char *audioBuffer; @@ -195,7 +195,7 @@ int parseAudioConfig(AudioFormat * audioFormat, char *conf) return -1; } - audioFormat->bits = (mpd_sint8)strtol(test + 1, &test, 10); + audioFormat->bits = (int8_t)strtol(test + 1, &test, 10); if (*test != ':') { ERROR("error parsing audio output format: %s\n", conf); @@ -211,7 +211,7 @@ int parseAudioConfig(AudioFormat * audioFormat, char *conf) return -1; } - audioFormat->channels = (mpd_sint8)strtol(test + 1, &test, 10); + audioFormat->channels = (int8_t)strtol(test + 1, &test, 10); if (*test != '\0') { ERROR("error parsing audio output format: %s\n", conf); diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c index 06dbeb956..cd93f9159 100644 --- a/src/audioOutputs/audioOutput_alsa.c +++ b/src/audioOutputs/audioOutput_alsa.c @@ -217,7 +217,7 @@ configure_hw: snd_strerror(-err)); goto fail; } - audioFormat->channels = (mpd_sint8)channels; + audioFormat->channels = (int8_t)channels; err = snd_pcm_hw_params_set_rate_near(ad->pcmHandle, hwparams, &sampleRate, NULL); diff --git a/src/audioOutputs/audioOutput_oss.c b/src/audioOutputs/audioOutput_oss.c index 2df7d5728..a89eeab46 100644 --- a/src/audioOutputs/audioOutput_oss.c +++ b/src/audioOutputs/audioOutput_oss.c @@ -486,9 +486,9 @@ static int oss_openDevice(AudioOutput * audioOutput) OssData *od = audioOutput->data; AudioFormat *audioFormat = &audioOutput->outAudioFormat; - od->channels = (mpd_sint8)audioFormat->channels; + od->channels = (int8_t)audioFormat->channels; od->sampleRate = audioFormat->sampleRate; - od->bits = (mpd_sint8)audioFormat->bits; + od->bits = (int8_t)audioFormat->bits; if ((ret = oss_open(audioOutput)) < 0) return ret; diff --git a/src/audioOutputs/audioOutput_shout.c b/src/audioOutputs/audioOutput_shout.c index 2ee942809..95db68544 100644 --- a/src/audioOutputs/audioOutput_shout.c +++ b/src/audioOutputs/audioOutput_shout.c @@ -636,7 +636,7 @@ static int myShout_play(AudioOutput * audioOutput, for (i = 0; i < samples; i++) { for (j = 0; j < sd->audioFormat->channels; j++) { - vorbbuf[j][i] = (*((const mpd_sint16 *) playChunk)) + vorbbuf[j][i] = (*((const int16_t *) playChunk)) / 32768.0; playChunk += bytes; } diff --git a/src/audio_format.h b/src/audio_format.h index ade9d8810..ce47fb95b 100644 --- a/src/audio_format.h +++ b/src/audio_format.h @@ -22,9 +22,9 @@ #include "mpd_types.h" typedef struct _AudioFormat { - mpd_sint8 channels; - mpd_uint32 sampleRate; - mpd_sint8 bits; + int8_t channels; + uint32_t sampleRate; + int8_t bits; } AudioFormat; static inline double audio_format_time_to_size(const AudioFormat * af) diff --git a/src/charConv.c b/src/charConv.c index 60bcc655a..9c97be38c 100644 --- a/src/charConv.c +++ b/src/charConv.c @@ -32,13 +32,13 @@ static iconv_t char_conv_iconv; static char *char_conv_to; static char *char_conv_from; -static mpd_sint8 char_conv_same; -static mpd_sint8 char_conv_use_iconv; +static int8_t char_conv_same; +static int8_t char_conv_use_iconv; /* 1 is to use latin1ToUtf8 0 is not to use latin1/utf8 converter -1 is to use utf8ToLatin1*/ -static mpd_sint8 char_conv_latin1ToUtf8; +static int8_t char_conv_latin1ToUtf8; #define BUFFER_SIZE MPD_PATH_MAX diff --git a/src/command.c b/src/command.c index 3f80dc916..28b6ee3bb 100644 --- a/src/command.c +++ b/src/command.c @@ -185,7 +185,7 @@ static void command_error_va(int fd, int error, const char *fmt, va_list args) } } -static int mpd_fprintf__ check_uint32(int fd, mpd_uint32 *dst, +static int mpd_fprintf__ check_uint32(int fd, uint32_t *dst, const char *s, const char *fmt, ...) { char *test; @@ -613,7 +613,7 @@ static int handleRename(int fd, mpd_unused int *permission, static int handlePlaylistChanges(int fd, mpd_unused int *permission, mpd_unused int argc, char *argv[]) { - mpd_uint32 version; + uint32_t version; if (check_uint32(fd, &version, argv[1], need_positive) < 0) return -1; @@ -623,7 +623,7 @@ static int handlePlaylistChanges(int fd, mpd_unused int *permission, static int handlePlaylistChangesPosId(int fd, mpd_unused int *permission, mpd_unused int argc, char *argv[]) { - mpd_uint32 version; + uint32_t version; if (check_uint32(fd, &version, argv[1], need_positive) < 0) return -1; diff --git a/src/dbUtils.c b/src/dbUtils.c index fbade8012..4cb3edcca 100644 --- a/src/dbUtils.c +++ b/src/dbUtils.c @@ -29,7 +29,7 @@ #include "storedPlaylist.h" typedef struct _ListCommandItem { - mpd_sint8 tagType; + int8_t tagType; int numConditionals; LocateTagItem *conditionals; } ListCommandItem; diff --git a/src/inputPlugins/_flac_common.c b/src/inputPlugins/_flac_common.c index beff5d431..546f5c192 100644 --- a/src/inputPlugins/_flac_common.c +++ b/src/inputPlugins/_flac_common.c @@ -159,9 +159,9 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block, switch (block->type) { case FLAC__METADATA_TYPE_STREAMINFO: - dc.audio_format.bits = (mpd_sint8)si->bits_per_sample; + dc.audio_format.bits = (int8_t)si->bits_per_sample; dc.audio_format.sampleRate = si->sample_rate; - dc.audio_format.channels = (mpd_sint8)si->channels; + dc.audio_format.channels = (int8_t)si->channels; dc.total_time = ((float)si->total_samples) / (si->sample_rate); break; case FLAC__METADATA_TYPE_VORBIS_COMMENT: diff --git a/src/inputPlugins/aac_plugin.c b/src/inputPlugins/aac_plugin.c index dc97c1e08..2e5df8f48 100644 --- a/src/inputPlugins/aac_plugin.c +++ b/src/inputPlugins/aac_plugin.c @@ -313,7 +313,7 @@ static int aac_stream_decode(InputStream *inStream) unsigned int sampleCount; char *sampleBuffer; size_t sampleBufferLen; - mpd_uint16 bitRate = 0; + uint16_t bitRate = 0; AacBuffer b; initAacBuffer(inStream, &b); @@ -442,7 +442,7 @@ static int aac_decode(char *path) /*float * seekTable; long seekTableEnd = -1; int seekPositionFound = 0; */ - mpd_uint16 bitRate = 0; + uint16_t bitRate = 0; AacBuffer b; InputStream inStream; diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c index 6fcc98239..858b71229 100644 --- a/src/inputPlugins/audiofile_plugin.c +++ b/src/inputPlugins/audiofile_plugin.c @@ -45,7 +45,7 @@ static int audiofile_decode(char *path) int fs, frame_count; AFfilehandle af_fp; int bits; - mpd_uint16 bitRate; + uint16_t bitRate; struct stat st; int ret, current = 0; char chunk[CHUNK_SIZE]; @@ -64,18 +64,18 @@ static int audiofile_decode(char *path) afSetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16); afGetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits); - dc.audio_format.bits = (mpd_uint8)bits; + dc.audio_format.bits = (uint8_t)bits; dc.audio_format.sampleRate = (unsigned int)afGetRate(af_fp, AF_DEFAULT_TRACK); dc.audio_format.channels = - (mpd_uint8)afGetVirtualChannels(af_fp, AF_DEFAULT_TRACK); + (uint8_t)afGetVirtualChannels(af_fp, AF_DEFAULT_TRACK); frame_count = afGetFrameCount(af_fp, AF_DEFAULT_TRACK); dc.total_time = ((float)frame_count / (float)dc.audio_format.sampleRate); - bitRate = (mpd_uint16)(st.st_size * 8.0 / dc.total_time / 1000.0 + 0.5); + bitRate = (uint16_t)(st.st_size * 8.0 / dc.total_time / 1000.0 + 0.5); if (dc.audio_format.bits != 8 && dc.audio_format.bits != 16) { ERROR("Only 8 and 16-bit files are supported. %s is %i-bit\n", diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index 1d6333fd6..0d664b020 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -65,7 +65,7 @@ static unsigned long prng(unsigned long state) return (state * 0x0019660dL + 0x3c6ef35fL) & 0xffffffffL; } -static mpd_sint16 audio_linear_dither(unsigned int bits, mad_fixed_t sample, +static int16_t audio_linear_dither(unsigned int bits, mad_fixed_t sample, struct audio_dither *dither) { unsigned int scalebits; @@ -107,15 +107,15 @@ static mpd_sint16 audio_linear_dither(unsigned int bits, mad_fixed_t sample, dither->error[0] = sample - output; - return (mpd_sint16)(output >> scalebits); + return (int16_t)(output >> scalebits); } -static unsigned dither_buffer(mpd_sint16 *dest0, const struct mad_synth *synth, +static unsigned dither_buffer(int16_t *dest0, const struct mad_synth *synth, struct audio_dither *dither, unsigned int start, unsigned int end, unsigned int num_channels) { - mpd_sint16 *dest = dest0; + int16_t *dest = dest0; unsigned int i; for (i = start; i < end; ++i) { @@ -153,7 +153,7 @@ typedef struct _mp3DecodeData { struct mad_synth synth; mad_timer_t timer; unsigned char readBuffer[READ_BUFFER_SIZE]; - mpd_sint16 outputBuffer[MP3_DATA_OUTPUT_BUFFER_SIZE]; + int16_t outputBuffer[MP3_DATA_OUTPUT_BUFFER_SIZE]; float totalTime; float elapsedTime; enum muteframe muteFrame; diff --git a/src/inputPlugins/mp4_plugin.c b/src/inputPlugins/mp4_plugin.c index 1e65f6667..0763c6c12 100644 --- a/src/inputPlugins/mp4_plugin.c +++ b/src/inputPlugins/mp4_plugin.c @@ -103,7 +103,7 @@ static int mp4_decode(InputStream * inStream) long seekTableEnd = -1; int seekPositionFound = 0; long offset; - mpd_uint16 bitRate = 0; + uint16_t bitRate = 0; int seeking = 0; mp4cb = xmalloc(sizeof(mp4ff_callback_t)); diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c index e5502a2f0..735916cdc 100644 --- a/src/inputPlugins/mpc_plugin.c +++ b/src/inputPlugins/mpc_plugin.c @@ -74,10 +74,10 @@ static mpc_int32_t mpc_getsize_cb(void *vdata) } /* this _looks_ performance-critical, don't de-inline -- eric */ -static inline mpd_sint16 convertSample(MPC_SAMPLE_FORMAT sample) +static inline int16_t convertSample(MPC_SAMPLE_FORMAT sample) { /* only doing 16-bit audio for now */ - mpd_sint32 val; + int32_t val; const int clip_min = -1 << (16 - 1); const int clip_max = (1 << (16 - 1)) - 1; @@ -121,7 +121,7 @@ static int mpc_decode(InputStream * inStream) char chunk[MPC_CHUNK_SIZE]; int chunkpos = 0; long bitRate = 0; - mpd_sint16 *s16 = (mpd_sint16 *) chunk; + int16_t *s16 = (int16_t *) chunk; unsigned long samplePos = 0; mpc_uint32_t vbrUpdateAcc; mpc_uint32_t vbrUpdateBits; @@ -175,7 +175,7 @@ static int mpc_decode(InputStream * inStream) dc_action_begin(); samplePos = dc.seek_where * dc.audio_format.sampleRate; if (mpc_decoder_seek_sample(&decoder, samplePos)) { - s16 = (mpd_sint16 *) chunk; + s16 = (int16_t *) chunk; chunkpos = 0; } else dc.seek_where = DC_SEEK_ERROR; @@ -214,7 +214,7 @@ static int mpc_decode(InputStream * inStream) bitRate, replayGainInfo); chunkpos = 0; - s16 = (mpd_sint16 *) chunk; + s16 = (int16_t *) chunk; if (dc_intr()) { eof = 1; break; diff --git a/src/locate.c b/src/locate.c index 7d4a51db9..6101dd95b 100644 --- a/src/locate.c +++ b/src/locate.c @@ -126,7 +126,7 @@ static int strstrSearchTag(Song * song, enum tag_type type, char *str) int i; char *duplicate; int ret = 0; - mpd_sint8 visitedTypes[TAG_NUM_OF_ITEM_TYPES] = { 0 }; + int8_t visitedTypes[TAG_NUM_OF_ITEM_TYPES] = { 0 }; if (type == LOCATE_TAG_FILE_TYPE || type == LOCATE_TAG_ANY_TYPE) { char path_max_tmp[MPD_PATH_MAX]; @@ -183,7 +183,7 @@ int strstrSearchTags(Song * song, int numItems, LocateTagItem * items) static int tagItemFoundAndMatches(Song * song, enum tag_type type, char *str) { int i; - mpd_sint8 visitedTypes[TAG_NUM_OF_ITEM_TYPES] = { 0 }; + int8_t visitedTypes[TAG_NUM_OF_ITEM_TYPES] = { 0 }; if (type == LOCATE_TAG_FILE_TYPE || type == LOCATE_TAG_ANY_TYPE) { char path_max_tmp[MPD_PATH_MAX]; diff --git a/src/locate.h b/src/locate.h index 325ae384d..7a817828a 100644 --- a/src/locate.h +++ b/src/locate.h @@ -26,7 +26,7 @@ /* struct used for search, find, list queries */ typedef struct _LocateTagItem { - mpd_sint8 tagType; + int8_t tagType; /* what we are looking for */ char *needle; } LocateTagItem; diff --git a/src/metadata_pipe.c b/src/metadata_pipe.c index f4ff16052..83c36ce1b 100644 --- a/src/metadata_pipe.c +++ b/src/metadata_pipe.c @@ -29,7 +29,7 @@ static struct ringbuf *mp; /* Each one of these is a packet inside the metadata pipe */ struct tag_container { float metadata_time; - mpd_uint8 seq; /* ob.seq_decoder at time of metadata_pipe_send() */ + uint8_t seq; /* ob.seq_decoder at time of metadata_pipe_send() */ struct mpd_tag *tag; /* our payload */ }; @@ -79,8 +79,8 @@ struct mpd_tag * metadata_pipe_recv(void) { struct tag_container tc; size_t r; - static const size_t mpd_uint8_max = 255; /* XXX CLEANUP */ - mpd_uint8 expect_seq = ob_get_player_sequence(); + static const size_t uint8_t_max = 255; /* XXX CLEANUP */ + uint8_t expect_seq = ob_get_player_sequence(); unsigned long current_time = ob_get_elapsed_time(); struct mpd_tag *tag = NULL; @@ -106,7 +106,7 @@ retry: current_tag = tc.tag; ringbuf_read_advance(mp, sizeof(struct tag_container)); } else if (expect_seq > tc.seq || - (!expect_seq && tc.seq == mpd_uint8_max)) { + (!expect_seq && tc.seq == uint8_t_max)) { DEBUG("metadata_pipe: reader is ahead of writer\n"); tag_free(tc.tag); ringbuf_read_advance(mp, sizeof(struct tag_container)); diff --git a/src/mpd_types.h b/src/mpd_types.h index dbdfc6865..b61f007ad 100644 --- a/src/mpd_types.h +++ b/src/mpd_types.h @@ -21,23 +21,48 @@ #include "../config.h" -typedef unsigned char mpd_uint8; -typedef signed char mpd_sint8; +#if defined(HAVE_INTTYPES_H) + /* + * inttypes.h pulls in stdint.h on C99 systems, needed for older systems + * that didn't provide stdint.h but still defined equivalent types. + */ +# include +#elif defined(HAVE_STDINT_H) +# include +#elif defined(HAVE_SYS_INTTYPES_H) +# include /* some ancient systems had this, untested */ +#endif /* C99-ish type headers */ + +#include + +#if (!defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H)) + +/* + * this only includes a partial subset of what is expected in a C99 + * stdint.h or inttypes.h; but includes enough of what is needed for mpd + * to function on older platforms + * (especially Linux ones still using gcc 2.95) + */ + +typedef unsigned char uint8_t; +typedef signed char int8_t; #if SIZEOF_SHORT == 2 -typedef unsigned short mpd_uint16; -typedef signed short mpd_sint16; +typedef unsigned short uint16_t; +typedef signed short int16_t; #elif SIZEOF_INT == 2 -typedef unsigned int mpd_uint16; -typedef signed int mpd_sint16; -#endif +typedef unsigned int uint16_t; +typedef signed int int16_t; +#endif /* (u)int_16_t */ #if SIZEOF_INT == 4 -typedef unsigned int mpd_uint32; -typedef signed int mpd_sint32; +typedef unsigned int uint32_t; +typedef signed int int32_t; #elif SIZEOF_LONG == 4 -typedef unsigned long mpd_uint32; -typedef signed long mpd_sint32; -#endif +typedef unsigned long uint32_t; +typedef signed long int32_t; +#endif /* (u)int_32 */ + +#endif /* !HAVE_STDINT_H && !HAVE_INTTYPES_H */ -#endif +#endif /* MPD_TYPES_H */ diff --git a/src/os_compat.h b/src/os_compat.h index 7cd47cbf8..c3aede51c 100644 --- a/src/os_compat.h +++ b/src/os_compat.h @@ -31,14 +31,7 @@ * 2) optional features in core (libsamplerate, avahi, ...) */ -#if defined(HAVE_STDINT_H) -#include -#elif defined(HAVE_INTTYPES_H) -#include -#elif defined(HAVE_SYS_INTTYPES_H) -#include -#endif -#include +#include "mpd_types.h" #define _XOPEN_SOURCE 600 /* for posix_fadvise, won't hurt if not available */ #include diff --git a/src/outputBuffer.c b/src/outputBuffer.c index 606877dd0..9a659db41 100644 --- a/src/outputBuffer.c +++ b/src/outputBuffer.c @@ -33,10 +33,10 @@ /* typically have 2048-4096 of these structs, so pack tightly */ struct ob_chunk { - mpd_uint16 len; /* 0: skip this chunk */ - mpd_uint16 bit_rate; + uint16_t len; /* 0: skip this chunk */ + uint16_t bit_rate; float time; - mpd_uint8 seq; /* see seq_ok() for explanation */ + uint8_t seq; /* see seq_ok() for explanation */ char data[CHUNK_SIZE]; }; @@ -73,12 +73,12 @@ struct output_buffer { size_t conv_buf_len; pthread_t thread; ConvState conv_state; - mpd_uint8 seq_drop; - mpd_uint8 seq_player; /* only gets changed by ob.thread */ - mpd_uint8 seq_decoder; /* only gets changed by dc.thread */ + uint8_t seq_drop; + uint8_t seq_player; /* only gets changed by ob.thread */ + uint8_t seq_decoder; /* only gets changed by dc.thread */ struct ringbuf preseek_index; enum ob_state preseek_state; - mpd_uint16 *preseek_len; + uint16_t *preseek_len; }; static struct output_buffer ob; @@ -158,7 +158,7 @@ static enum action_status ob_do_drop(void) { struct rbvec vec[2]; long i; - mpd_uint8 seq_drop; + uint8_t seq_drop; cond_enter(&ob_seq_cond); seq_drop = ob.seq_drop; @@ -209,7 +209,7 @@ static void reader_reset_buffer(void) metadata_pipe_clear(); } -static void ob_seq_player_set(mpd_uint8 seq_num) +static void ob_seq_player_set(uint8_t seq_num) { cond_enter(&ob_seq_cond); ob.seq_player = seq_num; diff --git a/src/outputBuffer.h b/src/outputBuffer.h index 022f7ecdc..258875868 100644 --- a/src/outputBuffer.h +++ b/src/outputBuffer.h @@ -67,7 +67,7 @@ int ob_synced(void); * vec = ob_getv(); decode_to(&vec, ...); ob_vmsplice(&vec, ...); */ enum dc_action ob_send(void *data, size_t len, float time, - mpd_uint16 bit_rate, ReplayGainInfo *rgi); + uint16_t bit_rate, ReplayGainInfo *rgi); /* synchronous and blocking (the only way it should be) */ void ob_trigger_action(enum ob_action action); @@ -106,7 +106,7 @@ void ob_flush(void); void config_output_buffer(void); void init_output_buffer(void); -mpd_uint8 ob_get_decoder_sequence(void); +uint8_t ob_get_decoder_sequence(void); -mpd_uint8 ob_get_player_sequence(void); +uint8_t ob_get_player_sequence(void); #endif diff --git a/src/outputBuffer_accessors.h b/src/outputBuffer_accessors.h index 2f4116b94..8d59429dd 100644 --- a/src/outputBuffer_accessors.h +++ b/src/outputBuffer_accessors.h @@ -76,12 +76,12 @@ AudioFormat *ob_audio_format(void) return &ob.audio_format; } -mpd_uint8 ob_get_decoder_sequence(void) +uint8_t ob_get_decoder_sequence(void) { return ob.seq_decoder; } -mpd_uint8 ob_get_player_sequence(void) +uint8_t ob_get_player_sequence(void) { return ob.seq_player; } diff --git a/src/outputBuffer_ob_send.h b/src/outputBuffer_ob_send.h index 310d5f8fd..f27a5c0dc 100644 --- a/src/outputBuffer_ob_send.h +++ b/src/outputBuffer_ob_send.h @@ -37,7 +37,7 @@ static void do_audio_conversion(void **data, size_t *len) static void ensure_audio_format_sanity(void **data, size_t *len) { - static mpd_uint8 seq_last; + static uint8_t seq_last; assert(pthread_equal(pthread_self(), dc.thread)); if (mpd_unlikely(seq_last != ob.seq_decoder)) { @@ -61,7 +61,7 @@ static void start_playback(void) enum dc_action ob_send(void *data, size_t len, - float decode_time, mpd_uint16 bit_rate, ReplayGainInfo * rgi) + float decode_time, uint16_t bit_rate, ReplayGainInfo * rgi) { struct rbvec vec[2]; struct ob_chunk *c; @@ -97,7 +97,7 @@ ob_send(void *data, size_t len, c->bit_rate = bit_rate; c_len = len > CHUNK_SIZE ? CHUNK_SIZE : len; - c->len = (mpd_uint16)c_len; + c->len = (uint16_t)c_len; memcpy(c->data, data, c_len); } else { /* partially filled chunk */ size_t max = CHUNK_SIZE - c->len; diff --git a/src/pcm_utils.c b/src/pcm_utils.c index 077010062..a798223c7 100644 --- a/src/pcm_utils.c +++ b/src/pcm_utils.c @@ -34,8 +34,8 @@ pcm_dither(void) * Check if the value is within the range of the provided bit size, * and caps it if necessary. */ -static mpd_sint32 -pcm_range(mpd_sint32 sample, unsigned bits) +static int32_t +pcm_range(int32_t sample, unsigned bits) { if (mpd_unlikely(sample < (-1 << (bits - 1)))) return -1 << (bits - 1); @@ -47,9 +47,9 @@ pcm_range(mpd_sint32 sample, unsigned bits) void pcm_volumeChange(char *buffer, int bufferSize, const AudioFormat * format, int volume) { - mpd_sint32 temp32; - mpd_sint8 *buffer8 = (mpd_sint8 *) buffer; - mpd_sint16 *buffer16 = (mpd_sint16 *) buffer; + int32_t temp32; + int8_t *buffer8 = (int8_t *) buffer; + int16_t *buffer16 = (int16_t *) buffer; if (volume >= 1000) return; @@ -94,11 +94,11 @@ static void pcm_add(char *buffer1, const char *buffer2, size_t bufferSize1, size_t bufferSize2, int vol1, int vol2, const AudioFormat * format) { - mpd_sint32 temp32; - mpd_sint8 *buffer8_1 = (mpd_sint8 *) buffer1; - const mpd_sint8 *buffer8_2 = (const mpd_sint8 *) buffer2; - mpd_sint16 *buffer16_1 = (mpd_sint16 *) buffer1; - const mpd_sint16 *buffer16_2 = (const mpd_sint16 *) buffer2; + int32_t temp32; + int8_t *buffer8_1 = (int8_t *) buffer1; + const int8_t *buffer8_2 = (const int8_t *) buffer2; + int16_t *buffer16_1 = (int16_t *) buffer1; + const int16_t *buffer16_2 = (const int16_t *) buffer2; switch (format->bits) { case 16: @@ -192,9 +192,9 @@ out: #endif #ifdef HAVE_LIBSAMPLERATE -static size_t pcm_convertSampleRate(mpd_sint8 channels, mpd_uint32 inSampleRate, +static size_t pcm_convertSampleRate(int8_t channels, uint32_t inSampleRate, const char *inBuffer, size_t inSize, - mpd_uint32 outSampleRate, char *outBuffer, + uint32_t outSampleRate, char *outBuffer, size_t outSize, ConvState *convState) { static int convalgo = -1; @@ -268,19 +268,19 @@ static size_t pcm_convertSampleRate(mpd_sint8 channels, mpd_uint32 inSampleRate, } #else /* !HAVE_LIBSAMPLERATE */ /* resampling code blatantly ripped from ESD */ -static size_t pcm_convertSampleRate(mpd_sint8 channels, mpd_uint32 inSampleRate, +static size_t pcm_convertSampleRate(int8_t channels, uint32_t inSampleRate, const char *inBuffer, mpd_unused size_t inSize, - mpd_uint32 outSampleRate, char *outBuffer, + uint32_t outSampleRate, char *outBuffer, size_t outSize, mpd_unused ConvState *convState) { - mpd_uint32 rd_dat = 0; - mpd_uint32 wr_dat = 0; - mpd_sint16 *in = (mpd_sint16 *)inBuffer; - mpd_sint16 *out = (mpd_sint16 *)outBuffer; - mpd_uint32 nlen = outSize / 2; - mpd_sint16 lsample, rsample; + uint32_t rd_dat = 0; + uint32_t wr_dat = 0; + int16_t *in = (int16_t *)inBuffer; + int16_t *out = (int16_t *)outBuffer; + uint32_t nlen = outSize / 2; + int16_t lsample, rsample; switch (channels) { case 1: @@ -310,14 +310,14 @@ static size_t pcm_convertSampleRate(mpd_sint8 channels, mpd_uint32 inSampleRate, } #endif /* !HAVE_LIBSAMPLERATE */ -static char *pcm_convertChannels(mpd_sint8 channels, const char *inBuffer, +static char *pcm_convertChannels(int8_t channels, const char *inBuffer, size_t inSize, size_t *outSize) { static char *buf; static size_t len; char *outBuffer = NULL; - const mpd_sint16 *in; - mpd_sint16 *out; + const int16_t *in; + int16_t *out; int inSamples, i; switch (channels) { @@ -331,8 +331,8 @@ static char *pcm_convertChannels(mpd_sint8 channels, const char *inBuffer, outBuffer = buf; inSamples = inSize >> 1; - in = (const mpd_sint16 *)inBuffer; - out = (mpd_sint16 *)outBuffer; + in = (const int16_t *)inBuffer; + out = (int16_t *)outBuffer; for (i = 0; i < inSamples; i++) { *out++ = *in; *out++ = *in++; @@ -349,8 +349,8 @@ static char *pcm_convertChannels(mpd_sint8 channels, const char *inBuffer, outBuffer = buf; inSamples = inSize >> 2; - in = (const mpd_sint16 *)inBuffer; - out = (mpd_sint16 *)outBuffer; + in = (const int16_t *)inBuffer; + out = (int16_t *)outBuffer; for (i = 0; i < inSamples; i++) { *out = (*in++) / 2; *out++ += (*in++) / 2; @@ -364,14 +364,14 @@ static char *pcm_convertChannels(mpd_sint8 channels, const char *inBuffer, return outBuffer; } -static const char *pcm_convertTo16bit(mpd_sint8 bits, const char *inBuffer, +static const char *pcm_convertTo16bit(int8_t bits, const char *inBuffer, size_t inSize, size_t *outSize) { static char *buf; static size_t len; char *outBuffer = NULL; - const mpd_sint8 *in; - mpd_sint16 *out; + const int8_t *in; + int16_t *out; size_t i; switch (bits) { @@ -383,8 +383,8 @@ static const char *pcm_convertTo16bit(mpd_sint8 bits, const char *inBuffer, } outBuffer = buf; - in = (const mpd_sint8 *)inBuffer; - out = (mpd_sint16 *)outBuffer; + in = (const int8_t *)inBuffer; + out = (int16_t *)outBuffer; for (i = 0; i < inSize; i++) *out++ = (*in++) << 8; diff --git a/src/pcm_utils.h b/src/pcm_utils.h index 2ecb56201..31911af01 100644 --- a/src/pcm_utils.h +++ b/src/pcm_utils.h @@ -34,9 +34,9 @@ typedef struct _ConvState { SRC_DATA data; size_t dataInSize; size_t dataOutSize; - mpd_sint8 lastChannels; - mpd_uint32 lastInSampleRate; - mpd_uint32 lastOutSampleRate; + int8_t lastChannels; + uint32_t lastInSampleRate; + uint32_t lastOutSampleRate; #endif /* Strict C99 doesn't allow empty structs */ int error; diff --git a/src/playlist.c b/src/playlist.c index af0aaccc0..ca903036d 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -43,7 +43,7 @@ static enum _playlist_state playlist_state; struct _playlist { Song **songs; /* holds version a song was modified on */ - mpd_uint32 *songMod; + uint32_t *songMod; int *order; int *positionToId; int *idToPosition; @@ -52,7 +52,7 @@ struct _playlist { int queued; /* to be decoded */ int repeat; int random; - mpd_uint32 version; + uint32_t version; }; #define PLAYLIST_PREV_UNLESS_ELAPSED 10 @@ -99,7 +99,7 @@ static void randomizeOrder(int start, int end); static void incrPlaylistVersion(void) { - static unsigned long max = ((mpd_uint32) 1 << 31) - 1; + static unsigned long max = ((uint32_t) 1 << 31) - 1; playlist.version++; if (playlist.version >= max) { int i; @@ -167,7 +167,7 @@ void initPlaylist(void) DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS; playlist.songs = xmalloc(sizeof(Song *) * playlist_max_length); - playlist.songMod = xmalloc(sizeof(mpd_uint32) * playlist_max_length); + playlist.songMod = xmalloc(sizeof(uint32_t) * playlist_max_length); playlist.order = xmalloc(sizeof(int) * playlist_max_length); playlist.idToPosition = xmalloc(sizeof(int) * playlist_max_length * PLAYLIST_HASH_MULT); @@ -381,7 +381,7 @@ static void printPlaylistSongInfo(int fd, int song) fdprintf(fd, "Pos: %i\nId: %i\n", song, playlist.positionToId[song]); } -int playlistChanges(int fd, mpd_uint32 version) +int playlistChanges(int fd, uint32_t version) { int i; @@ -396,7 +396,7 @@ int playlistChanges(int fd, mpd_uint32 version) return 0; } -int playlistChangesPosId(int fd, mpd_uint32 version) +int playlistChangesPosId(int fd, uint32_t version) { int i; diff --git a/src/playlist.h b/src/playlist.h index 6b5fe0cd7..265b58356 100644 --- a/src/playlist.h +++ b/src/playlist.h @@ -126,9 +126,9 @@ enum playlist_result seekSongInPlaylistById(int id, float seek_time); void playlistVersionChange(void); -int playlistChanges(int fd, mpd_uint32 version); +int playlistChanges(int fd, uint32_t version); -int playlistChangesPosId(int fd, mpd_uint32 version); +int playlistChangesPosId(int fd, uint32_t version); int PlaylistInfo(int fd, const char *utf8file, int detail); diff --git a/src/replayGain.c b/src/replayGain.c index 8926138bb..7576fb974 100644 --- a/src/replayGain.c +++ b/src/replayGain.c @@ -106,9 +106,9 @@ void freeReplayGainInfo(ReplayGainInfo * info) void doReplayGain(ReplayGainInfo * info, char *buffer, int bufferSize, const AudioFormat * format) { - mpd_sint16 *buffer16; - mpd_sint8 *buffer8; - mpd_sint32 temp32; + int16_t *buffer16; + int8_t *buffer8; + int32_t temp32; float scale; if (replayGainState == REPLAYGAIN_OFF || !info) @@ -134,8 +134,8 @@ void doReplayGain(ReplayGainInfo * info, char *buffer, int bufferSize, if (info->scale <= 1.01 && info->scale >= 0.99) return; - buffer16 = (mpd_sint16 *) buffer; - buffer8 = (mpd_sint8 *) buffer; + buffer16 = (int16_t *) buffer; + buffer8 = (int8_t *) buffer; scale = info->scale; diff --git a/src/song.h b/src/song.h index 0fbee7b07..9bb96aba0 100644 --- a/src/song.h +++ b/src/song.h @@ -37,7 +37,7 @@ typedef struct _Song { char *url; - mpd_sint8 type; + int8_t type; struct mpd_tag *tag; struct _Directory *parentDir; time_t mtime; diff --git a/src/tag.c b/src/tag.c index f1acb7c79..2dcaf4ef8 100644 --- a/src/tag.c +++ b/src/tag.c @@ -52,7 +52,7 @@ const char *mpdTagItemKeys[TAG_NUM_OF_ITEM_TYPES] = { "Disc" }; -static mpd_sint8 ignoreTagItems[TAG_NUM_OF_ITEM_TYPES]; +static int8_t ignoreTagItems[TAG_NUM_OF_ITEM_TYPES]; static size_t items_size(const struct mpd_tag *tag) { diff --git a/src/tag.h b/src/tag.h index a05f7654a..744b82e83 100644 --- a/src/tag.h +++ b/src/tag.h @@ -48,7 +48,7 @@ struct tag_item { struct mpd_tag { int time; struct tag_item **items; - mpd_uint8 numOfItems; + uint8_t numOfItems; }; struct mpd_tag *tag_ape_load(const char *file); -- cgit v1.2.3