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.
This commit is contained in:
@@ -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);
|
||||
|
@@ -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 <glib.h>
|
||||
|
Reference in New Issue
Block a user