aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/AudiofileDecoderPlugin.cxx15
-rw-r--r--src/decoder/DsdLib.cxx23
-rw-r--r--src/decoder/DsdiffDecoderPlugin.cxx24
-rw-r--r--src/decoder/DsfDecoderPlugin.cxx3
-rw-r--r--src/decoder/FaadDecoderPlugin.cxx10
-rw-r--r--src/decoder/FfmpegDecoderPlugin.cxx5
-rw-r--r--src/decoder/FlacDecoderPlugin.cxx2
-rw-r--r--src/decoder/FlacIOHandle.cxx6
-rw-r--r--src/decoder/FlacInput.cxx8
-rw-r--r--src/decoder/MadDecoderPlugin.cxx15
-rw-r--r--src/decoder/ModplugDecoderPlugin.cxx7
-rw-r--r--src/decoder/MpcdecDecoderPlugin.cxx12
-rw-r--r--src/decoder/OpusDecoderPlugin.cxx6
-rw-r--r--src/decoder/PcmDecoderPlugin.cxx12
-rw-r--r--src/decoder/SndfileDecoderPlugin.cxx11
-rw-r--r--src/decoder/VorbisDecoderPlugin.cxx6
-rw-r--r--src/decoder/WavpackDecoderPlugin.cxx15
17 files changed, 88 insertions, 92 deletions
diff --git a/src/decoder/AudiofileDecoderPlugin.cxx b/src/decoder/AudiofileDecoderPlugin.cxx
index c146466cb..d19249932 100644
--- a/src/decoder/AudiofileDecoderPlugin.cxx
+++ b/src/decoder/AudiofileDecoderPlugin.cxx
@@ -20,6 +20,7 @@
#include "config.h"
#include "AudiofileDecoderPlugin.hxx"
#include "DecoderAPI.hxx"
+#include "InputStream.hxx"
#include "CheckAudioFormat.hxx"
#include "TagHandler.hxx"
#include "util/Error.hxx"
@@ -56,7 +57,7 @@ audiofile_file_read(AFvirtualfile *vfile, void *data, size_t length)
struct input_stream *is = (struct input_stream *) vfile->closure;
Error error;
- size_t nbytes = input_stream_lock_read(is, data, length, error);
+ size_t nbytes = is->LockRead(data, length, error);
if (nbytes == 0 && error.IsDefined()) {
g_warning("%s", error.GetMessage());
return -1;
@@ -69,14 +70,14 @@ static AFfileoffset
audiofile_file_length(AFvirtualfile *vfile)
{
struct input_stream *is = (struct input_stream *) vfile->closure;
- return input_stream_get_size(is);
+ return is->GetSize();
}
static AFfileoffset
audiofile_file_tell(AFvirtualfile *vfile)
{
struct input_stream *is = (struct input_stream *) vfile->closure;
- return input_stream_get_offset(is);
+ return is->GetOffset();
}
static void
@@ -94,8 +95,8 @@ audiofile_file_seek(AFvirtualfile *vfile, AFfileoffset offset, int is_relative)
int whence = (is_relative ? SEEK_CUR : SEEK_SET);
Error error;
- if (input_stream_lock_seek(is, offset, whence, error)) {
- return input_stream_get_offset(is);
+ if (is->LockSeek(offset, whence, error)) {
+ return is->GetOffset();
} else {
return -1;
}
@@ -167,7 +168,7 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
char chunk[CHUNK_SIZE];
enum decoder_command cmd;
- if (!input_stream_is_seekable(is)) {
+ if (!is->IsSeekable()) {
g_warning("not seekable");
return;
}
@@ -195,7 +196,7 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
total_time = ((float)frame_count / (float)audio_format.sample_rate);
- bit_rate = (uint16_t)(input_stream_get_size(is) * 8.0 / total_time / 1000.0 + 0.5);
+ bit_rate = (uint16_t)(is->GetSize() * 8.0 / total_time / 1000.0 + 0.5);
fs = (int)afGetVirtualFrameSize(af_fp, AF_DEFAULT_TRACK, 1);
diff --git a/src/decoder/DsdLib.cxx b/src/decoder/DsdLib.cxx
index eb3d537b9..b093d5d66 100644
--- a/src/decoder/DsdLib.cxx
+++ b/src/decoder/DsdLib.cxx
@@ -26,6 +26,7 @@
#include "config.h"
#include "DsdLib.hxx"
#include "DecoderAPI.hxx"
+#include "InputStream.hxx"
#include "util/bit_reverse.h"
#include "TagHandler.hxx"
#include "tag/TagId3.hxx"
@@ -64,24 +65,24 @@ bool
dsdlib_skip_to(struct decoder *decoder, struct input_stream *is,
goffset offset)
{
- if (input_stream_is_seekable(is))
- return input_stream_seek(is, offset, SEEK_SET, IgnoreError());
+ if (is->IsSeekable())
+ return is->Seek(offset, SEEK_SET, IgnoreError());
- if (input_stream_get_offset(is) > offset)
+ if (is->GetOffset() > offset)
return false;
char buffer[8192];
- while (input_stream_get_offset(is) < offset) {
+ while (is->GetOffset() < offset) {
size_t length = sizeof(buffer);
- if (offset - input_stream_get_offset(is) < (goffset)length)
- length = offset - input_stream_get_offset(is);
+ if (offset - is->GetOffset() < (goffset)length)
+ length = offset - is->GetOffset();
size_t nbytes = decoder_read(decoder, is, buffer, length);
if (nbytes == 0)
return false;
}
- assert(input_stream_get_offset(is) == offset);
+ assert(is->GetOffset() == offset);
return true;
}
@@ -97,8 +98,8 @@ dsdlib_skip(struct decoder *decoder, struct input_stream *is,
if (delta == 0)
return true;
- if (input_stream_is_seekable(is))
- return input_stream_seek(is, delta, SEEK_CUR, IgnoreError());
+ if (is->IsSeekable())
+ return is->Seek(delta, SEEK_CUR, IgnoreError());
char buffer[8192];
while (delta > 0) {
@@ -139,8 +140,8 @@ dsdlib_tag_id3(struct input_stream *is,
id3_length_t count;
/* Prevent broken files causing problems */
- const goffset size = input_stream_get_size(is);
- const goffset offset = input_stream_get_offset(is);
+ const goffset size = is->GetSize();
+ const goffset offset = is->GetOffset();
if (offset >= size)
return;
diff --git a/src/decoder/DsdiffDecoderPlugin.cxx b/src/decoder/DsdiffDecoderPlugin.cxx
index 7c461f9c3..71226b8fb 100644
--- a/src/decoder/DsdiffDecoderPlugin.cxx
+++ b/src/decoder/DsdiffDecoderPlugin.cxx
@@ -29,12 +29,12 @@
#include "config.h"
#include "DsdiffDecoderPlugin.hxx"
#include "DecoderAPI.hxx"
+#include "InputStream.hxx"
#include "CheckAudioFormat.hxx"
#include "util/bit_reverse.h"
#include "util/Error.hxx"
#include "TagHandler.hxx"
#include "DsdLib.hxx"
-#include "TagHandler.hxx"
#include <unistd.h>
#include <stdio.h> /* for SEEK_SET, SEEK_CUR */
@@ -127,11 +127,11 @@ dsdiff_read_prop_snd(struct decoder *decoder, struct input_stream *is,
goffset end_offset)
{
DsdiffChunkHeader header;
- while ((goffset)(input_stream_get_offset(is) + sizeof(header)) <= end_offset) {
+ while ((goffset)(is->GetOffset() + sizeof(header)) <= end_offset) {
if (!dsdiff_read_chunk_header(decoder, is, &header))
return false;
- goffset chunk_end_offset = input_stream_get_offset(is)
+ goffset chunk_end_offset = is->GetOffset()
+ header.GetSize();
if (chunk_end_offset > end_offset)
return false;
@@ -173,7 +173,7 @@ dsdiff_read_prop_snd(struct decoder *decoder, struct input_stream *is,
}
}
- return input_stream_get_offset(is) == end_offset;
+ return is->GetOffset() == end_offset;
}
/**
@@ -185,7 +185,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 = input_stream_get_offset(is) + prop_size;
+ goffset end_offset = is->GetOffset() + prop_size;
struct dsdlib_id prop_id;
if (prop_size < sizeof(prop_id) ||
@@ -260,8 +260,8 @@ 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 = input_stream_get_size(is);
- while (input_stream_get_offset(is) < size) {
+ const goffset size = is->GetSize();
+ while (is->GetOffset() < size) {
uint64_t chunk_size = chunk_header->GetSize();
/* DIIN chunk, is directly followed by other chunks */
@@ -271,19 +271,19 @@ dsdiff_read_metadata_extra(struct decoder *decoder, struct input_stream *is,
/* DIAR chunk - DSDIFF native tag for Artist */
if (dsdlib_id_equals(&chunk_header->id, "DIAR")) {
chunk_size = chunk_header->GetSize();
- metadata->diar_offset = input_stream_get_offset(is);
+ metadata->diar_offset = is->GetOffset();
}
/* DITI chunk - DSDIFF native tag for Title */
if (dsdlib_id_equals(&chunk_header->id, "DITI")) {
chunk_size = chunk_header->GetSize();
- metadata->diti_offset = input_stream_get_offset(is);
+ metadata->diti_offset = is->GetOffset();
}
#ifdef HAVE_ID3TAG
/* 'ID3 ' chunk, offspec. Used by sacdextract */
if (dsdlib_id_equals(&chunk_header->id, "ID3 ")) {
chunk_size = chunk_header->GetSize();
- metadata->id3_offset = input_stream_get_offset(is);
+ metadata->id3_offset = is->GetOffset();
metadata->id3_size = chunk_size;
}
#endif
@@ -292,7 +292,7 @@ dsdiff_read_metadata_extra(struct decoder *decoder, struct input_stream *is,
break;
}
- if (input_stream_get_offset(is) < size) {
+ if (is->GetOffset() < size) {
if (!dsdiff_read_chunk_header(decoder, is, chunk_header))
return false;
}
@@ -352,7 +352,7 @@ 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 = input_stream_get_offset(is)
+ goffset chunk_end_offset = is->GetOffset()
+ chunk_size;
if (!dsdlib_skip_to(decoder, is, chunk_end_offset))
diff --git a/src/decoder/DsfDecoderPlugin.cxx b/src/decoder/DsfDecoderPlugin.cxx
index 26ba0e2d6..5f2422e77 100644
--- a/src/decoder/DsfDecoderPlugin.cxx
+++ b/src/decoder/DsfDecoderPlugin.cxx
@@ -30,6 +30,7 @@
#include "config.h"
#include "DsfDecoderPlugin.hxx"
#include "DecoderAPI.hxx"
+#include "InputStream.hxx"
#include "CheckAudioFormat.hxx"
#include "util/bit_reverse.h"
#include "util/Error.hxx"
@@ -165,7 +166,7 @@ dsf_read_metadata(struct decoder *decoder, struct input_stream *is,
metadata->chunk_size = data_size;
/* data_size cannot be bigger or equal to total file size */
- const uint64_t size = (uint64_t)input_stream_get_size(is);
+ const uint64_t size = (uint64_t)is->GetSize();
if (data_size >= size)
return false;
diff --git a/src/decoder/FaadDecoderPlugin.cxx b/src/decoder/FaadDecoderPlugin.cxx
index 1387dc45c..7540413f5 100644
--- a/src/decoder/FaadDecoderPlugin.cxx
+++ b/src/decoder/FaadDecoderPlugin.cxx
@@ -21,6 +21,7 @@
#include "FaadDecoderPlugin.hxx"
#include "DecoderAPI.hxx"
#include "DecoderBuffer.hxx"
+#include "InputStream.hxx"
#include "CheckAudioFormat.hxx"
#include "TagHandler.hxx"
#include "util/Error.hxx"
@@ -173,7 +174,7 @@ faad_song_duration(DecoderBuffer *buffer, struct input_stream *is)
size_t length;
bool success;
- const goffset size = input_stream_get_size(is);
+ const goffset size = is->GetSize();
fileread = size >= 0 ? size : 0;
decoder_buffer_fill(buffer);
@@ -201,12 +202,12 @@ faad_song_duration(DecoderBuffer *buffer, struct input_stream *is)
return -1;
}
- if (input_stream_is_seekable(is) && length >= 2 &&
+ if (is->IsSeekable() && length >= 2 &&
data[0] == 0xFF && ((data[1] & 0xF6) == 0xF0)) {
/* obtain the duration from the ADTS header */
float song_length = adts_song_duration(buffer);
- input_stream_lock_seek(is, tagsize, SEEK_SET, IgnoreError());
+ is->LockSeek(tagsize, SEEK_SET, IgnoreError());
data = (const uint8_t *)decoder_buffer_read(buffer, &length);
if (data != nullptr)
@@ -384,8 +385,7 @@ faad_stream_decode(struct decoder *mpd_decoder, struct input_stream *is)
config->dontUpSampleImplicitSBR = 0;
NeAACDecSetConfiguration(decoder, config);
- while (!decoder_buffer_is_full(buffer) &&
- !input_stream_lock_eof(is) &&
+ while (!decoder_buffer_is_full(buffer) && !is->LockIsEOF() &&
decoder_get_command(mpd_decoder) == DECODE_COMMAND_NONE) {
adts_find_frame(buffer);
decoder_buffer_fill(buffer);
diff --git a/src/decoder/FfmpegDecoderPlugin.cxx b/src/decoder/FfmpegDecoderPlugin.cxx
index 305662e6c..b9297ae2a 100644
--- a/src/decoder/FfmpegDecoderPlugin.cxx
+++ b/src/decoder/FfmpegDecoderPlugin.cxx
@@ -126,7 +126,7 @@ mpd_ffmpeg_stream_seek(void *opaque, int64_t pos, int whence)
return stream->input->size;
Error error;
- if (!input_stream_lock_seek(stream->input, pos, whence, error))
+ if (!stream->input->LockSeek(pos, whence, error))
return -1;
return stream->input->offset;
@@ -349,8 +349,7 @@ ffmpeg_probe(struct decoder *decoder, struct input_stream *is)
unsigned char *buffer = (unsigned char *)g_malloc(BUFFER_SIZE);
size_t nbytes = decoder_read(decoder, is, buffer, BUFFER_SIZE);
- if (nbytes <= PADDING ||
- !input_stream_lock_seek(is, 0, SEEK_SET, error)) {
+ if (nbytes <= PADDING || !is->LockSeek(0, SEEK_SET, error)) {
g_free(buffer);
return NULL;
}
diff --git a/src/decoder/FlacDecoderPlugin.cxx b/src/decoder/FlacDecoderPlugin.cxx
index 1693e109b..c5dd03665 100644
--- a/src/decoder/FlacDecoderPlugin.cxx
+++ b/src/decoder/FlacDecoderPlugin.cxx
@@ -331,7 +331,7 @@ oggflac_decode(struct decoder *decoder, struct input_stream *input_stream)
/* rewind the stream, because ogg_codec_detect() has
moved it */
- input_stream_lock_seek(input_stream, 0, SEEK_SET, IgnoreError());
+ input_stream->LockSeek(0, SEEK_SET, IgnoreError());
flac_decode_internal(decoder, input_stream, true);
}
diff --git a/src/decoder/FlacIOHandle.cxx b/src/decoder/FlacIOHandle.cxx
index cf877414b..77da864e5 100644
--- a/src/decoder/FlacIOHandle.cxx
+++ b/src/decoder/FlacIOHandle.cxx
@@ -37,7 +37,7 @@ FlacIORead(void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle)
Error error;
while (p < end) {
- size_t nbytes = input_stream_lock_read(is, p, end - p, error);
+ size_t nbytes = is->LockRead(p, end - p, error);
if (nbytes == 0) {
if (!error.IsDefined())
/* end of file */
@@ -67,7 +67,7 @@ FlacIOSeek(FLAC__IOHandle handle, FLAC__int64 offset, int whence)
input_stream *is = (input_stream *)handle;
Error error;
- return input_stream_lock_seek(is, offset, whence, error) ? 0 : -1;
+ return is->LockSeek(offset, whence, error) ? 0 : -1;
}
static FLAC__int64
@@ -83,7 +83,7 @@ FlacIOEof(FLAC__IOHandle handle)
{
input_stream *is = (input_stream *)handle;
- return input_stream_lock_eof(is);
+ return is->LockIsEOF();
}
static int
diff --git a/src/decoder/FlacInput.cxx b/src/decoder/FlacInput.cxx
index 46f213787..947177cde 100644
--- a/src/decoder/FlacInput.cxx
+++ b/src/decoder/FlacInput.cxx
@@ -31,7 +31,7 @@ FlacInput::Read(FLAC__byte buffer[], size_t *bytes)
*bytes = r;
if (r == 0) {
- if (input_stream_lock_eof(input_stream) ||
+ if (input_stream->LockIsEOF() ||
(decoder != nullptr &&
decoder_get_command(decoder) != DECODE_COMMAND_NONE))
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
@@ -49,9 +49,7 @@ FlacInput::Seek(FLAC__uint64 absolute_byte_offset)
return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED;
::Error error;
- if (!input_stream_lock_seek(input_stream,
- absolute_byte_offset, SEEK_SET,
- error))
+ if (!input_stream->LockSeek(absolute_byte_offset, SEEK_SET, error))
return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
@@ -83,7 +81,7 @@ FlacInput::Eof()
return (decoder != nullptr &&
decoder_get_command(decoder) != DECODE_COMMAND_NONE &&
decoder_get_command(decoder) != DECODE_COMMAND_SEEK) ||
- input_stream_lock_eof(input_stream);
+ input_stream->LockIsEOF();
}
void
diff --git a/src/decoder/MadDecoderPlugin.cxx b/src/decoder/MadDecoderPlugin.cxx
index 381a5703f..8e390d52d 100644
--- a/src/decoder/MadDecoderPlugin.cxx
+++ b/src/decoder/MadDecoderPlugin.cxx
@@ -20,6 +20,7 @@
#include "config.h"
#include "MadDecoderPlugin.hxx"
#include "DecoderAPI.hxx"
+#include "InputStream.hxx"
#include "conf.h"
#include "tag/TagId3.hxx"
#include "tag/TagRva2.hxx"
@@ -205,8 +206,7 @@ inline bool
MadDecoder::Seek(long offset)
{
Error error;
- if (!input_stream_lock_seek(input_stream, offset, SEEK_SET,
- error))
+ if (!input_stream->LockSeek(offset, SEEK_SET, error))
return false;
mad_stream_buffer(&stream, input_buffer, 0);
@@ -776,7 +776,7 @@ mp3_frame_duration(const struct mad_frame *frame)
inline goffset
MadDecoder::ThisFrameOffset() const
{
- goffset offset = input_stream_get_offset(input_stream);
+ goffset offset = input_stream->GetOffset();
if (stream.this_frame != nullptr)
offset -= stream.bufend - stream.this_frame;
@@ -789,7 +789,7 @@ MadDecoder::ThisFrameOffset() const
inline goffset
MadDecoder::RestIncludingThisFrame() const
{
- return input_stream_get_size(input_stream) - ThisFrameOffset();
+ return input_stream->GetSize() - ThisFrameOffset();
}
inline void
@@ -857,8 +857,7 @@ MadDecoder::DecodeFirstFrame(Tag **tag)
}
if (parse_lame(&lame, &ptr, &bitlen)) {
- if (gapless_playback &&
- input_stream_is_seekable(input_stream)) {
+ if (gapless_playback && input_stream->IsSeekable()) {
drop_start_samples = lame.encoder_delay +
DECODERDELAY;
drop_end_samples = lame.encoder_padding;
@@ -1059,7 +1058,7 @@ MadDecoder::Read()
if (cmd == DECODE_COMMAND_SEEK) {
unsigned long j;
- assert(input_stream_is_seekable(input_stream));
+ assert(input_stream->IsSeekable());
j = TimeToFrame(decoder_seek_where(decoder));
if (j < highest_frame) {
@@ -1139,7 +1138,7 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
}
decoder_initialized(decoder, audio_format,
- input_stream_is_seekable(input_stream),
+ input_stream->IsSeekable(),
data.total_time);
if (tag != nullptr) {
diff --git a/src/decoder/ModplugDecoderPlugin.cxx b/src/decoder/ModplugDecoderPlugin.cxx
index b95736bf8..0305b582d 100644
--- a/src/decoder/ModplugDecoderPlugin.cxx
+++ b/src/decoder/ModplugDecoderPlugin.cxx
@@ -20,6 +20,7 @@
#include "config.h"
#include "ModplugDecoderPlugin.hxx"
#include "DecoderAPI.hxx"
+#include "InputStream.hxx"
#include "TagHandler.hxx"
#include <glib.h>
@@ -37,7 +38,7 @@ static constexpr goffset MODPLUG_FILE_LIMIT = 100 * 1024 * 1024;
static GByteArray *
mod_loadfile(struct decoder *decoder, struct input_stream *is)
{
- const goffset size = input_stream_get_size(is);
+ const goffset size = is->GetSize();
if (size == 0) {
g_warning("file is empty");
@@ -63,7 +64,7 @@ mod_loadfile(struct decoder *decoder, struct input_stream *is)
size_t ret = decoder_read(decoder, is, data,
MODPLUG_READ_BLOCK);
if (ret == 0) {
- if (input_stream_lock_eof(is))
+ if (is->LockIsEOF())
/* end of file */
break;
@@ -125,7 +126,7 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
assert(audio_format.IsValid());
decoder_initialized(decoder, audio_format,
- input_stream_is_seekable(is),
+ is->IsSeekable(),
ModPlug_GetLength(f) / 1000.0);
do {
diff --git a/src/decoder/MpcdecDecoderPlugin.cxx b/src/decoder/MpcdecDecoderPlugin.cxx
index 35d5ce0df..87d868f19 100644
--- a/src/decoder/MpcdecDecoderPlugin.cxx
+++ b/src/decoder/MpcdecDecoderPlugin.cxx
@@ -20,6 +20,7 @@
#include "config.h"
#include "MpcdecDecoderPlugin.hxx"
#include "DecoderAPI.hxx"
+#include "InputStream.hxx"
#include "CheckAudioFormat.hxx"
#include "TagHandler.hxx"
#include "util/Error.hxx"
@@ -54,8 +55,7 @@ mpc_seek_cb(mpc_reader *reader, mpc_int32_t offset)
struct mpc_decoder_data *data =
(struct mpc_decoder_data *)reader->data;
- return input_stream_lock_seek(data->is, offset, SEEK_SET,
- IgnoreError());
+ return data->is->LockSeek(offset, SEEK_SET, IgnoreError());
}
static mpc_int32_t
@@ -64,7 +64,7 @@ mpc_tell_cb(mpc_reader *reader)
struct mpc_decoder_data *data =
(struct mpc_decoder_data *)reader->data;
- return (long)input_stream_get_offset(data->is);
+ return (long)data->is->GetOffset();
}
static mpc_bool_t
@@ -73,7 +73,7 @@ mpc_canseek_cb(mpc_reader *reader)
struct mpc_decoder_data *data =
(struct mpc_decoder_data *)reader->data;
- return input_stream_is_seekable(data->is);
+ return data->is->IsSeekable();
}
static mpc_int32_t
@@ -82,7 +82,7 @@ mpc_getsize_cb(mpc_reader *reader)
struct mpc_decoder_data *data =
(struct mpc_decoder_data *)reader->data;
- return input_stream_get_size(data->is);
+ return data->is->GetSize();
}
/* this _looks_ performance-critical, don't de-inline -- eric */
@@ -175,7 +175,7 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is)
decoder_replay_gain(mpd_decoder, &replay_gain_info);
decoder_initialized(mpd_decoder, audio_format,
- input_stream_is_seekable(is),
+ is->IsSeekable(),
mpc_streaminfo_get_length(&info));
enum decoder_command cmd = DECODE_COMMAND_NONE;
diff --git a/src/decoder/OpusDecoderPlugin.cxx b/src/decoder/OpusDecoderPlugin.cxx
index 18da812ab..2d378ef6c 100644
--- a/src/decoder/OpusDecoderPlugin.cxx
+++ b/src/decoder/OpusDecoderPlugin.cxx
@@ -272,7 +272,7 @@ mpd_opus_stream_decode(struct decoder *decoder,
/* rewind the stream, because ogg_codec_detect() has
moved it */
- input_stream_lock_seek(input_stream, 0, SEEK_SET, IgnoreError());
+ input_stream->LockSeek(0, SEEK_SET, IgnoreError());
MPDOpusDecoder d(decoder, input_stream);
OggSyncState oy(*input_stream, decoder);
@@ -298,13 +298,13 @@ SeekFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet,
if (is->size > 0 && is->size - is->offset < 65536)
return OggFindEOS(oy, os, packet);
- if (!input_stream_cheap_seeking(is))
+ if (!is->CheapSeeking())
return false;
oy.Reset();
Error error;
- return input_stream_lock_seek(is, -65536, SEEK_END, error) &&
+ return is->LockSeek(-65536, SEEK_END, error) &&
oy.ExpectPageSeekIn(os) &&
OggFindEOS(oy, os, packet);
}
diff --git a/src/decoder/PcmDecoderPlugin.cxx b/src/decoder/PcmDecoderPlugin.cxx
index f47b54d03..4fccca75d 100644
--- a/src/decoder/PcmDecoderPlugin.cxx
+++ b/src/decoder/PcmDecoderPlugin.cxx
@@ -20,6 +20,7 @@
#include "config.h"
#include "decoder/PcmDecoderPlugin.hxx"
#include "DecoderAPI.hxx"
+#include "InputStream.hxx"
#include "util/Error.hxx"
extern "C" {
@@ -43,7 +44,7 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
2,
};
- const char *const mime = input_stream_get_mime_type(is);
+ const char *const mime = is->GetMimeType();
const bool reverse_endian = mime != nullptr &&
strcmp(mime, "audio/x-mpd-cdda-pcm-reverse") == 0;
@@ -52,12 +53,12 @@ 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 = input_stream_get_size(is);
+ const goffset size = is->GetSize();
if (size >= 0)
total_time = size / time_to_size;
decoder_initialized(decoder, audio_format,
- input_stream_is_seekable(is), total_time);
+ is->IsSeekable(), total_time);
do {
char buffer[4096];
@@ -65,7 +66,7 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
size_t nbytes = decoder_read(decoder, is,
buffer, sizeof(buffer));
- if (nbytes == 0 && input_stream_lock_eof(is))
+ if (nbytes == 0 && is->LockIsEOF())
break;
if (reverse_endian)
@@ -83,8 +84,7 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
decoder_seek_where(decoder));
Error error;
- if (input_stream_lock_seek(is, offset, SEEK_SET,
- error)) {
+ if (is->LockSeek(offset, SEEK_SET, error)) {
decoder_command_finished(decoder);
} else {
g_warning("seeking failed: %s", error.GetMessage());
diff --git a/src/decoder/SndfileDecoderPlugin.cxx b/src/decoder/SndfileDecoderPlugin.cxx
index 0b83c142a..f61e7c2c2 100644
--- a/src/decoder/SndfileDecoderPlugin.cxx
+++ b/src/decoder/SndfileDecoderPlugin.cxx
@@ -20,6 +20,7 @@
#include "config.h"
#include "SndfileDecoderPlugin.hxx"
#include "DecoderAPI.hxx"
+#include "InputStream.hxx"
#include "CheckAudioFormat.hxx"
#include "TagHandler.hxx"
#include "util/Error.hxx"
@@ -34,7 +35,7 @@ sndfile_vio_get_filelen(void *user_data)
{
const struct input_stream *is = (const struct input_stream *)user_data;
- return input_stream_get_size(is);
+ return is->GetSize();
}
static sf_count_t
@@ -42,10 +43,10 @@ sndfile_vio_seek(sf_count_t offset, int whence, void *user_data)
{
struct input_stream *is = (struct input_stream *)user_data;
- if (!input_stream_lock_seek(is, offset, whence, IgnoreError()))
+ if (!is->LockSeek(offset, whence, IgnoreError()))
return -1;
- return input_stream_get_offset(is);
+ return is->GetOffset();
}
static sf_count_t
@@ -54,7 +55,7 @@ sndfile_vio_read(void *ptr, sf_count_t count, void *user_data)
struct input_stream *is = (struct input_stream *)user_data;
Error error;
- size_t nbytes = input_stream_lock_read(is, ptr, count, error);
+ size_t nbytes = is->LockRead(ptr, count, error);
if (nbytes == 0 && error.IsDefined()) {
g_warning("%s", error.GetMessage());
return -1;
@@ -77,7 +78,7 @@ sndfile_vio_tell(void *user_data)
{
const struct input_stream *is = (const struct input_stream *)user_data;
- return input_stream_get_offset(is);
+ return is->GetOffset();
}
/**
diff --git a/src/decoder/VorbisDecoderPlugin.cxx b/src/decoder/VorbisDecoderPlugin.cxx
index 3626fe162..d6b0f5eb0 100644
--- a/src/decoder/VorbisDecoderPlugin.cxx
+++ b/src/decoder/VorbisDecoderPlugin.cxx
@@ -84,7 +84,7 @@ static int ogg_seek_cb(void *data, ogg_int64_t offset, int whence)
Error error;
return vis->seekable &&
(!vis->decoder || decoder_get_command(vis->decoder) != DECODE_COMMAND_STOP) &&
- input_stream_lock_seek(vis->input_stream, offset, whence, error)
+ vis->input_stream->LockSeek(offset, whence, error)
? 0 : -1;
}
@@ -138,7 +138,7 @@ vorbis_is_open(struct vorbis_input_stream *vis, OggVorbis_File *vf,
{
vis->decoder = decoder;
vis->input_stream = input_stream;
- vis->seekable = input_stream_cheap_seeking(input_stream);
+ vis->seekable = input_stream->CheapSeeking();
int ret = ov_open_callbacks(vis, vf, NULL, 0, vorbis_is_callbacks);
if (ret < 0) {
@@ -189,7 +189,7 @@ vorbis_stream_decode(struct decoder *decoder,
/* rewind the stream, because ogg_codec_detect() has
moved it */
- input_stream_lock_seek(input_stream, 0, SEEK_SET, IgnoreError());
+ input_stream->LockSeek(0, SEEK_SET, IgnoreError());
struct vorbis_input_stream vis;
OggVorbis_File vf;
diff --git a/src/decoder/WavpackDecoderPlugin.cxx b/src/decoder/WavpackDecoderPlugin.cxx
index 88394f2c1..f37bd3f12 100644
--- a/src/decoder/WavpackDecoderPlugin.cxx
+++ b/src/decoder/WavpackDecoderPlugin.cxx
@@ -401,17 +401,13 @@ wavpack_input_get_pos(void *id)
static int
wavpack_input_set_pos_abs(void *id, uint32_t pos)
{
- Error error;
- return input_stream_lock_seek(wpin(id)->is, pos, SEEK_SET, error)
- ? 0 : -1;
+ return wpin(id)->is->LockSeek(pos, SEEK_SET, IgnoreError()) ? 0 : -1;
}
static int
wavpack_input_set_pos_rel(void *id, int32_t delta, int mode)
{
- Error error;
- return input_stream_lock_seek(wpin(id)->is, delta, mode, error)
- ? 0 : -1;
+ return wpin(id)->is->LockSeek(delta, mode, IgnoreError()) ? 0 : -1;
}
static int
@@ -479,8 +475,7 @@ wavpack_open_wvc(struct decoder *decoder, const char *uri,
wvc_url = g_strconcat(uri, "c", NULL);
- Error error;
- is_wvc = input_stream_open(wvc_url, mutex, cond, error);
+ is_wvc = input_stream::Open(wvc_url, mutex, cond, IgnoreError());
g_free(wvc_url);
if (is_wvc == NULL)
@@ -494,7 +489,7 @@ wavpack_open_wvc(struct decoder *decoder, const char *uri,
decoder, is_wvc, &first_byte, sizeof(first_byte)
);
if (nbytes == 0) {
- input_stream_close(is_wvc);
+ is_wvc->Close();
return NULL;
}
@@ -545,7 +540,7 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
WavpackCloseFile(wpc);
if (open_flags & OPEN_WVC) {
- input_stream_close(is_wvc);
+ is_wvc->Close();
}
}