From 727c301fbcd285ff781f2d9b538973ca6a4ebcef Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 11 Oct 2009 23:32:22 +0200 Subject: input_stream: use "goffset" instead of "off_t" The "off_t" type may change when you enable or disable large file support on 32 bit platforms. This caused severe ABI problems within MPD when we enabled LFS for the first time: two sources included config.h and sys/types.h in different order, and had different off_t sizes - leading to memory corruption because of ABI incompatibility. This patch attempts to get rid of all public "off_t" uses: it removes "off_t" from the input_stream ABI/API, and switches to GLib's 64 bit "goffset" type. This may hurt 32 bit embedded platforms a tiny bit, but that's not even measurable. --- src/decoder/mad_plugin.c | 8 ++++---- src/decoder/mpg123_decoder_plugin.c | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/decoder') diff --git a/src/decoder/mad_plugin.c b/src/decoder/mad_plugin.c index c5287564f..27ddf655d 100644 --- a/src/decoder/mad_plugin.c +++ b/src/decoder/mad_plugin.c @@ -779,10 +779,10 @@ mp3_frame_duration(const struct mad_frame *frame) MAD_UNITS_MILLISECONDS) / 1000.0; } -static off_t +static goffset mp3_this_frame_offset(const struct mp3_data *data) { - off_t offset = data->input_stream->offset; + goffset offset = data->input_stream->offset; if (data->stream.this_frame != NULL) offset -= data->stream.bufend - data->stream.this_frame; @@ -792,7 +792,7 @@ mp3_this_frame_offset(const struct mp3_data *data) return offset; } -static off_t +static goffset mp3_rest_including_this_frame(const struct mp3_data *data) { return data->input_stream->size - mp3_this_frame_offset(data); @@ -804,7 +804,7 @@ mp3_rest_including_this_frame(const struct mp3_data *data) static void mp3_filesize_to_song_length(struct mp3_data *data) { - off_t rest = mp3_rest_including_this_frame(data); + goffset rest = mp3_rest_including_this_frame(data); if (rest > 0) { float frame_duration = mp3_frame_duration(&data->frame); diff --git a/src/decoder/mpg123_decoder_plugin.c b/src/decoder/mpg123_decoder_plugin.c index 7ffeb1155..20d9c4a54 100644 --- a/src/decoder/mpg123_decoder_plugin.c +++ b/src/decoder/mpg123_decoder_plugin.c @@ -17,6 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "config.h" /* must be first for large file support */ #include "decoder_api.h" #include -- cgit v1.2.3