aboutsummaryrefslogtreecommitdiff
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-24 19:14:40 +0100
committerMax Kellermann <max@duempel.org>2013-01-26 01:24:01 +0100
commit0273cd44b0b50d5d320ce88cc1472e0d8ee8e529 (patch)
tree7c493850ab07deddd637ca0b5e8b3476e40a68fc /src/decoder
parent3203a7dd8ce8db6afcc54d68d63b4f4af7dc4c7f (diff)
input_stream: forward-declare the struct
Hide the definition from C code, to prepare the transition to C++.
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/FLACIOHandle.hxx2
-rw-r--r--src/decoder/FLACInput.cxx2
-rw-r--r--src/decoder/FfmpegDecoderPlugin.cxx1
-rw-r--r--src/decoder/OpusDecoderPlugin.cxx1
-rw-r--r--src/decoder/VorbisDecoderPlugin.cxx1
-rw-r--r--src/decoder/WavpackDecoderPlugin.cxx1
-rw-r--r--src/decoder/audiofile_decoder_plugin.c10
-rw-r--r--src/decoder/dsdiff_decoder_plugin.c25
-rw-r--r--src/decoder/dsdlib.c20
-rw-r--r--src/decoder/dsf_decoder_plugin.c5
-rw-r--r--src/decoder/faad_decoder_plugin.c5
-rw-r--r--src/decoder/mad_decoder_plugin.c12
-rw-r--r--src/decoder/modplug_decoder_plugin.c13
-rw-r--r--src/decoder/mpcdec_decoder_plugin.c8
-rw-r--r--src/decoder/pcm_decoder_plugin.c13
-rw-r--r--src/decoder/sndfile_decoder_plugin.c6
16 files changed, 71 insertions, 54 deletions
diff --git a/src/decoder/FLACIOHandle.hxx b/src/decoder/FLACIOHandle.hxx
index 0c2c2477..505d2db1 100644
--- a/src/decoder/FLACIOHandle.hxx
+++ b/src/decoder/FLACIOHandle.hxx
@@ -21,7 +21,7 @@
#define MPD_FLAC_IO_HANDLE_HXX
#include "gcc.h"
-#include "input_stream.h"
+#include "InputStream.hxx"
#include <FLAC/callback.h>
diff --git a/src/decoder/FLACInput.cxx b/src/decoder/FLACInput.cxx
index 99f321cd..ba0a86ce 100644
--- a/src/decoder/FLACInput.cxx
+++ b/src/decoder/FLACInput.cxx
@@ -21,7 +21,7 @@
#include "FLACInput.hxx"
#include "decoder_api.h"
#include "gcc.h"
-#include "input_stream.h"
+#include "InputStream.hxx"
FLAC__StreamDecoderReadStatus
FLACInput::Read(FLAC__byte buffer[], size_t *bytes)
diff --git a/src/decoder/FfmpegDecoderPlugin.cxx b/src/decoder/FfmpegDecoderPlugin.cxx
index ac288330..e89f35ef 100644
--- a/src/decoder/FfmpegDecoderPlugin.cxx
+++ b/src/decoder/FfmpegDecoderPlugin.cxx
@@ -25,6 +25,7 @@
#include "decoder_api.h"
#include "FfmpegMetaData.hxx"
#include "tag_handler.h"
+#include "InputStream.hxx"
extern "C" {
#include "audio_check.h"
diff --git a/src/decoder/OpusDecoderPlugin.cxx b/src/decoder/OpusDecoderPlugin.cxx
index f0c0a442..8be95ab2 100644
--- a/src/decoder/OpusDecoderPlugin.cxx
+++ b/src/decoder/OpusDecoderPlugin.cxx
@@ -28,6 +28,7 @@
#include "OggCodec.hxx"
#include "audio_check.h"
#include "tag_handler.h"
+#include "InputStream.hxx"
#include <opus.h>
#include <ogg/ogg.h>
diff --git a/src/decoder/VorbisDecoderPlugin.cxx b/src/decoder/VorbisDecoderPlugin.cxx
index 01a558de..488786ed 100644
--- a/src/decoder/VorbisDecoderPlugin.cxx
+++ b/src/decoder/VorbisDecoderPlugin.cxx
@@ -21,6 +21,7 @@
#include "VorbisDecoderPlugin.h"
#include "VorbisComments.hxx"
#include "decoder_api.h"
+#include "InputStream.hxx"
#include "OggCodec.hxx"
extern "C" {
diff --git a/src/decoder/WavpackDecoderPlugin.cxx b/src/decoder/WavpackDecoderPlugin.cxx
index fdd910c8..aeecf641 100644
--- a/src/decoder/WavpackDecoderPlugin.cxx
+++ b/src/decoder/WavpackDecoderPlugin.cxx
@@ -20,6 +20,7 @@
#include "config.h"
#include "WavpackDecoderPlugin.hxx"
#include "decoder_api.h"
+#include "InputStream.hxx"
extern "C" {
#include "audio_check.h"
diff --git a/src/decoder/audiofile_decoder_plugin.c b/src/decoder/audiofile_decoder_plugin.c
index b344795e..d2ceee8a 100644
--- a/src/decoder/audiofile_decoder_plugin.c
+++ b/src/decoder/audiofile_decoder_plugin.c
@@ -69,14 +69,14 @@ static AFfileoffset
audiofile_file_length(AFvirtualfile *vfile)
{
struct input_stream *is = (struct input_stream *) vfile->closure;
- return is->size;
+ return input_stream_get_size(is);
}
static AFfileoffset
audiofile_file_tell(AFvirtualfile *vfile)
{
struct input_stream *is = (struct input_stream *) vfile->closure;
- return is->offset;
+ return input_stream_get_offset(is);
}
static void
@@ -93,7 +93,7 @@ audiofile_file_seek(AFvirtualfile *vfile, AFfileoffset offset, int is_relative)
struct input_stream *is = (struct input_stream *) vfile->closure;
int whence = (is_relative ? SEEK_CUR : SEEK_SET);
if (input_stream_lock_seek(is, offset, whence, NULL)) {
- return is->offset;
+ return input_stream_get_offset(is);
} else {
return -1;
}
@@ -166,7 +166,7 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
char chunk[CHUNK_SIZE];
enum decoder_command cmd;
- if (!is->seekable) {
+ if (!input_stream_is_seekable(is)) {
g_warning("not seekable");
return;
}
@@ -194,7 +194,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)(is->size * 8.0 / total_time / 1000.0 + 0.5);
+ bit_rate = (uint16_t)(input_stream_get_size(is) * 8.0 / total_time / 1000.0 + 0.5);
fs = (int)afGetVirtualFrameSize(af_fp, AF_DEFAULT_TRACK, 1);
diff --git a/src/decoder/dsdiff_decoder_plugin.c b/src/decoder/dsdiff_decoder_plugin.c
index 4e21e91d..44d12d89 100644
--- a/src/decoder/dsdiff_decoder_plugin.c
+++ b/src/decoder/dsdiff_decoder_plugin.c
@@ -128,12 +128,12 @@ dsdiff_read_prop_snd(struct decoder *decoder, struct input_stream *is,
goffset end_offset)
{
struct dsdiff_chunk_header header;
- while ((goffset)(is->offset + sizeof(header)) <= end_offset) {
+ while ((goffset)(input_stream_get_offset(is) + sizeof(header)) <= end_offset) {
if (!dsdiff_read_chunk_header(decoder, is, &header))
return false;
- goffset chunk_end_offset =
- is->offset + dsdiff_chunk_size(&header);
+ goffset chunk_end_offset = input_stream_get_offset(is)
+ + dsdiff_chunk_size(&header);
if (chunk_end_offset > end_offset)
return false;
@@ -174,7 +174,7 @@ dsdiff_read_prop_snd(struct decoder *decoder, struct input_stream *is,
}
}
- return is->offset == end_offset;
+ return input_stream_get_offset(is) == end_offset;
}
/**
@@ -186,7 +186,7 @@ dsdiff_read_prop(struct decoder *decoder, struct input_stream *is,
const struct dsdiff_chunk_header *prop_header)
{
uint64_t prop_size = dsdiff_chunk_size(prop_header);
- goffset end_offset = is->offset + prop_size;
+ goffset end_offset = input_stream_get_offset(is) + prop_size;
struct dsdlib_id prop_id;
if (prop_size < sizeof(prop_id) ||
@@ -261,8 +261,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 */
- while ( is->offset < is->size )
- {
+ const goffset size = input_stream_get_size(is);
+ while (input_stream_get_offset(is) < size) {
uint64_t chunk_size = dsdiff_chunk_size(chunk_header);
/* DIIN chunk, is directly followed by other chunks */
@@ -272,19 +272,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 = dsdiff_chunk_size(chunk_header);
- metadata->diar_offset = is->offset;
+ metadata->diar_offset = input_stream_get_offset(is);
}
/* DITI chunk - DSDIFF native tag for Title */
if (dsdlib_id_equals(&chunk_header->id, "DITI")) {
chunk_size = dsdiff_chunk_size(chunk_header);
- metadata->diti_offset = is->offset;
+ metadata->diti_offset = input_stream_get_offset(is);
}
#ifdef HAVE_ID3TAG
/* 'ID3 ' chunk, offspec. Used by sacdextract */
if (dsdlib_id_equals(&chunk_header->id, "ID3 ")) {
chunk_size = dsdiff_chunk_size(chunk_header);
- metadata->id3_offset = is->offset;
+ metadata->id3_offset = input_stream_get_offset(is);
metadata->id3_size = chunk_size;
}
#endif
@@ -293,7 +293,7 @@ dsdiff_read_metadata_extra(struct decoder *decoder, struct input_stream *is,
break;
}
- if ( is->offset < is->size ) {
+ if (input_stream_get_offset(is) < size) {
if (!dsdiff_read_chunk_header(decoder, is, chunk_header))
return false;
}
@@ -355,7 +355,8 @@ dsdiff_read_metadata(struct decoder *decoder, struct input_stream *is,
/* ignore unknown chunk */
uint64_t chunk_size;
chunk_size = dsdiff_chunk_size(chunk_header);
- goffset chunk_end_offset = is->offset + chunk_size;
+ goffset chunk_end_offset = input_stream_get_offset(is)
+ + chunk_size;
if (!dsdlib_skip_to(decoder, is, chunk_end_offset))
return false;
diff --git a/src/decoder/dsdlib.c b/src/decoder/dsdlib.c
index c788184e..d3043fb0 100644
--- a/src/decoder/dsdlib.c
+++ b/src/decoder/dsdlib.c
@@ -64,24 +64,24 @@ bool
dsdlib_skip_to(struct decoder *decoder, struct input_stream *is,
goffset offset)
{
- if (is->seekable)
+ if (input_stream_is_seekable(is))
return input_stream_seek(is, offset, SEEK_SET, NULL);
- if (is->offset > offset)
+ if (input_stream_get_offset(is) > offset)
return false;
char buffer[8192];
- while (is->offset < offset) {
+ while (input_stream_get_offset(is) < offset) {
size_t length = sizeof(buffer);
- if (offset - is->offset < (goffset)length)
- length = offset - is->offset;
+ if (offset - input_stream_get_offset(is) < (goffset)length)
+ length = offset - input_stream_get_offset(is);
size_t nbytes = decoder_read(decoder, is, buffer, length);
if (nbytes == 0)
return false;
}
- assert(is->offset == offset);
+ assert(input_stream_get_offset(is) == offset);
return true;
}
@@ -97,7 +97,7 @@ dsdlib_skip(struct decoder *decoder, struct input_stream *is,
if (delta == 0)
return true;
- if (is->seekable)
+ if (input_stream_is_seekable(is))
return input_stream_seek(is, delta, SEEK_CUR, NULL);
char buffer[8192];
@@ -139,10 +139,12 @@ dsdlib_tag_id3(struct input_stream *is,
id3_length_t count;
/* Prevent broken files causing problems */
- if (is->offset >= is->size)
+ const goffset size = input_stream_get_size(is);
+ const goffset offset = input_stream_get_offset(is);
+ if (offset >= size)
return;
- count = is->size - is->offset;
+ count = size - offset;
/* Check and limit id3 tag size to prevent a stack overflow */
if (count == 0 || count > 4096)
diff --git a/src/decoder/dsf_decoder_plugin.c b/src/decoder/dsf_decoder_plugin.c
index 6700f739..23576a62 100644
--- a/src/decoder/dsf_decoder_plugin.c
+++ b/src/decoder/dsf_decoder_plugin.c
@@ -165,14 +165,15 @@ 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 */
- if (data_size >= (unsigned) is->size)
+ const uint64_t size = (uint64_t)input_stream_get_size(is);
+ if (data_size >= size)
return false;
metadata->channels = (unsigned) dsf_fmt_chunk.channelnum;
metadata->sample_rate = samplefreq;
#ifdef HAVE_ID3TAG
/* metada_offset cannot be bigger then or equal to total file size */
- if (metadata_offset >= (unsigned) is->size)
+ if (metadata_offset >= size)
metadata->id3_offset = 0;
else
metadata->id3_offset = (goffset) metadata_offset;
diff --git a/src/decoder/faad_decoder_plugin.c b/src/decoder/faad_decoder_plugin.c
index 911f033b..c8dbb966 100644
--- a/src/decoder/faad_decoder_plugin.c
+++ b/src/decoder/faad_decoder_plugin.c
@@ -175,7 +175,8 @@ faad_song_duration(struct decoder_buffer *buffer, struct input_stream *is)
size_t length;
bool success;
- fileread = is->size >= 0 ? is->size : 0;
+ const goffset size = input_stream_get_size(is);
+ fileread = size >= 0 ? size : 0;
decoder_buffer_fill(buffer);
data = decoder_buffer_read(buffer, &length);
@@ -201,7 +202,7 @@ faad_song_duration(struct decoder_buffer *buffer, struct input_stream *is)
return -1;
}
- if (is->seekable && length >= 2 &&
+ if (input_stream_is_seekable(is) && length >= 2 &&
data[0] == 0xFF && ((data[1] & 0xF6) == 0xF0)) {
/* obtain the duration from the ADTS header */
float song_length = adts_song_duration(buffer);
diff --git a/src/decoder/mad_decoder_plugin.c b/src/decoder/mad_decoder_plugin.c
index 0c27ac11..4e2e0331 100644
--- a/src/decoder/mad_decoder_plugin.c
+++ b/src/decoder/mad_decoder_plugin.c
@@ -755,7 +755,7 @@ mp3_frame_duration(const struct mad_frame *frame)
static goffset
mp3_this_frame_offset(const struct mp3_data *data)
{
- goffset offset = data->input_stream->offset;
+ goffset offset = input_stream_get_offset(data->input_stream);
if (data->stream.this_frame != NULL)
offset -= data->stream.bufend - data->stream.this_frame;
@@ -768,7 +768,8 @@ mp3_this_frame_offset(const struct mp3_data *data)
static goffset
mp3_rest_including_this_frame(const struct mp3_data *data)
{
- return data->input_stream->size - mp3_this_frame_offset(data);
+ return input_stream_get_size(data->input_stream)
+ - mp3_this_frame_offset(data);
}
/**
@@ -841,7 +842,7 @@ mp3_decode_first_frame(struct mp3_data *data, struct tag **tag)
if (parse_lame(&lame, &ptr, &bitlen)) {
if (gapless_playback &&
- data->input_stream->seekable) {
+ input_stream_is_seekable(data->input_stream)) {
data->drop_start_samples = lame.encoder_delay +
DECODERDELAY;
data->drop_end_samples = lame.encoder_padding;
@@ -1081,7 +1082,7 @@ mp3_read(struct mp3_data *data)
if (cmd == DECODE_COMMAND_SEEK) {
unsigned long j;
- assert(data->input_stream->seekable);
+ assert(input_stream_is_seekable(data->input_stream));
j = mp3_time_to_frame(data,
decoder_seek_where(decoder));
@@ -1163,7 +1164,8 @@ mp3_decode(struct decoder *decoder, struct input_stream *input_stream)
}
decoder_initialized(decoder, &audio_format,
- data.input_stream->seekable, data.total_time);
+ input_stream_is_seekable(input_stream),
+ data.total_time);
if (tag != NULL) {
decoder_tag(decoder, input_stream, tag);
diff --git a/src/decoder/modplug_decoder_plugin.c b/src/decoder/modplug_decoder_plugin.c
index 21ee79e7..bc3d8176 100644
--- a/src/decoder/modplug_decoder_plugin.c
+++ b/src/decoder/modplug_decoder_plugin.c
@@ -41,19 +41,21 @@ static GByteArray *mod_loadfile(struct decoder *decoder, struct input_stream *is
GByteArray *bdatas;
size_t ret;
- if (is->size == 0) {
+ const goffset size = input_stream_get_size(is);
+
+ if (size == 0) {
g_warning("file is empty");
return NULL;
}
- if (is->size > MODPLUG_FILE_LIMIT) {
+ if (size > MODPLUG_FILE_LIMIT) {
g_warning("file too large");
return NULL;
}
//known/unknown size, preallocate array, lets read in chunks
- if (is->size > 0) {
- bdatas = g_byte_array_sized_new(is->size);
+ if (size > 0) {
+ bdatas = g_byte_array_sized_new(size);
} else {
bdatas = g_byte_array_sized_new(MODPLUG_PREALLOC_BLOCK);
}
@@ -126,7 +128,8 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
assert(audio_format_valid(&audio_format));
decoder_initialized(decoder, &audio_format,
- is->seekable, ModPlug_GetLength(f) / 1000.0);
+ input_stream_is_seekable(is),
+ ModPlug_GetLength(f) / 1000.0);
do {
ret = ModPlug_Read(f, audio_buffer, MODPLUG_FRAME_SIZE);
diff --git a/src/decoder/mpcdec_decoder_plugin.c b/src/decoder/mpcdec_decoder_plugin.c
index d4768b35..77db2416 100644
--- a/src/decoder/mpcdec_decoder_plugin.c
+++ b/src/decoder/mpcdec_decoder_plugin.c
@@ -70,7 +70,7 @@ mpc_tell_cb(cb_first_arg)
{
struct mpc_decoder_data *data = (struct mpc_decoder_data *) cb_data;
- return (long)(data->is->offset);
+ return (long)input_stream_get_offset(data->is);
}
static mpc_bool_t
@@ -78,7 +78,7 @@ mpc_canseek_cb(cb_first_arg)
{
struct mpc_decoder_data *data = (struct mpc_decoder_data *) cb_data;
- return data->is->seekable;
+ return input_stream_is_seekable(data->is);
}
static mpc_int32_t
@@ -86,7 +86,7 @@ mpc_getsize_cb(cb_first_arg)
{
struct mpc_decoder_data *data = (struct mpc_decoder_data *) cb_data;
- return data->is->size;
+ return input_stream_get_size(data->is);
}
/* this _looks_ performance-critical, don't de-inline -- eric */
@@ -222,7 +222,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,
- is->seekable,
+ input_stream_is_seekable(is),
mpc_streaminfo_get_length(&info));
do {
diff --git a/src/decoder/pcm_decoder_plugin.c b/src/decoder/pcm_decoder_plugin.c
index fc7dffc0..d529cef5 100644
--- a/src/decoder/pcm_decoder_plugin.c
+++ b/src/decoder/pcm_decoder_plugin.c
@@ -38,8 +38,9 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
.channels = 2,
};
- const bool reverse_endian = is->mime != NULL &&
- strcmp(is->mime, "audio/x-mpd-cdda-pcm-reverse") == 0;
+ const char *const mime = input_stream_get_mime_type(is);
+ const bool reverse_endian = mime != NULL &&
+ strcmp(mime, "audio/x-mpd-cdda-pcm-reverse") == 0;
GError *error = NULL;
enum decoder_command cmd;
@@ -47,10 +48,12 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
double time_to_size = audio_format_time_to_size(&audio_format);
float total_time = -1;
- if (is->size >= 0)
- total_time = is->size / time_to_size;
+ const goffset size = input_stream_get_size(is);
+ if (size >= 0)
+ total_time = size / time_to_size;
- decoder_initialized(decoder, &audio_format, is->seekable, total_time);
+ decoder_initialized(decoder, &audio_format,
+ input_stream_is_seekable(is), total_time);
do {
char buffer[4096];
diff --git a/src/decoder/sndfile_decoder_plugin.c b/src/decoder/sndfile_decoder_plugin.c
index 8dd98236..e70a2dc2 100644
--- a/src/decoder/sndfile_decoder_plugin.c
+++ b/src/decoder/sndfile_decoder_plugin.c
@@ -32,7 +32,7 @@ sndfile_vio_get_filelen(void *user_data)
{
const struct input_stream *is = user_data;
- return is->size;
+ return input_stream_get_size(is);
}
static sf_count_t
@@ -45,7 +45,7 @@ sndfile_vio_seek(sf_count_t offset, int whence, void *user_data)
if (!success)
return -1;
- return is->offset;
+ return input_stream_get_offset(is);
}
static sf_count_t
@@ -79,7 +79,7 @@ sndfile_vio_tell(void *user_data)
{
const struct input_stream *is = user_data;
- return is->offset;
+ return input_stream_get_offset(is);
}
/**