aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/InputInternal.cxx31
-rw-r--r--src/InputInternal.hxx10
-rw-r--r--src/InputStream.hxx17
-rw-r--r--src/archive/Bzip2ArchivePlugin.cxx5
-rw-r--r--src/archive/Iso9660ArchivePlugin.cxx6
-rw-r--r--src/archive/ZzipArchivePlugin.cxx7
-rw-r--r--src/input/CdioParanoiaInputPlugin.cxx7
-rw-r--r--src/input/CurlInputPlugin.cxx6
-rw-r--r--src/input/DespotifyInputPlugin.cxx6
-rw-r--r--src/input/FfmpegInputPlugin.cxx7
-rw-r--r--src/input/FileInputPlugin.cxx7
-rw-r--r--src/input/MmsInputPlugin.cxx6
-rw-r--r--src/input/RewindInputPlugin.cxx8
-rw-r--r--src/input/SoupInputPlugin.cxx8
14 files changed, 40 insertions, 91 deletions
diff --git a/src/InputInternal.cxx b/src/InputInternal.cxx
index 52ca4cf00..a154b68da 100644
--- a/src/InputInternal.cxx
+++ b/src/InputInternal.cxx
@@ -21,37 +21,6 @@
#include "InputInternal.hxx"
#include "InputStream.hxx"
-#include <assert.h>
-
-void
-input_stream_init(struct input_stream *is, const struct input_plugin *plugin,
- const char *uri, Mutex &mutex, Cond &cond)
-{
- assert(is != NULL);
- assert(plugin != NULL);
- assert(uri != NULL);
-
- is->plugin = plugin;
- is->uri = g_strdup(uri);
- is->mutex = &mutex;
- is->cond = &cond;
- is->ready = false;
- is->seekable = false;
- is->size = -1;
- is->offset = 0;
- is->mime = NULL;
-}
-
-void
-input_stream_deinit(struct input_stream *is)
-{
- assert(is != NULL);
- assert(is->plugin != NULL);
-
- g_free(is->uri);
- g_free(is->mime);
-}
-
void
input_stream_signal_client(struct input_stream *is)
{
diff --git a/src/InputInternal.hxx b/src/InputInternal.hxx
index 9994ea745..019ac09c6 100644
--- a/src/InputInternal.hxx
+++ b/src/InputInternal.hxx
@@ -21,18 +21,8 @@
#define MPD_INPUT_INTERNAL_HXX
#include "check.h"
-#include "thread/Mutex.hxx"
-#include "thread/Cond.hxx"
struct input_stream;
-struct input_plugin;
-
-void
-input_stream_init(struct input_stream *is, const struct input_plugin *plugin,
- const char *uri, Mutex &mutex, Cond &cond);
-
-void
-input_stream_deinit(struct input_stream *is);
void
input_stream_signal_client(struct input_stream *is);
diff --git a/src/InputStream.hxx b/src/InputStream.hxx
index 2c868725e..62836af88 100644
--- a/src/InputStream.hxx
+++ b/src/InputStream.hxx
@@ -28,6 +28,8 @@
#include <glib.h>
+#include <assert.h>
+
struct input_stream {
/**
* the plugin which implements this input stream
@@ -85,6 +87,21 @@ struct input_stream {
* the MIME content type of the resource, or NULL if unknown
*/
char *mime;
+
+ input_stream(const input_plugin &_plugin,
+ const char *_uri, Mutex &_mutex, Cond &_cond)
+ :plugin(&_plugin), uri(g_strdup(_uri)),
+ mutex(&_mutex), cond(&_cond),
+ ready(false), seekable(false),
+ size(-1), offset(0),
+ mime(nullptr) {
+ assert(_uri != NULL);
+ }
+
+ ~input_stream() {
+ g_free(uri);
+ g_free(mime);
+ }
};
gcc_nonnull(1)
diff --git a/src/archive/Bzip2ArchivePlugin.cxx b/src/archive/Bzip2ArchivePlugin.cxx
index ba4d4028e..b344f1186 100644
--- a/src/archive/Bzip2ArchivePlugin.cxx
+++ b/src/archive/Bzip2ArchivePlugin.cxx
@@ -184,16 +184,15 @@ bz2_close(struct archive_file *file)
Bzip2InputStream::Bzip2InputStream(Bzip2ArchiveFile &_context, const char *uri,
Mutex &mutex, Cond &cond)
- :archive(&_context), eof(false)
+ :base(bz2_inputplugin, uri, mutex, cond),
+ archive(&_context), eof(false)
{
- input_stream_init(&base, &bz2_inputplugin, uri, mutex, cond);
refcount_inc(&archive->ref);
}
Bzip2InputStream::~Bzip2InputStream()
{
bz2_close(&archive->base);
- input_stream_deinit(&base);
}
static struct input_stream *
diff --git a/src/archive/Iso9660ArchivePlugin.cxx b/src/archive/Iso9660ArchivePlugin.cxx
index b2802756f..f92895b7d 100644
--- a/src/archive/Iso9660ArchivePlugin.cxx
+++ b/src/archive/Iso9660ArchivePlugin.cxx
@@ -178,10 +178,9 @@ struct Iso9660InputStream {
Iso9660InputStream(Iso9660ArchiveFile &_archive, const char *uri,
Mutex &mutex, Cond &cond,
iso9660_stat_t *_statbuf)
- :archive(&_archive), statbuf(_statbuf),
+ :base(iso9660_input_plugin, uri, mutex, cond),
+ archive(&_archive), statbuf(_statbuf),
max_blocks(CEILING(statbuf->size, ISO_BLOCKSIZE)) {
- input_stream_init(&base, &iso9660_input_plugin, uri,
- mutex, cond);
base.ready = true;
base.size = statbuf->size;
@@ -192,7 +191,6 @@ struct Iso9660InputStream {
~Iso9660InputStream() {
free(statbuf);
archive->Unref();
- input_stream_deinit(&base);
}
};
diff --git a/src/archive/ZzipArchivePlugin.cxx b/src/archive/ZzipArchivePlugin.cxx
index 8c4b77987..dabdd41d9 100644
--- a/src/archive/ZzipArchivePlugin.cxx
+++ b/src/archive/ZzipArchivePlugin.cxx
@@ -142,10 +142,8 @@ struct ZzipInputStream {
ZzipInputStream(ZzipArchiveFile &_archive, const char *uri,
Mutex &mutex, Cond &cond,
ZZIP_FILE *_file)
- :archive(&_archive), file(_file) {
- input_stream_init(&base, &zzip_input_plugin, uri,
- mutex, cond);
-
+ :base(zzip_input_plugin, uri, mutex, cond),
+ archive(&_archive), file(_file) {
base.ready = true;
//we are seekable (but its not recommendent to do so)
base.seekable = true;
@@ -160,7 +158,6 @@ struct ZzipInputStream {
~ZzipInputStream() {
zzip_file_close(file);
archive->Unref();
- input_stream_deinit(&base);
}
};
diff --git a/src/input/CdioParanoiaInputPlugin.cxx b/src/input/CdioParanoiaInputPlugin.cxx
index 129eb75b7..942eefb99 100644
--- a/src/input/CdioParanoiaInputPlugin.cxx
+++ b/src/input/CdioParanoiaInputPlugin.cxx
@@ -56,11 +56,10 @@ struct CdioParanoiaInputStream {
CdioParanoiaInputStream(const char *uri, Mutex &mutex, Cond &cond,
int _trackno)
- :drv(nullptr), cdio(nullptr), para(nullptr),
+ :base(input_plugin_cdio_paranoia, uri, mutex, cond),
+ drv(nullptr), cdio(nullptr), para(nullptr),
trackno(_trackno)
{
- input_stream_init(&base, &input_plugin_cdio_paranoia, uri,
- mutex, cond);
}
~CdioParanoiaInputStream() {
@@ -70,8 +69,6 @@ struct CdioParanoiaInputStream {
cdio_cddap_close_no_free_cdio(drv);
if (cdio != nullptr)
cdio_destroy(cdio);
-
- input_stream_deinit(&base);
}
};
diff --git a/src/input/CurlInputPlugin.cxx b/src/input/CurlInputPlugin.cxx
index 8ed25f9a4..0fbfa29d2 100644
--- a/src/input/CurlInputPlugin.cxx
+++ b/src/input/CurlInputPlugin.cxx
@@ -166,12 +166,12 @@ struct input_curl {
GError *postponed_error;
input_curl(const char *url, Mutex &mutex, Cond &cond)
- :range(nullptr), request_headers(nullptr),
+ :base(input_plugin_curl, url, mutex, cond),
+ range(nullptr), request_headers(nullptr),
paused(false),
meta_name(nullptr),
tag(nullptr),
postponed_error(nullptr) {
- input_stream_init(&base, &input_plugin_curl, url, mutex, cond);
}
~input_curl();
@@ -705,8 +705,6 @@ input_curl::~input_curl()
if (postponed_error != NULL)
g_error_free(postponed_error);
-
- input_stream_deinit(&base);
}
static bool
diff --git a/src/input/DespotifyInputPlugin.cxx b/src/input/DespotifyInputPlugin.cxx
index 669ebd036..1e5a8c606 100644
--- a/src/input/DespotifyInputPlugin.cxx
+++ b/src/input/DespotifyInputPlugin.cxx
@@ -51,11 +51,10 @@ struct DespotifyInputStream {
Mutex &mutex, Cond &cond,
despotify_session *_session,
ds_track *_track)
- :session(_session), track(_track),
+ :base(input_plugin_despotify, uri, mutex, cond),
+ session(_session), track(_track),
tag(mpd_despotify_tag_from_track(track)),
len_available(0), eof(false) {
- input_stream_init(&base, &input_plugin_despotify, uri,
- mutex, cond);
memset(&pcm, 0, sizeof(pcm));
@@ -69,7 +68,6 @@ struct DespotifyInputStream {
tag_free(tag);
despotify_free_track(track);
- input_stream_deinit(&base);
}
};
diff --git a/src/input/FfmpegInputPlugin.cxx b/src/input/FfmpegInputPlugin.cxx
index 2e44f74b7..1660f177d 100644
--- a/src/input/FfmpegInputPlugin.cxx
+++ b/src/input/FfmpegInputPlugin.cxx
@@ -44,10 +44,8 @@ struct FfmpegInputStream {
FfmpegInputStream(const char *uri, Mutex &mutex, Cond &cond,
AVIOContext *_h)
- :h(_h), eof(false) {
- input_stream_init(&base, &input_plugin_ffmpeg,
- uri, mutex, cond);
-
+ :base(input_plugin_ffmpeg, uri, mutex, cond),
+ h(_h), eof(false) {
base.ready = true;
base.seekable = (h->seekable & AVIO_SEEKABLE_NORMAL) != 0;
base.size = avio_size(h);
@@ -61,7 +59,6 @@ struct FfmpegInputStream {
~FfmpegInputStream() {
avio_close(h);
- input_stream_deinit(&base);
}
};
diff --git a/src/input/FileInputPlugin.cxx b/src/input/FileInputPlugin.cxx
index 7681ee0c9..2eecf32b6 100644
--- a/src/input/FileInputPlugin.cxx
+++ b/src/input/FileInputPlugin.cxx
@@ -42,10 +42,8 @@ struct FileInputStream {
FileInputStream(const char *path, int _fd, off_t size,
Mutex &mutex, Cond &cond)
- :fd(_fd) {
- input_stream_init(&base, &input_plugin_file, path,
- mutex, cond);
-
+ :base(input_plugin_file, path, mutex, cond),
+ fd(_fd) {
base.size = size;
base.seekable = true;
base.ready = true;
@@ -53,7 +51,6 @@ struct FileInputStream {
~FileInputStream() {
close(fd);
- input_stream_deinit(&base);
}
};
diff --git a/src/input/MmsInputPlugin.cxx b/src/input/MmsInputPlugin.cxx
index be583e283..b347eb92b 100644
--- a/src/input/MmsInputPlugin.cxx
+++ b/src/input/MmsInputPlugin.cxx
@@ -42,9 +42,8 @@ struct MmsInputStream {
MmsInputStream(const char *uri,
Mutex &mutex, Cond &cond,
mmsx_t *_mms)
- :mms(_mms), eof(false) {
- input_stream_init(&base, &input_plugin_mms, uri, mutex, cond);
-
+ :base(input_plugin_mms, uri, mutex, cond),
+ mms(_mms), eof(false) {
/* XX is this correct? at least this selects the ffmpeg
decoder, which seems to work fine*/
base.mime = g_strdup("audio/x-ms-wma");
@@ -54,7 +53,6 @@ struct MmsInputStream {
~MmsInputStream() {
mmsx_close(mms);
- input_stream_deinit(&base);
}
};
diff --git a/src/input/RewindInputPlugin.cxx b/src/input/RewindInputPlugin.cxx
index bc428e7ac..6c0093a38 100644
--- a/src/input/RewindInputPlugin.cxx
+++ b/src/input/RewindInputPlugin.cxx
@@ -61,15 +61,13 @@ struct RewindInputStream {
char buffer[64 * 1024];
RewindInputStream(input_stream *_input)
- :input(_input), tail(0) {
- input_stream_init(&base, &rewind_input_plugin, input->uri,
- *input->mutex, *input->cond);
+ :base(rewind_input_plugin, _input->uri,
+ *_input->mutex, *_input->cond),
+ input(_input), tail(0) {
}
~RewindInputStream() {
input_stream_close(input);
-
- input_stream_deinit(&base);
}
/**
diff --git a/src/input/SoupInputPlugin.cxx b/src/input/SoupInputPlugin.cxx
index b781cd447..6615a3c7f 100644
--- a/src/input/SoupInputPlugin.cxx
+++ b/src/input/SoupInputPlugin.cxx
@@ -278,14 +278,12 @@ input_soup_queue(gpointer data)
SoupInputStream::SoupInputStream(const char *uri,
Mutex &mutex, Cond &cond)
- :buffers(g_queue_new()),
+ :base(input_plugin_soup, uri, mutex, cond),
+ buffers(g_queue_new()),
current_consumed(0), total_buffered(0),
alive(false), pause(false), eof(false), completed(false),
postponed_error(nullptr)
{
- input_stream_init(&base, &input_plugin_soup, uri,
- mutex, cond);
-
#if GCC_CHECK_VERSION(4,6)
#pragma GCC diagnostic push
/* the libsoup macro SOUP_METHOD_GET discards the "const"
@@ -365,8 +363,6 @@ SoupInputStream::~SoupInputStream()
if (postponed_error != NULL)
g_error_free(postponed_error);
-
- input_stream_deinit(&base);
}
static void