diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/InputPlugin.hxx | 7 | ||||
-rw-r--r-- | src/InputStream.cxx | 4 | ||||
-rw-r--r-- | src/InputStream.hxx | 17 | ||||
-rw-r--r-- | src/PlaylistPrint.cxx | 2 | ||||
-rw-r--r-- | src/PlaylistQueue.cxx | 2 | ||||
-rw-r--r-- | src/PlaylistRegistry.cxx | 2 | ||||
-rw-r--r-- | src/archive/ZzipArchivePlugin.cxx | 6 | ||||
-rw-r--r-- | src/decoder/DsdLib.cxx | 14 | ||||
-rw-r--r-- | src/decoder/DsdLib.hxx | 9 | ||||
-rw-r--r-- | src/decoder/DsdiffDecoderPlugin.cxx | 22 | ||||
-rw-r--r-- | src/decoder/DsfDecoderPlugin.cxx | 4 | ||||
-rw-r--r-- | src/decoder/FaadDecoderPlugin.cxx | 2 | ||||
-rw-r--r-- | src/decoder/MadDecoderPlugin.cxx | 12 | ||||
-rw-r--r-- | src/decoder/ModplugDecoderPlugin.cxx | 6 | ||||
-rw-r--r-- | src/decoder/PcmDecoderPlugin.cxx | 6 | ||||
-rw-r--r-- | src/input/CdioParanoiaInputPlugin.cxx | 2 | ||||
-rw-r--r-- | src/input/CurlInputPlugin.cxx | 7 | ||||
-rw-r--r-- | src/input/FfmpegInputPlugin.cxx | 5 | ||||
-rw-r--r-- | src/input/FileInputPlugin.cxx | 5 | ||||
-rw-r--r-- | src/input/RewindInputPlugin.cxx | 8 |
20 files changed, 78 insertions, 64 deletions
diff --git a/src/InputPlugin.hxx b/src/InputPlugin.hxx index f6976bf8d..134207584 100644 --- a/src/InputPlugin.hxx +++ b/src/InputPlugin.hxx @@ -23,9 +23,8 @@ #include "thread/Mutex.hxx" #include "thread/Cond.hxx" -#include <glib.h> - #include <stddef.h> +#include <stdint.h> struct config_param; struct input_stream; @@ -33,6 +32,8 @@ class Error; struct Tag; struct InputPlugin { + typedef int64_t offset_type; + const char *name; /** @@ -85,7 +86,7 @@ struct InputPlugin { size_t (*read)(struct input_stream *is, void *ptr, size_t size, Error &error); bool (*eof)(struct input_stream *is); - bool (*seek)(struct input_stream *is, goffset offset, int whence, + bool (*seek)(struct input_stream *is, offset_type offset, int whence, Error &error); }; diff --git a/src/InputStream.cxx b/src/InputStream.cxx index 8a9f6c66d..23e535d15 100644 --- a/src/InputStream.cxx +++ b/src/InputStream.cxx @@ -95,7 +95,7 @@ input_stream::CheapSeeking() const } bool -input_stream::Seek(goffset _offset, int whence, Error &error) +input_stream::Seek(offset_type _offset, int whence, Error &error) { if (plugin.seek == nullptr) return false; @@ -104,7 +104,7 @@ input_stream::Seek(goffset _offset, int whence, Error &error) } bool -input_stream::LockSeek(goffset _offset, int whence, Error &error) +input_stream::LockSeek(offset_type _offset, int whence, Error &error) { if (plugin.seek == nullptr) return false; diff --git a/src/InputStream.hxx b/src/InputStream.hxx index 51f32deec..2a3d7b2cd 100644 --- a/src/InputStream.hxx +++ b/src/InputStream.hxx @@ -26,9 +26,8 @@ #include <string> -#include <glib.h> - #include <assert.h> +#include <stdint.h> class Cond; class Error; @@ -36,6 +35,8 @@ struct Tag; struct InputPlugin; struct input_stream { + typedef int64_t offset_type; + /** * the plugin which implements this input stream */ @@ -80,12 +81,12 @@ struct input_stream { /** * the size of the resource, or -1 if unknown */ - goffset size; + offset_type size; /** * the current offset within the stream */ - goffset offset; + offset_type offset; /** * the MIME content type of the resource, or empty if unknown. @@ -173,14 +174,14 @@ struct input_stream { } gcc_pure - goffset GetSize() const { + offset_type GetSize() const { assert(ready); return size; } gcc_pure - goffset GetOffset() const { + offset_type GetOffset() const { assert(ready); return offset; @@ -208,13 +209,13 @@ struct input_stream { * @param offset the relative offset * @param whence the base of the seek, one of SEEK_SET, SEEK_CUR, SEEK_END */ - bool Seek(goffset offset, int whence, Error &error); + bool Seek(offset_type offset, int whence, Error &error); /** * Wrapper for Seek() which locks and unlocks the mutex; the * caller must not be holding it already. */ - bool LockSeek(goffset offset, int whence, Error &error); + bool LockSeek(offset_type offset, int whence, Error &error); /** * Returns true if the stream has reached end-of-file. diff --git a/src/PlaylistPrint.cxx b/src/PlaylistPrint.cxx index 791a600c5..0a9b5c4bc 100644 --- a/src/PlaylistPrint.cxx +++ b/src/PlaylistPrint.cxx @@ -36,6 +36,8 @@ #include "util/Error.hxx" #include "thread/Cond.hxx" +#include <glib.h> + void playlist_print_uris(Client *client, const struct playlist *playlist) { diff --git a/src/PlaylistQueue.cxx b/src/PlaylistQueue.cxx index 183237b5f..28a1ff22d 100644 --- a/src/PlaylistQueue.cxx +++ b/src/PlaylistQueue.cxx @@ -28,6 +28,8 @@ #include "Song.hxx" #include "thread/Cond.hxx" +#include <glib.h> + enum playlist_result playlist_load_into_queue(const char *uri, SongEnumerator &e, unsigned start_index, unsigned end_index, diff --git a/src/PlaylistRegistry.cxx b/src/PlaylistRegistry.cxx index 2a4cf8c5d..f18f7c5e9 100644 --- a/src/PlaylistRegistry.cxx +++ b/src/PlaylistRegistry.cxx @@ -40,6 +40,8 @@ #include "system/FatalError.hxx" #include "Log.hxx" +#include <glib.h> + #include <assert.h> #include <string.h> #include <stdio.h> diff --git a/src/archive/ZzipArchivePlugin.cxx b/src/archive/ZzipArchivePlugin.cxx index ebac331b5..35730d078 100644 --- a/src/archive/ZzipArchivePlugin.cxx +++ b/src/archive/ZzipArchivePlugin.cxx @@ -178,12 +178,12 @@ zzip_input_eof(struct input_stream *is) { ZzipInputStream *zis = (ZzipInputStream *)is; - return (goffset)zzip_tell(zis->file) == is->size; + return (InputPlugin::offset_type)zzip_tell(zis->file) == is->size; } static bool -zzip_input_seek(struct input_stream *is, - goffset offset, int whence, Error &error) +zzip_input_seek(struct input_stream *is, InputPlugin::offset_type offset, + int whence, Error &error) { ZzipInputStream *zis = (ZzipInputStream *)is; zzip_off_t ofs = zzip_seek(zis->file, offset, whence); 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)) { diff --git a/src/input/CdioParanoiaInputPlugin.cxx b/src/input/CdioParanoiaInputPlugin.cxx index d441ed818..654a6dc4a 100644 --- a/src/input/CdioParanoiaInputPlugin.cxx +++ b/src/input/CdioParanoiaInputPlugin.cxx @@ -250,7 +250,7 @@ input_cdio_open(const char *uri, static bool input_cdio_seek(struct input_stream *is, - goffset offset, int whence, Error &error) + InputPlugin::offset_type offset, int whence, Error &error) { CdioParanoiaInputStream *cis = (CdioParanoiaInputStream *)is; diff --git a/src/input/CurlInputPlugin.cxx b/src/input/CurlInputPlugin.cxx index 5a89fc1fd..6f11153ec 100644 --- a/src/input/CurlInputPlugin.cxx +++ b/src/input/CurlInputPlugin.cxx @@ -780,7 +780,7 @@ input_curl_read(struct input_stream *is, void *ptr, size_t size, if (c->icy.IsDefined()) copy_icy_tag(c); - is->offset += (goffset)nbytes; + is->offset += (InputPlugin::offset_type)nbytes; if (c->paused && curl_total_buffer_size(c) < CURL_RESUME_AT) { c->base.mutex.unlock(); @@ -977,7 +977,8 @@ input_curl_easy_init(struct input_curl *c, Error &error) } static bool -input_curl_seek(struct input_stream *is, goffset offset, int whence, +input_curl_seek(struct input_stream *is, InputPlugin::offset_type offset, + int whence, Error &error) { struct input_curl *c = (struct input_curl *)is; @@ -1022,7 +1023,7 @@ input_curl_seek(struct input_stream *is, goffset offset, int whence, while (offset > is->offset && !c->buffers.empty()) { auto &buffer = c->buffers.front(); size_t length = buffer.Available(); - if (offset - is->offset < (goffset)length) + if (offset - is->offset < (InputPlugin::offset_type)length) length = offset - is->offset; const bool empty = !buffer.Consume(length); diff --git a/src/input/FfmpegInputPlugin.cxx b/src/input/FfmpegInputPlugin.cxx index e6eeaa8fc..0d9cf6b8f 100644 --- a/src/input/FfmpegInputPlugin.cxx +++ b/src/input/FfmpegInputPlugin.cxx @@ -34,6 +34,8 @@ extern "C" { #include <libavformat/avformat.h> } +#include <glib.h> + struct FfmpegInputStream { struct input_stream base; @@ -146,7 +148,8 @@ input_ffmpeg_eof(struct input_stream *is) } static bool -input_ffmpeg_seek(struct input_stream *is, goffset offset, int whence, +input_ffmpeg_seek(struct input_stream *is, InputPlugin::offset_type offset, + int whence, Error &error) { FfmpegInputStream *i = (FfmpegInputStream *)is; diff --git a/src/input/FileInputPlugin.cxx b/src/input/FileInputPlugin.cxx index 221dbff84..f52b1cd14 100644 --- a/src/input/FileInputPlugin.cxx +++ b/src/input/FileInputPlugin.cxx @@ -97,12 +97,13 @@ input_file_open(const char *filename, } static bool -input_file_seek(struct input_stream *is, goffset offset, int whence, +input_file_seek(struct input_stream *is, InputPlugin::offset_type offset, + int whence, Error &error) { FileInputStream *fis = (FileInputStream *)is; - offset = (goffset)lseek(fis->fd, (off_t)offset, whence); + offset = (InputPlugin::offset_type)lseek(fis->fd, (off_t)offset, whence); if (offset < 0) { error.SetErrno("Failed to seek"); return false; diff --git a/src/input/RewindInputPlugin.cxx b/src/input/RewindInputPlugin.cxx index 2088d8eea..567fb6888 100644 --- a/src/input/RewindInputPlugin.cxx +++ b/src/input/RewindInputPlugin.cxx @@ -164,7 +164,7 @@ input_rewind_read(struct input_stream *is, void *ptr, size_t size, size_t nbytes = r->input->Read(ptr, size, error); - if (r->input->offset > (goffset)sizeof(r->buffer)) + if (r->input->offset > (InputPlugin::offset_type)sizeof(r->buffer)) /* disable buffering */ r->tail = 0; else if (r->tail == (size_t)is->offset) { @@ -191,14 +191,16 @@ input_rewind_eof(struct input_stream *is) } static bool -input_rewind_seek(struct input_stream *is, goffset offset, int whence, +input_rewind_seek(struct input_stream *is, InputPlugin::offset_type offset, + int whence, Error &error) { RewindInputStream *r = (RewindInputStream *)is; assert(is->ready); - if (whence == SEEK_SET && r->tail > 0 && offset <= (goffset)r->tail) { + if (whence == SEEK_SET && r->tail > 0 && + offset <= (InputPlugin::offset_type)r->tail) { /* buffered seek */ assert(!r->ReadingFromBuffer() || |