aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-17 09:43:55 +0200
committerMax Kellermann <max@duempel.org>2013-10-17 10:45:10 +0200
commit05de2e998c7df2757ae63ce6a053e27eca3d13ca (patch)
tree2c85c43cb69dc2dc7086bfddc66090928cd0d93f /src/decoder
parent24780d99e61af44141e8f0d0d0776a1c994e6770 (diff)
downloadmpd-05de2e998c7df2757ae63ce6a053e27eca3d13ca.tar.gz
mpd-05de2e998c7df2757ae63ce6a053e27eca3d13ca.tar.xz
mpd-05de2e998c7df2757ae63ce6a053e27eca3d13ca.zip
InputStream: use int64_t instead of goffset
Decouple some more from GLib.
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/DsdLib.cxx14
-rw-r--r--src/decoder/DsdLib.hxx9
-rw-r--r--src/decoder/DsdiffDecoderPlugin.cxx22
-rw-r--r--src/decoder/DsfDecoderPlugin.cxx4
-rw-r--r--src/decoder/FaadDecoderPlugin.cxx2
-rw-r--r--src/decoder/MadDecoderPlugin.cxx12
-rw-r--r--src/decoder/ModplugDecoderPlugin.cxx6
-rw-r--r--src/decoder/PcmDecoderPlugin.cxx6
8 files changed, 37 insertions, 38 deletions
diff --git a/src/decoder/DsdLib.cxx b/src/decoder/DsdLib.cxx
index 7135c9903..491b158e6 100644
--- a/src/decoder/DsdLib.cxx
+++ b/src/decoder/DsdLib.cxx
@@ -63,7 +63,7 @@ dsdlib_read(struct decoder *decoder, struct input_stream *is,
*/
bool
dsdlib_skip_to(struct decoder *decoder, struct input_stream *is,
- goffset offset)
+ int64_t offset)
{
if (is->IsSeekable())
return is->Seek(offset, SEEK_SET, IgnoreError());
@@ -74,7 +74,7 @@ dsdlib_skip_to(struct decoder *decoder, struct input_stream *is,
char buffer[8192];
while (is->GetOffset() < offset) {
size_t length = sizeof(buffer);
- if (offset - is->GetOffset() < (goffset)length)
+ if (offset - is->GetOffset() < (int64_t)length)
length = offset - is->GetOffset();
size_t nbytes = decoder_read(decoder, is, buffer, length);
@@ -91,7 +91,7 @@ dsdlib_skip_to(struct decoder *decoder, struct input_stream *is,
*/
bool
dsdlib_skip(struct decoder *decoder, struct input_stream *is,
- goffset delta)
+ int64_t delta)
{
assert(delta >= 0);
@@ -104,7 +104,7 @@ dsdlib_skip(struct decoder *decoder, struct input_stream *is,
char buffer[8192];
while (delta > 0) {
size_t length = sizeof(buffer);
- if ((goffset)length > delta)
+ if ((int64_t)length > delta)
length = delta;
size_t nbytes = decoder_read(decoder, is, buffer, length);
@@ -126,7 +126,7 @@ dsdlib_skip(struct decoder *decoder, struct input_stream *is,
void
dsdlib_tag_id3(struct input_stream *is,
const struct tag_handler *handler,
- void *handler_ctx, goffset tagoffset)
+ void *handler_ctx, int64_t tagoffset)
{
assert(tagoffset >= 0);
@@ -140,8 +140,8 @@ dsdlib_tag_id3(struct input_stream *is,
id3_length_t count;
/* Prevent broken files causing problems */
- const goffset size = is->GetSize();
- const goffset offset = is->GetOffset();
+ const auto size = is->GetSize();
+ const auto offset = is->GetOffset();
if (offset >= size)
return;
diff --git a/src/decoder/DsdLib.hxx b/src/decoder/DsdLib.hxx
index 2a8e15190..b1c708fca 100644
--- a/src/decoder/DsdLib.hxx
+++ b/src/decoder/DsdLib.hxx
@@ -21,8 +21,7 @@
#define MPD_DECODER_DSDLIB_HXX
#include <stdlib.h>
-
-#include <glib.h>
+#include <stdint.h>
struct dsdlib_id {
char value[4];
@@ -37,15 +36,15 @@ dsdlib_read(struct decoder *decoder, struct input_stream *is,
bool
dsdlib_skip_to(struct decoder *decoder, struct input_stream *is,
- goffset offset);
+ int64_t offset);
bool
dsdlib_skip(struct decoder *decoder, struct input_stream *is,
- goffset delta);
+ int64_t delta);
void
dsdlib_tag_id3(struct input_stream *is,
const struct tag_handler *handler,
- void *handler_ctx, goffset tagoffset);
+ void *handler_ctx, int64_t tagoffset);
#endif
diff --git a/src/decoder/DsdiffDecoderPlugin.cxx b/src/decoder/DsdiffDecoderPlugin.cxx
index c4150dd91..93002509f 100644
--- a/src/decoder/DsdiffDecoderPlugin.cxx
+++ b/src/decoder/DsdiffDecoderPlugin.cxx
@@ -72,13 +72,13 @@ struct DsdiffMetaData {
bool bitreverse;
uint64_t chunk_size;
#ifdef HAVE_ID3TAG
- goffset id3_offset;
+ input_stream::offset_type id3_offset;
uint64_t id3_size;
#endif
/** offset for artist tag */
- goffset diar_offset;
+ input_stream::offset_type diar_offset;
/** offset for title tag */
- goffset diti_offset;
+ input_stream::offset_type diti_offset;
};
static bool lsbitfirst;
@@ -123,14 +123,14 @@ dsdiff_read_payload(struct decoder *decoder, struct input_stream *is,
static bool
dsdiff_read_prop_snd(struct decoder *decoder, struct input_stream *is,
DsdiffMetaData *metadata,
- goffset end_offset)
+ input_stream::offset_type end_offset)
{
DsdiffChunkHeader header;
- while ((goffset)(is->GetOffset() + sizeof(header)) <= end_offset) {
+ while ((input_stream::offset_type)(is->GetOffset() + sizeof(header)) <= end_offset) {
if (!dsdiff_read_chunk_header(decoder, is, &header))
return false;
- goffset chunk_end_offset = is->GetOffset()
+ input_stream::offset_type chunk_end_offset = is->GetOffset()
+ header.GetSize();
if (chunk_end_offset > end_offset)
return false;
@@ -184,7 +184,7 @@ dsdiff_read_prop(struct decoder *decoder, struct input_stream *is,
const DsdiffChunkHeader *prop_header)
{
uint64_t prop_size = prop_header->GetSize();
- goffset end_offset = is->GetOffset() + prop_size;
+ input_stream::offset_type end_offset = is->GetOffset() + prop_size;
struct dsdlib_id prop_id;
if (prop_size < sizeof(prop_id) ||
@@ -201,7 +201,7 @@ dsdiff_read_prop(struct decoder *decoder, struct input_stream *is,
static void
dsdiff_handle_native_tag(struct input_stream *is,
const struct tag_handler *handler,
- void *handler_ctx, goffset tagoffset,
+ void *handler_ctx, input_stream::offset_type tagoffset,
enum tag_type type)
{
if (!dsdlib_skip_to(nullptr, is, tagoffset))
@@ -259,7 +259,7 @@ dsdiff_read_metadata_extra(struct decoder *decoder, struct input_stream *is,
/* Now process all the remaining chunk headers in the stream
and record their position and size */
- const goffset size = is->GetSize();
+ const auto size = is->GetSize();
while (is->GetOffset() < size) {
uint64_t chunk_size = chunk_header->GetSize();
@@ -351,8 +351,8 @@ dsdiff_read_metadata(struct decoder *decoder, struct input_stream *is,
} else {
/* ignore unknown chunk */
const uint64_t chunk_size = chunk_header->GetSize();
- goffset chunk_end_offset = is->GetOffset()
- + chunk_size;
+ input_stream::offset_type chunk_end_offset =
+ is->GetOffset() + chunk_size;
if (!dsdlib_skip_to(decoder, is, chunk_end_offset))
return false;
diff --git a/src/decoder/DsfDecoderPlugin.cxx b/src/decoder/DsfDecoderPlugin.cxx
index 28004e8b7..95735d8c6 100644
--- a/src/decoder/DsfDecoderPlugin.cxx
+++ b/src/decoder/DsfDecoderPlugin.cxx
@@ -47,7 +47,7 @@ struct DsfMetaData {
bool bitreverse;
uint64_t chunk_size;
#ifdef HAVE_ID3TAG
- goffset id3_offset;
+ input_stream::offset_type id3_offset;
uint64_t id3_size;
#endif
};
@@ -176,7 +176,7 @@ dsf_read_metadata(struct decoder *decoder, struct input_stream *is,
if (metadata_offset >= size)
metadata->id3_offset = 0;
else
- metadata->id3_offset = (goffset) metadata_offset;
+ metadata->id3_offset = (input_stream::offset_type)metadata_offset;
#endif
/* check bits per sample format, determine if bitreverse is needed */
metadata->bitreverse = dsf_fmt_chunk.bitssample == 1;
diff --git a/src/decoder/FaadDecoderPlugin.cxx b/src/decoder/FaadDecoderPlugin.cxx
index de846c61a..077b3ccf2 100644
--- a/src/decoder/FaadDecoderPlugin.cxx
+++ b/src/decoder/FaadDecoderPlugin.cxx
@@ -170,7 +170,7 @@ faad_song_duration(DecoderBuffer *buffer, struct input_stream *is)
size_t length;
bool success;
- const goffset size = is->GetSize();
+ const auto size = is->GetSize();
fileread = size >= 0 ? size : 0;
decoder_buffer_fill(buffer);
diff --git a/src/decoder/MadDecoderPlugin.cxx b/src/decoder/MadDecoderPlugin.cxx
index 1cce24f31..a6c53bfb6 100644
--- a/src/decoder/MadDecoderPlugin.cxx
+++ b/src/decoder/MadDecoderPlugin.cxx
@@ -152,10 +152,10 @@ struct MadDecoder {
enum mp3_action DecodeNextFrame();
gcc_pure
- goffset ThisFrameOffset() const;
+ input_stream::offset_type ThisFrameOffset() const;
gcc_pure
- goffset RestIncludingThisFrame() const;
+ input_stream::offset_type RestIncludingThisFrame() const;
/**
* Attempt to calulcate the length of the song from filesize
@@ -776,10 +776,10 @@ mp3_frame_duration(const struct mad_frame *frame)
MAD_UNITS_MILLISECONDS) / 1000.0;
}
-inline goffset
+inline input_stream::offset_type
MadDecoder::ThisFrameOffset() const
{
- goffset offset = input_stream->GetOffset();
+ auto offset = input_stream->GetOffset();
if (stream.this_frame != nullptr)
offset -= stream.bufend - stream.this_frame;
@@ -789,7 +789,7 @@ MadDecoder::ThisFrameOffset() const
return offset;
}
-inline goffset
+inline input_stream::offset_type
MadDecoder::RestIncludingThisFrame() const
{
return input_stream->GetSize() - ThisFrameOffset();
@@ -798,7 +798,7 @@ MadDecoder::RestIncludingThisFrame() const
inline void
MadDecoder::FileSizeToSongLength()
{
- goffset rest = RestIncludingThisFrame();
+ input_stream::offset_type rest = RestIncludingThisFrame();
if (rest > 0) {
float frame_duration = mp3_frame_duration(&frame);
diff --git a/src/decoder/ModplugDecoderPlugin.cxx b/src/decoder/ModplugDecoderPlugin.cxx
index 39c366492..685675350 100644
--- a/src/decoder/ModplugDecoderPlugin.cxx
+++ b/src/decoder/ModplugDecoderPlugin.cxx
@@ -36,12 +36,12 @@ static constexpr Domain modplug_domain("modplug");
static constexpr size_t MODPLUG_FRAME_SIZE = 4096;
static constexpr size_t MODPLUG_PREALLOC_BLOCK = 256 * 1024;
static constexpr size_t MODPLUG_READ_BLOCK = 128 * 1024;
-static constexpr goffset MODPLUG_FILE_LIMIT = 100 * 1024 * 1024;
+static constexpr input_stream::offset_type MODPLUG_FILE_LIMIT = 100 * 1024 * 1024;
static GByteArray *
mod_loadfile(struct decoder *decoder, struct input_stream *is)
{
- const goffset size = is->GetSize();
+ const input_stream::offset_type size = is->GetSize();
if (size == 0) {
LogWarning(modplug_domain, "file is empty");
@@ -77,7 +77,7 @@ mod_loadfile(struct decoder *decoder, struct input_stream *is)
return nullptr;
}
- if (goffset(bdatas->len + ret) > MODPLUG_FILE_LIMIT) {
+ if (input_stream::offset_type(bdatas->len + ret) > MODPLUG_FILE_LIMIT) {
LogWarning(modplug_domain, "stream too large");
g_free(data);
g_byte_array_free(bdatas, TRUE);
diff --git a/src/decoder/PcmDecoderPlugin.cxx b/src/decoder/PcmDecoderPlugin.cxx
index 61062f7f9..874fb5b89 100644
--- a/src/decoder/PcmDecoderPlugin.cxx
+++ b/src/decoder/PcmDecoderPlugin.cxx
@@ -46,7 +46,7 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
const double time_to_size = audio_format.GetTimeToSize();
float total_time = -1;
- const goffset size = is->GetSize();
+ const auto size = is->GetSize();
if (size >= 0)
total_time = size / time_to_size;
@@ -74,8 +74,8 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
buffer, nbytes, 0)
: decoder_get_command(decoder);
if (cmd == DecoderCommand::SEEK) {
- goffset offset = (goffset)(time_to_size *
- decoder_seek_where(decoder));
+ input_stream::offset_type offset(time_to_size *
+ decoder_seek_where(decoder));
Error error;
if (is->LockSeek(offset, SEEK_SET, error)) {