aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audioOutputs/audioOutput_shout_mp3.c2
-rw-r--r--src/audioOutputs/audioOutput_shout_ogg.c2
-rw-r--r--src/audio_format.h6
-rw-r--r--src/command.c6
-rw-r--r--src/decoder_api.c2
-rw-r--r--src/decoder_api.h2
-rw-r--r--src/decoder_control.h6
-rw-r--r--src/inputPlugins/_flac_common.c4
-rw-r--r--src/inputPlugins/audiofile_plugin.c8
-rw-r--r--src/inputPlugins/mpc_plugin.c10
-rw-r--r--src/mpd_types.h49
-rw-r--r--src/outputBuffer.c4
-rw-r--r--src/outputBuffer.h7
-rw-r--r--src/player_control.h14
-rw-r--r--src/playlist.c8
-rw-r--r--src/playlist.h8
-rw-r--r--src/song.h2
17 files changed, 82 insertions, 58 deletions
diff --git a/src/audioOutputs/audioOutput_shout_mp3.c b/src/audioOutputs/audioOutput_shout_mp3.c
index d3ec0b75b..d1fe87884 100644
--- a/src/audioOutputs/audioOutput_shout_mp3.c
+++ b/src/audioOutputs/audioOutput_shout_mp3.c
@@ -153,7 +153,7 @@ static int shout_mp3_encoder_encode(struct shout_data *sd,
for (i = 0; i < samples; i++) {
for (j = 0; j < sd->audio_format.channels; j++) {
- lamebuf[j][i] = *((const mpd_sint16 *) chunk);
+ lamebuf[j][i] = *((const int16_t *) chunk);
chunk += bytes;
}
}
diff --git a/src/audioOutputs/audioOutput_shout_ogg.c b/src/audioOutputs/audioOutput_shout_ogg.c
index d8627a007..aa96c4032 100644
--- a/src/audioOutputs/audioOutput_shout_ogg.c
+++ b/src/audioOutputs/audioOutput_shout_ogg.c
@@ -267,7 +267,7 @@ static int shout_ogg_encoder_encode(struct shout_data *sd,
for (i = 0; i < samples; i++) {
for (j = 0; j < sd->audio_format.channels; j++) {
- vorbbuf[j][i] = (*((const mpd_sint16 *) chunk)) / 32768.0;
+ vorbbuf[j][i] = (*((const int16_t *) chunk)) / 32768.0;
chunk += bytes;
}
}
diff --git a/src/audio_format.h b/src/audio_format.h
index e45d79cd5..3bbca3734 100644
--- a/src/audio_format.h
+++ b/src/audio_format.h
@@ -22,9 +22,9 @@
#include "mpd_types.h"
struct audio_format {
- mpd_uint32 sampleRate;
- mpd_sint8 bits;
- mpd_sint8 channels;
+ uint32_t sampleRate;
+ int8_t bits;
+ int8_t channels;
};
static inline void audio_format_clear(struct audio_format *af)
diff --git a/src/command.c b/src/command.c
index 882d968d3..822ee05bf 100644
--- a/src/command.c
+++ b/src/command.c
@@ -197,7 +197,7 @@ mpd_fprintf_ void command_error(struct client *client, int error,
va_end(args);
}
-static int mpd_fprintf__ check_uint32(struct client *client, mpd_uint32 *dst,
+static int mpd_fprintf__ check_uint32(struct client *client, uint32_t *dst,
const char *s, const char *fmt, ...)
{
char *test;
@@ -627,7 +627,7 @@ static int handleRename(struct client *client,
static int handlePlaylistChanges(struct client *client,
mpd_unused int argc, char *argv[])
{
- mpd_uint32 version;
+ uint32_t version;
if (check_uint32(client, &version, argv[1], need_positive) < 0)
return -1;
@@ -637,7 +637,7 @@ static int handlePlaylistChanges(struct client *client,
static int handlePlaylistChangesPosId(struct client *client,
mpd_unused int argc, char *argv[])
{
- mpd_uint32 version;
+ uint32_t version;
if (check_uint32(client, &version, argv[1], need_positive) < 0)
return -1;
diff --git a/src/decoder_api.c b/src/decoder_api.c
index 236fe5029..52ad21e60 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -152,7 +152,7 @@ need_chunks(struct decoder *decoder, InputStream * inStream, int seekable)
enum decoder_command
decoder_data(struct decoder *decoder, InputStream * inStream, int seekable,
void *dataIn, size_t dataInLen,
- float data_time, mpd_uint16 bitRate,
+ float data_time, uint16_t bitRate,
ReplayGainInfo * replayGainInfo)
{
size_t nbytes;
diff --git a/src/decoder_api.h b/src/decoder_api.h
index ec1f139df..2851991ae 100644
--- a/src/decoder_api.h
+++ b/src/decoder_api.h
@@ -149,7 +149,7 @@ size_t decoder_read(struct decoder *decoder,
*/
enum decoder_command
decoder_data(struct decoder *decoder, InputStream * inStream, int seekable,
- void *data, size_t datalen, float data_time, mpd_uint16 bitRate,
+ void *data, size_t datalen, float data_time, uint16_t bitRate,
ReplayGainInfo * replayGainInfo);
void decoder_flush(struct decoder *decoder);
diff --git a/src/decoder_control.h b/src/decoder_control.h
index af777fb31..e34e9d607 100644
--- a/src/decoder_control.h
+++ b/src/decoder_control.h
@@ -44,9 +44,9 @@ struct decoder_control {
volatile enum decoder_state state;
volatile enum decoder_command command;
- volatile mpd_uint16 error;
- volatile mpd_sint8 seekError;
- volatile mpd_sint8 seekable;
+ volatile uint16_t error;
+ volatile int8_t seekError;
+ volatile int8_t seekable;
volatile double seekWhere;
struct audio_format audioFormat;
Song *current_song;
diff --git a/src/inputPlugins/_flac_common.c b/src/inputPlugins/_flac_common.c
index 550df77df..22d8774a3 100644
--- a/src/inputPlugins/_flac_common.c
+++ b/src/inputPlugins/_flac_common.c
@@ -161,9 +161,9 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
switch (block->type) {
case FLAC__METADATA_TYPE_STREAMINFO:
- data->audio_format.bits = (mpd_sint8)si->bits_per_sample;
+ data->audio_format.bits = (int8_t)si->bits_per_sample;
data->audio_format.sampleRate = si->sample_rate;
- data->audio_format.channels = (mpd_sint8)si->channels;
+ data->audio_format.channels = (int8_t)si->channels;
data->total_time = ((float)si->total_samples) / (si->sample_rate);
break;
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c
index a2fc39881..1dd488fb1 100644
--- a/src/inputPlugins/audiofile_plugin.c
+++ b/src/inputPlugins/audiofile_plugin.c
@@ -50,7 +50,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
int bits;
struct audio_format audio_format;
float total_time;
- mpd_uint16 bitRate;
+ uint16_t bitRate;
struct stat st;
int ret, current = 0;
char chunk[CHUNK_SIZE];
@@ -69,17 +69,17 @@ static int audiofile_decode(struct decoder * decoder, char *path)
afSetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK,
AF_SAMPFMT_TWOSCOMP, 16);
afGetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
- audio_format.bits = (mpd_uint8)bits;
+ audio_format.bits = (uint8_t)bits;
audio_format.sampleRate =
(unsigned int)afGetRate(af_fp, AF_DEFAULT_TRACK);
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);
total_time = ((float)frame_count / (float)audio_format.sampleRate);
- bitRate = (mpd_uint16)(st.st_size * 8.0 / total_time / 1000.0 + 0.5);
+ bitRate = (uint16_t)(st.st_size * 8.0 / total_time / 1000.0 + 0.5);
if (audio_format.bits != 8 && audio_format.bits != 16) {
ERROR("Only 8 and 16-bit files are supported. %s is %i-bit\n",
diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c
index ec76b035f..f439b68e6 100644
--- a/src/inputPlugins/mpc_plugin.c
+++ b/src/inputPlugins/mpc_plugin.c
@@ -66,10 +66,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;
@@ -114,7 +114,7 @@ static int mpc_decode(struct decoder * mpd_decoder, 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;
@@ -171,7 +171,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
audio_format.sampleRate;
if (mpc_decoder_seek_sample(&decoder, samplePos)) {
decoder_clear(mpd_decoder);
- s16 = (mpd_sint16 *) chunk;
+ s16 = (int16_t *) chunk;
chunkpos = 0;
decoder_command_finished(mpd_decoder);
} else
@@ -213,7 +213,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
bitRate, replayGainInfo);
chunkpos = 0;
- s16 = (mpd_sint16 *) chunk;
+ s16 = (int16_t *) chunk;
if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_STOP) {
eof = 1;
break;
diff --git a/src/mpd_types.h b/src/mpd_types.h
index ed573c4a4..0cc35b996 100644
--- a/src/mpd_types.h
+++ b/src/mpd_types.h
@@ -21,24 +21,49 @@
#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 <inttypes.h>
+#elif defined(HAVE_STDINT_H)
+# include <stdint.h>
+#elif defined(HAVE_SYS_INTTYPES_H)
+# include <sys/inttypes.h> /* some ancient systems had this, untested */
+#endif /* C99-ish type headers */
+
+#include <sys/types.h>
+
+#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 */
union const_hack {
const char *in;
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index 0efc5d16a..15ba1aa97 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -153,7 +153,7 @@ ob_chunk * ob_get_chunk(const unsigned i)
* @return the chunk which has room for more data; NULL if there is no
* room.
*/
-static ob_chunk *tail_chunk(float data_time, mpd_uint16 bitRate)
+static ob_chunk *tail_chunk(float data_time, uint16_t bitRate)
{
unsigned int next;
ob_chunk *chunk;
@@ -184,7 +184,7 @@ static ob_chunk *tail_chunk(float data_time, mpd_uint16 bitRate)
}
size_t ob_append(const void *data0, size_t datalen,
- float data_time, mpd_uint16 bitRate)
+ float data_time, uint16_t bitRate)
{
const unsigned char *data = data0;
size_t ret = 0, dataToSend;
diff --git a/src/outputBuffer.h b/src/outputBuffer.h
index b6fdda926..835ac222e 100644
--- a/src/outputBuffer.h
+++ b/src/outputBuffer.h
@@ -26,8 +26,8 @@
#define CHUNK_SIZE 1020
typedef struct _OutputBufferChunk {
- mpd_uint16 chunkSize;
- mpd_uint16 bitRate;
+ uint16_t chunkSize;
+ uint16_t bitRate;
float times;
char data[CHUNK_SIZE];
} ob_chunk;
@@ -102,9 +102,8 @@ ob_chunk * ob_get_chunk(const unsigned i);
* @return the number of bytes actually written
*/
size_t ob_append(const void *data, size_t datalen,
- float data_time, mpd_uint16 bitRate);
+ float data_time, uint16_t bitRate);
void ob_skip(unsigned num);
#endif
-
diff --git a/src/player_control.h b/src/player_control.h
index 805f0325d..ccc98d9d3 100644
--- a/src/player_control.h
+++ b/src/player_control.h
@@ -85,21 +85,21 @@ struct player_control {
Notify notify;
volatile enum player_command command;
volatile enum player_state state;
- volatile mpd_sint8 error;
- volatile mpd_uint16 bitRate;
- volatile mpd_sint8 bits;
- volatile mpd_sint8 channels;
- volatile mpd_uint32 sampleRate;
+ volatile int8_t error;
+ volatile uint16_t bitRate;
+ volatile int8_t bits;
+ volatile int8_t channels;
+ volatile uint32_t sampleRate;
volatile float totalTime;
volatile float elapsedTime;
volatile float fileTime;
Song *volatile next_song;
Song *errored_song;
volatile enum player_queue_state queueState;
- volatile mpd_sint8 queueLockState;
+ volatile int8_t queueLockState;
volatile double seekWhere;
volatile float crossFade;
- volatile mpd_uint16 softwareVolume;
+ volatile uint16_t softwareVolume;
volatile double totalPlayTime;
};
diff --git a/src/playlist.c b/src/playlist.c
index 233e434b7..e735d7731 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -73,7 +73,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;
@@ -141,7 +141,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);
@@ -369,7 +369,7 @@ static void printPlaylistSongInfo(struct client *client, int song)
client_printf(client, "Pos: %i\nId: %i\n", song, playlist.positionToId[song]);
}
-int playlistChanges(struct client *client, mpd_uint32 version)
+int playlistChanges(struct client *client, uint32_t version)
{
int i;
@@ -384,7 +384,7 @@ int playlistChanges(struct client *client, mpd_uint32 version)
return 0;
}
-int playlistChangesPosId(struct client *client, mpd_uint32 version)
+int playlistChangesPosId(struct client *client, uint32_t version)
{
int i;
diff --git a/src/playlist.h b/src/playlist.h
index 8d964aabd..acc44aca6 100644
--- a/src/playlist.h
+++ b/src/playlist.h
@@ -39,7 +39,7 @@ enum playlist_result {
typedef struct _Playlist {
Song **songs;
/* holds version a song was modified on */
- mpd_uint32 *songMod;
+ uint32_t *songMod;
int *order;
int *positionToId;
int *idToPosition;
@@ -48,7 +48,7 @@ typedef struct _Playlist {
int queued;
int repeat;
int random;
- mpd_uint32 version;
+ uint32_t version;
} Playlist;
extern int playlist_saveAbsolutePaths;
@@ -137,9 +137,9 @@ enum playlist_result seekSongInPlaylistById(int id, float seek_time);
void playlistVersionChange(void);
-int playlistChanges(struct client *client, mpd_uint32 version);
+int playlistChanges(struct client *client, uint32_t version);
-int playlistChangesPosId(struct client *client, mpd_uint32 version);
+int playlistChangesPosId(struct client *client, uint32_t version);
int PlaylistInfo(struct client *client, const char *utf8file, int detail);
diff --git a/src/song.h b/src/song.h
index 3e7f8666d..00629d702 100644
--- a/src/song.h
+++ b/src/song.h
@@ -35,7 +35,7 @@ struct client;
typedef struct _Song {
char *url;
- mpd_sint8 type;
+ int8_t type;
struct tag *tag;
struct _Directory *parentDir;
time_t mtime;