InputLegacy: move functions to the input_stream class
This commit is contained in:
parent
52ffdb0a55
commit
7d0269d2ce
|
@ -716,7 +716,6 @@ libinput_a_SOURCES = \
|
|||
src/InputInit.cxx src/InputInit.hxx \
|
||||
src/InputRegistry.cxx src/InputRegistry.hxx \
|
||||
src/InputStream.cxx src/InputStream.hxx \
|
||||
src/InputLegacy.hxx \
|
||||
src/InputPlugin.hxx \
|
||||
src/InputInternal.cxx src/InputInternal.hxx \
|
||||
src/input/RewindInputPlugin.cxx src/input/RewindInputPlugin.hxx \
|
||||
|
|
|
@ -268,29 +268,29 @@ size_t decoder_read(struct decoder *decoder,
|
|||
if (length == 0)
|
||||
return 0;
|
||||
|
||||
input_stream_lock(is);
|
||||
is->Lock();
|
||||
|
||||
while (true) {
|
||||
if (decoder_check_cancel_read(decoder)) {
|
||||
input_stream_unlock(is);
|
||||
is->Unlock();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (input_stream_available(is))
|
||||
if (is->IsAvailable())
|
||||
break;
|
||||
|
||||
is->cond.wait(is->mutex);
|
||||
}
|
||||
|
||||
Error error;
|
||||
size_t nbytes = input_stream_read(is, buffer, length, error);
|
||||
size_t nbytes = is->Read(buffer, length, error);
|
||||
assert(nbytes == 0 || !error.IsDefined());
|
||||
assert(nbytes > 0 || error.IsDefined() || input_stream_eof(is));
|
||||
assert(nbytes > 0 || error.IsDefined() || is->IsEOF());
|
||||
|
||||
if (gcc_unlikely(nbytes == 0 && error.IsDefined()))
|
||||
g_warning("%s", error.GetMessage());
|
||||
|
||||
input_stream_unlock(is);
|
||||
is->Unlock();
|
||||
|
||||
return nbytes;
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ update_stream_tag(struct decoder *decoder, struct input_stream *is)
|
|||
Tag *tag;
|
||||
|
||||
tag = is != NULL
|
||||
? input_stream_lock_tag(is)
|
||||
? is->LockReadTag()
|
||||
: NULL;
|
||||
if (tag == NULL) {
|
||||
tag = decoder->song_tag;
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "check.h"
|
||||
#include "DecoderCommand.hxx"
|
||||
#include "DecoderPlugin.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "replay_gain_info.h"
|
||||
#include "Tag.hxx"
|
||||
#include "AudioFormat.hxx"
|
||||
|
|
|
@ -60,7 +60,7 @@ decoder_command_finished_locked(struct decoder_control *dc)
|
|||
}
|
||||
|
||||
/**
|
||||
* Opens the input stream with input_stream_open(), and waits until
|
||||
* Opens the input stream with input_stream::Open(), and waits until
|
||||
* the stream gets ready. If a decoder STOP command is received
|
||||
* during that, it cancels the operation (but does not close the
|
||||
* stream).
|
||||
|
@ -75,7 +75,7 @@ decoder_input_stream_open(struct decoder_control *dc, const char *uri)
|
|||
{
|
||||
Error error;
|
||||
|
||||
input_stream *is = input_stream_open(uri, dc->mutex, dc->cond, error);
|
||||
input_stream *is = input_stream::Open(uri, dc->mutex, dc->cond, error);
|
||||
if (is == NULL) {
|
||||
if (error.IsDefined())
|
||||
g_warning("%s", error.GetMessage());
|
||||
|
@ -88,15 +88,15 @@ decoder_input_stream_open(struct decoder_control *dc, const char *uri)
|
|||
|
||||
dc->Lock();
|
||||
|
||||
input_stream_update(is);
|
||||
is->Update();
|
||||
while (!is->ready &&
|
||||
dc->command != DECODE_COMMAND_STOP) {
|
||||
dc->Wait();
|
||||
|
||||
input_stream_update(is);
|
||||
is->Update();
|
||||
}
|
||||
|
||||
if (!input_stream_check(is, error)) {
|
||||
if (!is->Check(error)) {
|
||||
dc->Unlock();
|
||||
|
||||
g_warning("%s", error.GetMessage());
|
||||
|
@ -128,10 +128,7 @@ decoder_stream_decode(const struct decoder_plugin *plugin,
|
|||
return true;
|
||||
|
||||
/* rewind the stream, so each plugin gets a fresh start */
|
||||
{
|
||||
Error error;
|
||||
input_stream_seek(input_stream, 0, SEEK_SET, error);
|
||||
}
|
||||
input_stream->Seek(0, SEEK_SET, IgnoreError());
|
||||
|
||||
decoder->dc->Unlock();
|
||||
|
||||
|
@ -303,7 +300,7 @@ decoder_run_stream(struct decoder *decoder, const char *uri)
|
|||
g_slist_free(tried);
|
||||
|
||||
dc->Unlock();
|
||||
input_stream_close(input_stream);
|
||||
input_stream->Close();
|
||||
dc->Lock();
|
||||
|
||||
return success;
|
||||
|
@ -361,7 +358,7 @@ decoder_run_file(struct decoder *decoder, const char *path_fs)
|
|||
|
||||
dc->Unlock();
|
||||
|
||||
input_stream_close(input_stream);
|
||||
input_stream->Close();
|
||||
|
||||
if (success) {
|
||||
dc->Lock();
|
||||
|
|
|
@ -1,225 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2003-2013 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef MPD_INPUT_LEGACY_HXX
|
||||
#define MPD_INPUT_LEGACY_HXX
|
||||
|
||||
#include "check.h"
|
||||
#include "thread/Mutex.hxx"
|
||||
#include "thread/Cond.hxx"
|
||||
#include "gcc.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
struct Tag;
|
||||
struct input_stream;
|
||||
class Error;
|
||||
|
||||
/**
|
||||
* Opens a new input stream. You may not access it until the "ready"
|
||||
* flag is set.
|
||||
*
|
||||
* @param mutex a mutex that is used to protect this object; must be
|
||||
* locked before calling any of the public methods
|
||||
* @param cond a cond that gets signalled when the state of
|
||||
* this object changes; may be NULL if the caller doesn't want to get
|
||||
* notifications
|
||||
* @return an #input_stream object on success, NULL on error
|
||||
*/
|
||||
gcc_nonnull(1)
|
||||
gcc_malloc
|
||||
struct input_stream *
|
||||
input_stream_open(const char *uri,
|
||||
Mutex &mutex, Cond &cond,
|
||||
Error &error);
|
||||
|
||||
/**
|
||||
* Close the input stream and free resources.
|
||||
*
|
||||
* The caller must not lock the mutex.
|
||||
*/
|
||||
gcc_nonnull(1)
|
||||
void
|
||||
input_stream_close(struct input_stream *is);
|
||||
|
||||
/**
|
||||
* Check for errors that may have occurred in the I/O thread.
|
||||
*
|
||||
* @return false on error
|
||||
*/
|
||||
gcc_nonnull(1)
|
||||
bool
|
||||
input_stream_check(struct input_stream *is, Error &error);
|
||||
|
||||
/**
|
||||
* Update the public attributes. Call before accessing attributes
|
||||
* such as "ready" or "offset".
|
||||
*/
|
||||
gcc_nonnull(1)
|
||||
void
|
||||
input_stream_update(struct input_stream *is);
|
||||
|
||||
/**
|
||||
* Wait until the stream becomes ready.
|
||||
*
|
||||
* The caller must lock the mutex.
|
||||
*/
|
||||
gcc_nonnull(1)
|
||||
void
|
||||
input_stream_wait_ready(struct input_stream *is);
|
||||
|
||||
/**
|
||||
* Wrapper for input_stream_wait_locked() which locks and unlocks the
|
||||
* mutex; the caller must not be holding it already.
|
||||
*/
|
||||
gcc_nonnull(1)
|
||||
void
|
||||
input_stream_lock_wait_ready(struct input_stream *is);
|
||||
|
||||
gcc_nonnull_all gcc_pure
|
||||
const char *
|
||||
input_stream_get_mime_type(const struct input_stream *is);
|
||||
|
||||
gcc_nonnull_all
|
||||
void
|
||||
input_stream_override_mime_type(struct input_stream *is, const char *mime);
|
||||
|
||||
gcc_nonnull_all gcc_pure
|
||||
goffset
|
||||
input_stream_get_size(const struct input_stream *is);
|
||||
|
||||
gcc_nonnull_all gcc_pure
|
||||
goffset
|
||||
input_stream_get_offset(const struct input_stream *is);
|
||||
|
||||
gcc_nonnull_all gcc_pure
|
||||
bool
|
||||
input_stream_is_seekable(const struct input_stream *is);
|
||||
|
||||
/**
|
||||
* Determines whether seeking is cheap. This is true for local files.
|
||||
*/
|
||||
gcc_pure gcc_nonnull(1)
|
||||
bool
|
||||
input_stream_cheap_seeking(const struct input_stream *is);
|
||||
|
||||
/**
|
||||
* Seeks to the specified position in the stream. This will most
|
||||
* likely fail if the "seekable" flag is false.
|
||||
*
|
||||
* The caller must lock the mutex.
|
||||
*
|
||||
* @param is the input_stream object
|
||||
* @param offset the relative offset
|
||||
* @param whence the base of the seek, one of SEEK_SET, SEEK_CUR, SEEK_END
|
||||
*/
|
||||
gcc_nonnull(1)
|
||||
bool
|
||||
input_stream_seek(struct input_stream *is, goffset offset, int whence,
|
||||
Error &error);
|
||||
|
||||
/**
|
||||
* Wrapper for input_stream_seek() which locks and unlocks the
|
||||
* mutex; the caller must not be holding it already.
|
||||
*/
|
||||
gcc_nonnull(1)
|
||||
bool
|
||||
input_stream_lock_seek(struct input_stream *is, goffset offset, int whence,
|
||||
Error &error);
|
||||
|
||||
/**
|
||||
* Returns true if the stream has reached end-of-file.
|
||||
*
|
||||
* The caller must lock the mutex.
|
||||
*/
|
||||
gcc_nonnull(1)
|
||||
gcc_pure
|
||||
bool input_stream_eof(struct input_stream *is);
|
||||
|
||||
/**
|
||||
* Wrapper for input_stream_eof() which locks and unlocks the mutex;
|
||||
* the caller must not be holding it already.
|
||||
*/
|
||||
gcc_nonnull(1)
|
||||
gcc_pure
|
||||
bool
|
||||
input_stream_lock_eof(struct input_stream *is);
|
||||
|
||||
/**
|
||||
* Reads the tag from the stream.
|
||||
*
|
||||
* The caller must lock the mutex.
|
||||
*
|
||||
* @return a tag object which must be freed by the caller, or nullptr
|
||||
* if the tag has not changed since the last call
|
||||
*/
|
||||
gcc_nonnull(1)
|
||||
gcc_malloc
|
||||
Tag *
|
||||
input_stream_tag(struct input_stream *is);
|
||||
|
||||
/**
|
||||
* Wrapper for input_stream_tag() which locks and unlocks the
|
||||
* mutex; the caller must not be holding it already.
|
||||
*/
|
||||
gcc_nonnull(1)
|
||||
gcc_malloc
|
||||
Tag *
|
||||
input_stream_lock_tag(struct input_stream *is);
|
||||
|
||||
/**
|
||||
* Returns true if the next read operation will not block: either data
|
||||
* is available, or end-of-stream has been reached, or an error has
|
||||
* occurred.
|
||||
*
|
||||
* The caller must lock the mutex.
|
||||
*/
|
||||
gcc_nonnull(1)
|
||||
gcc_pure
|
||||
bool
|
||||
input_stream_available(struct input_stream *is);
|
||||
|
||||
/**
|
||||
* Reads data from the stream into the caller-supplied buffer.
|
||||
* Returns 0 on error or eof (check with input_stream_eof()).
|
||||
*
|
||||
* The caller must lock the mutex.
|
||||
*
|
||||
* @param is the input_stream object
|
||||
* @param ptr the buffer to read into
|
||||
* @param size the maximum number of bytes to read
|
||||
* @return the number of bytes read
|
||||
*/
|
||||
gcc_nonnull(1, 2)
|
||||
size_t
|
||||
input_stream_read(struct input_stream *is, void *ptr, size_t size,
|
||||
Error &error);
|
||||
|
||||
/**
|
||||
* Wrapper for input_stream_tag() which locks and unlocks the
|
||||
* mutex; the caller must not be holding it already.
|
||||
*/
|
||||
gcc_nonnull(1, 2)
|
||||
size_t
|
||||
input_stream_lock_read(struct input_stream *is, void *ptr, size_t size,
|
||||
Error &error);
|
||||
|
||||
#endif
|
|
@ -20,13 +20,17 @@
|
|||
#ifndef MPD_INPUT_PLUGIN_HXX
|
||||
#define MPD_INPUT_PLUGIN_HXX
|
||||
|
||||
#include "InputLegacy.hxx"
|
||||
#include "thread/Mutex.hxx"
|
||||
#include "thread/Cond.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
struct config_param;
|
||||
struct input_stream;
|
||||
class Error;
|
||||
struct Tag;
|
||||
|
||||
struct input_plugin {
|
||||
const char *name;
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
static constexpr Domain input_domain("input");
|
||||
|
||||
struct input_stream *
|
||||
input_stream_open(const char *url,
|
||||
Mutex &mutex, Cond &cond,
|
||||
Error &error)
|
||||
input_stream::Open(const char *url,
|
||||
Mutex &mutex, Cond &cond,
|
||||
Error &error)
|
||||
{
|
||||
input_plugins_for_each_enabled(plugin) {
|
||||
struct input_stream *is;
|
||||
|
@ -57,191 +57,123 @@ input_stream_open(const char *url,
|
|||
}
|
||||
|
||||
bool
|
||||
input_stream_check(struct input_stream *is, Error &error)
|
||||
input_stream::Check(Error &error)
|
||||
{
|
||||
assert(is != NULL);
|
||||
|
||||
return is->plugin.check == NULL ||
|
||||
is->plugin.check(is, error);
|
||||
return plugin.check == nullptr || plugin.check(this, error);
|
||||
}
|
||||
|
||||
void
|
||||
input_stream_update(struct input_stream *is)
|
||||
input_stream::Update()
|
||||
{
|
||||
assert(is != NULL);
|
||||
|
||||
if (is->plugin.update != NULL)
|
||||
is->plugin.update(is);
|
||||
if (plugin.update != nullptr)
|
||||
plugin.update(this);
|
||||
}
|
||||
|
||||
void
|
||||
input_stream_wait_ready(struct input_stream *is)
|
||||
input_stream::WaitReady()
|
||||
{
|
||||
assert(is != NULL);
|
||||
|
||||
while (true) {
|
||||
input_stream_update(is);
|
||||
if (is->ready)
|
||||
Update();
|
||||
if (ready)
|
||||
break;
|
||||
|
||||
is->cond.wait(is->mutex);
|
||||
cond.wait(mutex);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
input_stream_lock_wait_ready(struct input_stream *is)
|
||||
input_stream::LockWaitReady()
|
||||
{
|
||||
assert(is != NULL);
|
||||
|
||||
const ScopeLock protect(is->mutex);
|
||||
input_stream_wait_ready(is);
|
||||
}
|
||||
|
||||
const char *
|
||||
input_stream_get_mime_type(const struct input_stream *is)
|
||||
{
|
||||
assert(is != NULL);
|
||||
assert(is->ready);
|
||||
|
||||
return is->mime.empty() ? nullptr : is->mime.c_str();
|
||||
}
|
||||
|
||||
void
|
||||
input_stream_override_mime_type(struct input_stream *is, const char *mime)
|
||||
{
|
||||
assert(is != NULL);
|
||||
assert(is->ready);
|
||||
|
||||
is->mime = mime;
|
||||
}
|
||||
|
||||
goffset
|
||||
input_stream_get_size(const struct input_stream *is)
|
||||
{
|
||||
assert(is != NULL);
|
||||
assert(is->ready);
|
||||
|
||||
return is->size;
|
||||
}
|
||||
|
||||
goffset
|
||||
input_stream_get_offset(const struct input_stream *is)
|
||||
{
|
||||
assert(is != NULL);
|
||||
assert(is->ready);
|
||||
|
||||
return is->offset;
|
||||
const ScopeLock protect(mutex);
|
||||
WaitReady();
|
||||
}
|
||||
|
||||
bool
|
||||
input_stream_is_seekable(const struct input_stream *is)
|
||||
input_stream::CheapSeeking() const
|
||||
{
|
||||
assert(is != NULL);
|
||||
assert(is->ready);
|
||||
|
||||
return is->seekable;
|
||||
return IsSeekable() && !uri_has_scheme(uri.c_str());
|
||||
}
|
||||
|
||||
bool
|
||||
input_stream_cheap_seeking(const struct input_stream *is)
|
||||
input_stream::Seek(goffset _offset, int whence, Error &error)
|
||||
{
|
||||
return is->seekable && !uri_has_scheme(is->uri.c_str());
|
||||
}
|
||||
|
||||
bool
|
||||
input_stream_seek(struct input_stream *is, goffset offset, int whence,
|
||||
Error &error)
|
||||
{
|
||||
assert(is != NULL);
|
||||
|
||||
if (is->plugin.seek == NULL)
|
||||
if (plugin.seek == nullptr)
|
||||
return false;
|
||||
|
||||
return is->plugin.seek(is, offset, whence, error);
|
||||
return plugin.seek(this, _offset, whence, error);
|
||||
}
|
||||
|
||||
bool
|
||||
input_stream_lock_seek(struct input_stream *is, goffset offset, int whence,
|
||||
Error &error)
|
||||
input_stream::LockSeek(goffset _offset, int whence, Error &error)
|
||||
{
|
||||
assert(is != NULL);
|
||||
|
||||
if (is->plugin.seek == NULL)
|
||||
if (plugin.seek == nullptr)
|
||||
return false;
|
||||
|
||||
const ScopeLock protect(is->mutex);
|
||||
return input_stream_seek(is, offset, whence, error);
|
||||
const ScopeLock protect(mutex);
|
||||
return Seek(_offset, whence, error);
|
||||
}
|
||||
|
||||
Tag *
|
||||
input_stream_tag(struct input_stream *is)
|
||||
input_stream::ReadTag()
|
||||
{
|
||||
assert(is != NULL);
|
||||
|
||||
return is->plugin.tag != NULL
|
||||
? is->plugin.tag(is)
|
||||
: NULL;
|
||||
return plugin.tag != nullptr
|
||||
? plugin.tag(this)
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
Tag *
|
||||
input_stream_lock_tag(struct input_stream *is)
|
||||
input_stream::LockReadTag()
|
||||
{
|
||||
assert(is != NULL);
|
||||
|
||||
if (is->plugin.tag == NULL)
|
||||
if (plugin.tag == nullptr)
|
||||
return nullptr;
|
||||
|
||||
const ScopeLock protect(is->mutex);
|
||||
return input_stream_tag(is);
|
||||
const ScopeLock protect(mutex);
|
||||
return ReadTag();
|
||||
}
|
||||
|
||||
bool
|
||||
input_stream_available(struct input_stream *is)
|
||||
input_stream::IsAvailable()
|
||||
{
|
||||
assert(is != NULL);
|
||||
|
||||
return is->plugin.available != NULL
|
||||
? is->plugin.available(is)
|
||||
return plugin.available != nullptr
|
||||
? plugin.available(this)
|
||||
: true;
|
||||
}
|
||||
|
||||
size_t
|
||||
input_stream_read(struct input_stream *is, void *ptr, size_t size,
|
||||
Error &error)
|
||||
input_stream::Read(void *ptr, size_t _size, Error &error)
|
||||
{
|
||||
assert(ptr != NULL);
|
||||
assert(size > 0);
|
||||
assert(_size > 0);
|
||||
|
||||
return is->plugin.read(is, ptr, size, error);
|
||||
return plugin.read(this, ptr, _size, error);
|
||||
}
|
||||
|
||||
size_t
|
||||
input_stream_lock_read(struct input_stream *is, void *ptr, size_t size,
|
||||
Error &error)
|
||||
input_stream::LockRead(void *ptr, size_t _size, Error &error)
|
||||
{
|
||||
assert(ptr != NULL);
|
||||
assert(size > 0);
|
||||
assert(_size > 0);
|
||||
|
||||
const ScopeLock protect(is->mutex);
|
||||
return input_stream_read(is, ptr, size, error);
|
||||
const ScopeLock protect(mutex);
|
||||
return Read(ptr, _size, error);
|
||||
}
|
||||
|
||||
void input_stream_close(struct input_stream *is)
|
||||
void
|
||||
input_stream::Close()
|
||||
{
|
||||
is->plugin.close(is);
|
||||
}
|
||||
|
||||
bool input_stream_eof(struct input_stream *is)
|
||||
{
|
||||
return is->plugin.eof(is);
|
||||
plugin.close(this);
|
||||
}
|
||||
|
||||
bool
|
||||
input_stream_lock_eof(struct input_stream *is)
|
||||
input_stream::IsEOF()
|
||||
{
|
||||
assert(is != NULL);
|
||||
|
||||
const ScopeLock protect(is->mutex);
|
||||
return input_stream_eof(is);
|
||||
return plugin.eof(this);
|
||||
}
|
||||
|
||||
bool
|
||||
input_stream::LockIsEOF()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
return IsEOF();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#ifndef MPD_INPUT_STREAM_HXX
|
||||
#define MPD_INPUT_STREAM_HXX
|
||||
|
||||
#include "InputLegacy.hxx"
|
||||
#include "check.h"
|
||||
#include "thread/Mutex.hxx"
|
||||
#include "thread/Cond.hxx"
|
||||
|
@ -28,8 +27,13 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
class Error;
|
||||
struct Tag;
|
||||
|
||||
struct input_stream {
|
||||
/**
|
||||
* the plugin which implements this input stream
|
||||
|
@ -95,20 +99,185 @@ struct input_stream {
|
|||
size(-1), offset(0) {
|
||||
assert(_uri != NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a new input stream. You may not access it until the "ready"
|
||||
* flag is set.
|
||||
*
|
||||
* @param mutex a mutex that is used to protect this object; must be
|
||||
* locked before calling any of the public methods
|
||||
* @param cond a cond that gets signalled when the state of
|
||||
* this object changes; may be NULL if the caller doesn't want to get
|
||||
* notifications
|
||||
* @return an #input_stream object on success, NULL on error
|
||||
*/
|
||||
gcc_nonnull_all
|
||||
gcc_malloc
|
||||
static input_stream *Open(const char *uri, Mutex &mutex, Cond &cond,
|
||||
Error &error);
|
||||
|
||||
/**
|
||||
* Close the input stream and free resources.
|
||||
*
|
||||
* The caller must not lock the mutex.
|
||||
*/
|
||||
void Close();
|
||||
|
||||
void Lock() {
|
||||
mutex.lock();
|
||||
}
|
||||
|
||||
void Unlock() {
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for errors that may have occurred in the I/O thread.
|
||||
*
|
||||
* @return false on error
|
||||
*/
|
||||
bool Check(Error &error);
|
||||
|
||||
/**
|
||||
* Update the public attributes. Call before accessing attributes
|
||||
* such as "ready" or "offset".
|
||||
*/
|
||||
void Update();
|
||||
|
||||
/**
|
||||
* Wait until the stream becomes ready.
|
||||
*
|
||||
* The caller must lock the mutex.
|
||||
*/
|
||||
void WaitReady();
|
||||
|
||||
/**
|
||||
* Wrapper for WaitReady() which locks and unlocks the mutex;
|
||||
* the caller must not be holding it already.
|
||||
*/
|
||||
void LockWaitReady();
|
||||
|
||||
gcc_pure
|
||||
const char *GetMimeType() const {
|
||||
assert(ready);
|
||||
|
||||
return mime.empty() ? nullptr : mime.c_str();
|
||||
}
|
||||
|
||||
gcc_nonnull_all
|
||||
void OverrideMimeType(const char *_mime) {
|
||||
assert(ready);
|
||||
|
||||
mime = _mime;
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
goffset GetSize() const {
|
||||
assert(ready);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
goffset GetOffset() const {
|
||||
assert(ready);
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
bool IsSeekable() const {
|
||||
assert(ready);
|
||||
|
||||
return seekable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether seeking is cheap. This is true for local files.
|
||||
*/
|
||||
gcc_pure
|
||||
bool CheapSeeking() const;
|
||||
|
||||
/**
|
||||
* Seeks to the specified position in the stream. This will most
|
||||
* likely fail if the "seekable" flag is false.
|
||||
*
|
||||
* The caller must lock the mutex.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Returns true if the stream has reached end-of-file.
|
||||
*
|
||||
* The caller must lock the mutex.
|
||||
*/
|
||||
gcc_pure
|
||||
bool IsEOF();
|
||||
|
||||
/**
|
||||
* Wrapper for IsEOF() which locks and unlocks the mutex; the
|
||||
* caller must not be holding it already.
|
||||
*/
|
||||
gcc_pure
|
||||
bool LockIsEOF();
|
||||
|
||||
/**
|
||||
* Reads the tag from the stream.
|
||||
*
|
||||
* The caller must lock the mutex.
|
||||
*
|
||||
* @return a tag object which must be freed by the caller, or
|
||||
* nullptr if the tag has not changed since the last call
|
||||
*/
|
||||
gcc_malloc
|
||||
Tag *ReadTag();
|
||||
|
||||
/**
|
||||
* Wrapper for ReadTag() which locks and unlocks the mutex;
|
||||
* the caller must not be holding it already.
|
||||
*/
|
||||
gcc_malloc
|
||||
Tag *LockReadTag();
|
||||
|
||||
/**
|
||||
* Returns true if the next read operation will not block: either data
|
||||
* is available, or end-of-stream has been reached, or an error has
|
||||
* occurred.
|
||||
*
|
||||
* The caller must lock the mutex.
|
||||
*/
|
||||
gcc_pure
|
||||
bool IsAvailable();
|
||||
|
||||
/**
|
||||
* Reads data from the stream into the caller-supplied buffer.
|
||||
* Returns 0 on error or eof (check with IsEOF()).
|
||||
*
|
||||
* The caller must lock the mutex.
|
||||
*
|
||||
* @param is the input_stream object
|
||||
* @param ptr the buffer to read into
|
||||
* @param size the maximum number of bytes to read
|
||||
* @return the number of bytes read
|
||||
*/
|
||||
gcc_nonnull_all
|
||||
size_t Read(void *ptr, size_t size, Error &error);
|
||||
|
||||
/**
|
||||
* Wrapper for Read() which locks and unlocks the mutex;
|
||||
* the caller must not be holding it already.
|
||||
*/
|
||||
gcc_nonnull_all
|
||||
size_t LockRead(void *ptr, size_t size, Error &error);
|
||||
};
|
||||
|
||||
gcc_nonnull(1)
|
||||
static inline void
|
||||
input_stream_lock(struct input_stream *is)
|
||||
{
|
||||
is->mutex.lock();
|
||||
}
|
||||
|
||||
gcc_nonnull(1)
|
||||
static inline void
|
||||
input_stream_unlock(struct input_stream *is)
|
||||
{
|
||||
is->mutex.unlock();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "PlaylistRegistry.hxx"
|
||||
#include "util/UriUtil.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -41,7 +41,7 @@ playlist_open_remote(const char *uri, Mutex &mutex, Cond &cond,
|
|||
}
|
||||
|
||||
Error error;
|
||||
input_stream *is = input_stream_open(uri, mutex, cond, error);
|
||||
input_stream *is = input_stream::Open(uri, mutex, cond, error);
|
||||
if (is == NULL) {
|
||||
if (error.IsDefined())
|
||||
g_warning("Failed to open %s: %s",
|
||||
|
@ -52,7 +52,7 @@ playlist_open_remote(const char *uri, Mutex &mutex, Cond &cond,
|
|||
|
||||
playlist = playlist_list_open_stream(is, uri);
|
||||
if (playlist == NULL) {
|
||||
input_stream_close(is);
|
||||
is->Close();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "DatabaseGlue.hxx"
|
||||
#include "DatabasePlugin.hxx"
|
||||
#include "Client.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "Song.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
||||
|
@ -182,7 +182,7 @@ playlist_file_print(Client *client, const char *uri, bool detail)
|
|||
playlist_plugin_close(playlist);
|
||||
|
||||
if (is != NULL)
|
||||
input_stream_close(is);
|
||||
is->Close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "PlaylistAny.hxx"
|
||||
#include "PlaylistSong.hxx"
|
||||
#include "Playlist.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "Song.hxx"
|
||||
|
||||
enum playlist_result
|
||||
|
@ -83,7 +83,7 @@ playlist_open_into_queue(const char *uri,
|
|||
playlist_plugin_close(playlist);
|
||||
|
||||
if (is != NULL)
|
||||
input_stream_close(is);
|
||||
is->Close();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "playlist/RssPlaylistPlugin.hxx"
|
||||
#include "playlist/CuePlaylistPlugin.hxx"
|
||||
#include "playlist/EmbeddedCuePlaylistPlugin.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "util/UriUtil.hxx"
|
||||
#include "util/StringUtil.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
@ -220,8 +220,7 @@ playlist_list_open_stream_mime2(struct input_stream *is, const char *mime)
|
|||
string_array_contains(plugin->mime_types, mime)) {
|
||||
/* rewind the stream, so each plugin gets a
|
||||
fresh start */
|
||||
Error error;
|
||||
input_stream_seek(is, 0, SEEK_SET, error);
|
||||
is->Seek(0, SEEK_SET, IgnoreError());
|
||||
|
||||
playlist = playlist_plugin_open_stream(plugin, is);
|
||||
if (playlist != NULL)
|
||||
|
@ -266,8 +265,7 @@ playlist_list_open_stream_suffix(struct input_stream *is, const char *suffix)
|
|||
string_array_contains(plugin->suffixes, suffix)) {
|
||||
/* rewind the stream, so each plugin gets a
|
||||
fresh start */
|
||||
Error error;
|
||||
input_stream_seek(is, 0, SEEK_SET, error);
|
||||
is->Seek(0, SEEK_SET, IgnoreError());
|
||||
|
||||
playlist = playlist_plugin_open_stream(plugin, is);
|
||||
if (playlist != NULL)
|
||||
|
@ -284,9 +282,9 @@ playlist_list_open_stream(struct input_stream *is, const char *uri)
|
|||
const char *suffix;
|
||||
struct playlist_provider *playlist;
|
||||
|
||||
input_stream_lock_wait_ready(is);
|
||||
is->LockWaitReady();
|
||||
|
||||
const char *const mime = input_stream_get_mime_type(is);
|
||||
const char *const mime = is->GetMimeType();
|
||||
if (mime != NULL) {
|
||||
playlist = playlist_list_open_stream_mime(is, mime);
|
||||
if (playlist != NULL)
|
||||
|
@ -331,7 +329,7 @@ playlist_list_open_path(const char *path_fs, Mutex &mutex, Cond &cond,
|
|||
return NULL;
|
||||
|
||||
Error error;
|
||||
input_stream *is = input_stream_open(path_fs, mutex, cond, error);
|
||||
input_stream *is = input_stream::Open(path_fs, mutex, cond, error);
|
||||
if (is == NULL) {
|
||||
if (error.IsDefined())
|
||||
g_warning("%s", error.GetMessage());
|
||||
|
@ -339,13 +337,13 @@ playlist_list_open_path(const char *path_fs, Mutex &mutex, Cond &cond,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
input_stream_lock_wait_ready(is);
|
||||
is->LockWaitReady();
|
||||
|
||||
playlist = playlist_list_open_stream_suffix(is, suffix);
|
||||
if (playlist != NULL)
|
||||
*is_r = is;
|
||||
else
|
||||
input_stream_close(is);
|
||||
is->Close();
|
||||
|
||||
return playlist;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "fs/Path.hxx"
|
||||
#include "fs/FileSystem.hxx"
|
||||
#include "Tag.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "DecoderPlugin.hxx"
|
||||
#include "DecoderList.hxx"
|
||||
#include "TagHandler.hxx"
|
||||
|
@ -127,12 +127,10 @@ Song::UpdateFile()
|
|||
if (plugin->scan_stream != NULL) {
|
||||
/* open the input_stream (if not already
|
||||
open) */
|
||||
if (is == NULL) {
|
||||
Error error;
|
||||
is = input_stream_open(path_fs.c_str(),
|
||||
mutex, cond,
|
||||
error);
|
||||
}
|
||||
if (is == NULL)
|
||||
is = input_stream::Open(path_fs.c_str(),
|
||||
mutex, cond,
|
||||
IgnoreError());
|
||||
|
||||
/* now try the stream_tag() method */
|
||||
if (is != NULL) {
|
||||
|
@ -145,8 +143,7 @@ Song::UpdateFile()
|
|||
delete tag;
|
||||
tag = nullptr;
|
||||
|
||||
Error error;
|
||||
input_stream_lock_seek(is, 0, SEEK_SET, error);
|
||||
is->LockSeek(0, SEEK_SET, IgnoreError());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,7 +151,7 @@ Song::UpdateFile()
|
|||
} while (plugin != NULL);
|
||||
|
||||
if (is != NULL)
|
||||
input_stream_close(is);
|
||||
is->Close();
|
||||
|
||||
if (tag != nullptr && tag->IsEmpty())
|
||||
tag_scan_fallback(path_fs.c_str(), &full_tag_handler, tag);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "util/Error.hxx"
|
||||
#include "DecoderList.hxx"
|
||||
#include "DecoderPlugin.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
|
||||
#include <assert.h>
|
||||
#include <unistd.h> /* for SEEK_SET */
|
||||
|
@ -62,8 +62,8 @@ tag_file_scan(const char *path_fs,
|
|||
open) */
|
||||
if (is == nullptr) {
|
||||
Error error;
|
||||
is = input_stream_open(path_fs, mutex, cond,
|
||||
error);
|
||||
is = input_stream::Open(path_fs, mutex, cond,
|
||||
error);
|
||||
}
|
||||
|
||||
/* now try the stream_tag() method */
|
||||
|
@ -73,8 +73,7 @@ tag_file_scan(const char *path_fs,
|
|||
handler_ctx))
|
||||
break;
|
||||
|
||||
Error error;
|
||||
input_stream_lock_seek(is, 0, SEEK_SET, error);
|
||||
is->LockSeek(0, SEEK_SET, IgnoreError());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +81,7 @@ tag_file_scan(const char *path_fs,
|
|||
} while (plugin != NULL);
|
||||
|
||||
if (is != NULL)
|
||||
input_stream_close(is);
|
||||
is->Close();
|
||||
|
||||
return plugin != NULL;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "TextInputStream.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "util/fifo_buffer.h"
|
||||
#include "util/Error.hxx"
|
||||
|
||||
|
@ -54,8 +54,7 @@ bool TextInputStream::ReadLine(std::string &line)
|
|||
--length;
|
||||
|
||||
Error error;
|
||||
nbytes = input_stream_lock_read(is, dest, length,
|
||||
error);
|
||||
nbytes = is->LockRead(dest, length, error);
|
||||
if (nbytes > 0)
|
||||
fifo_buffer_append(buffer, nbytes);
|
||||
else if (error.IsDefined()) {
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
}
|
||||
|
||||
~Bzip2ArchiveFile() {
|
||||
input_stream_close(istream);
|
||||
istream->Close();
|
||||
}
|
||||
|
||||
void Ref() {
|
||||
|
@ -155,7 +155,7 @@ bz2_open(const char *pathname, Error &error)
|
|||
{
|
||||
static Mutex mutex;
|
||||
static Cond cond;
|
||||
input_stream *is = input_stream_open(pathname, mutex, cond, error);
|
||||
input_stream *is = input_stream::Open(pathname, mutex, cond, error);
|
||||
if (is == nullptr)
|
||||
return nullptr;
|
||||
|
||||
|
@ -211,9 +211,8 @@ bz2_fillbuffer(Bzip2InputStream *bis, Error &error)
|
|||
if (bzstream->avail_in > 0)
|
||||
return true;
|
||||
|
||||
count = input_stream_read(bis->archive->istream,
|
||||
bis->buffer, sizeof(bis->buffer),
|
||||
error);
|
||||
count = bis->archive->istream->Read(bis->buffer, sizeof(bis->buffer),
|
||||
error);
|
||||
if (count == 0)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ struct input_curl {
|
|||
char *meta_name;
|
||||
|
||||
/** the tag object ready to be requested via
|
||||
input_stream_tag() */
|
||||
input_stream::ReadTag() */
|
||||
Tag *tag;
|
||||
|
||||
Error postponed_error;
|
||||
|
|
|
@ -66,7 +66,7 @@ struct RewindInputStream {
|
|||
}
|
||||
|
||||
~RewindInputStream() {
|
||||
input_stream_close(input);
|
||||
input->Close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,7 +114,7 @@ input_rewind_check(struct input_stream *is, Error &error)
|
|||
{
|
||||
RewindInputStream *r = (RewindInputStream *)is;
|
||||
|
||||
return input_stream_check(r->input, error);
|
||||
return r->input->Check(error);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -131,7 +131,7 @@ input_rewind_tag(struct input_stream *is)
|
|||
{
|
||||
RewindInputStream *r = (RewindInputStream *)is;
|
||||
|
||||
return input_stream_tag(r->input);
|
||||
return r->input->ReadTag();
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -139,7 +139,7 @@ input_rewind_available(struct input_stream *is)
|
|||
{
|
||||
RewindInputStream *r = (RewindInputStream *)is;
|
||||
|
||||
return input_stream_available(r->input);
|
||||
return r->input->IsAvailable();
|
||||
}
|
||||
|
||||
static size_t
|
||||
|
@ -165,7 +165,7 @@ input_rewind_read(struct input_stream *is, void *ptr, size_t size,
|
|||
} else {
|
||||
/* pass method call to underlying stream */
|
||||
|
||||
size_t nbytes = input_stream_read(r->input, ptr, size, error);
|
||||
size_t nbytes = r->input->Read(ptr, size, error);
|
||||
|
||||
if (r->input->offset > (goffset)sizeof(r->buffer))
|
||||
/* disable buffering */
|
||||
|
@ -190,7 +190,7 @@ input_rewind_eof(struct input_stream *is)
|
|||
{
|
||||
RewindInputStream *r = (RewindInputStream *)is;
|
||||
|
||||
return !r->ReadingFromBuffer() && input_stream_eof(r->input);
|
||||
return !r->ReadingFromBuffer() && r->input->IsEOF();
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -213,8 +213,7 @@ input_rewind_seek(struct input_stream *is, goffset offset, int whence,
|
|||
|
||||
return true;
|
||||
} else {
|
||||
bool success = input_stream_seek(r->input, offset, whence,
|
||||
error);
|
||||
bool success = r->input->Seek(offset, whence, error);
|
||||
r->CopyAttributes();
|
||||
|
||||
/* disable the buffer, because r->input has left the
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "config.h"
|
||||
#include "AsxPlaylistPlugin.hxx"
|
||||
#include "MemoryPlaylistProvider.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "Song.hxx"
|
||||
#include "Tag.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
@ -219,8 +219,7 @@ asx_open_stream(struct input_stream *is)
|
|||
&parser, asx_parser_destroy);
|
||||
|
||||
while (true) {
|
||||
nbytes = input_stream_lock_read(is, buffer, sizeof(buffer),
|
||||
error2);
|
||||
nbytes = is->LockRead(buffer, sizeof(buffer), error2);
|
||||
if (nbytes == 0) {
|
||||
if (error2.IsDefined()) {
|
||||
g_markup_parse_context_free(context);
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "PlaylistPlugin.hxx"
|
||||
#include "Tag.hxx"
|
||||
#include "Song.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "cue/CueParser.hxx"
|
||||
#include "TextInputStream.hxx"
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "PlaylistRegistry.hxx"
|
||||
#include "conf.h"
|
||||
#include "Song.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
|
@ -45,7 +45,7 @@ struct LastfmPlaylist {
|
|||
|
||||
~LastfmPlaylist() {
|
||||
playlist_plugin_close(xspf);
|
||||
input_stream_close(is);
|
||||
is->Close();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -97,7 +97,7 @@ lastfm_get(const char *url, Mutex &mutex, Cond &cond)
|
|||
char buffer[4096];
|
||||
size_t length = 0;
|
||||
|
||||
input_stream = input_stream_open(url, mutex, cond, error);
|
||||
input_stream = input_stream::Open(url, mutex, cond, error);
|
||||
if (input_stream == NULL) {
|
||||
if (error.IsDefined())
|
||||
g_warning("%s", error.GetMessage());
|
||||
|
@ -107,22 +107,22 @@ lastfm_get(const char *url, Mutex &mutex, Cond &cond)
|
|||
|
||||
mutex.lock();
|
||||
|
||||
input_stream_wait_ready(input_stream);
|
||||
input_stream->WaitReady();
|
||||
|
||||
do {
|
||||
size_t nbytes =
|
||||
input_stream_read(input_stream, buffer + length,
|
||||
sizeof(buffer) - length, error);
|
||||
input_stream->Read(buffer + length,
|
||||
sizeof(buffer) - length, error);
|
||||
if (nbytes == 0) {
|
||||
if (error.IsDefined())
|
||||
g_warning("%s", error.GetMessage());
|
||||
|
||||
if (input_stream_eof(input_stream))
|
||||
if (input_stream->IsEOF())
|
||||
break;
|
||||
|
||||
/* I/O error */
|
||||
mutex.unlock();
|
||||
input_stream_close(input_stream);
|
||||
input_stream->Close();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ lastfm_get(const char *url, Mutex &mutex, Cond &cond)
|
|||
|
||||
mutex.unlock();
|
||||
|
||||
input_stream_close(input_stream);
|
||||
input_stream->Close();
|
||||
return g_strndup(buffer, length);
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ lastfm_open_uri(const char *uri, Mutex &mutex, Cond &cond)
|
|||
g_free(session);
|
||||
|
||||
Error error;
|
||||
const auto is = input_stream_open(p, mutex, cond, error);
|
||||
const auto is = input_stream::Open(p, mutex, cond, error);
|
||||
g_free(p);
|
||||
|
||||
if (is == nullptr) {
|
||||
|
@ -237,11 +237,11 @@ lastfm_open_uri(const char *uri, Mutex &mutex, Cond &cond)
|
|||
|
||||
mutex.lock();
|
||||
|
||||
input_stream_wait_ready(is);
|
||||
is->WaitReady();
|
||||
|
||||
/* last.fm does not send a MIME type, we have to fake it here
|
||||
:-( */
|
||||
input_stream_override_mime_type(is, "application/xspf+xml");
|
||||
is->OverrideMimeType("application/xspf+xml");
|
||||
|
||||
mutex.unlock();
|
||||
|
||||
|
@ -249,7 +249,7 @@ lastfm_open_uri(const char *uri, Mutex &mutex, Cond &cond)
|
|||
|
||||
const auto xspf = playlist_list_open_stream(is, nullptr);
|
||||
if (xspf == nullptr) {
|
||||
input_stream_close(is);
|
||||
is->Close();
|
||||
g_warning("Failed to parse XSPF playlist");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "config.h"
|
||||
#include "PlsPlaylistPlugin.hxx"
|
||||
#include "MemoryPlaylistProvider.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "Song.hxx"
|
||||
#include "Tag.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
@ -114,8 +114,7 @@ pls_open_stream(struct input_stream *is)
|
|||
std::string kf_data;
|
||||
|
||||
do {
|
||||
nbytes = input_stream_lock_read(is, buffer, sizeof(buffer),
|
||||
error2);
|
||||
nbytes = is->LockRead(buffer, sizeof(buffer), error2);
|
||||
if (nbytes == 0) {
|
||||
if (error2.IsDefined()) {
|
||||
g_warning("%s", error2.GetMessage());
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "config.h"
|
||||
#include "RssPlaylistPlugin.hxx"
|
||||
#include "MemoryPlaylistProvider.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "Song.hxx"
|
||||
#include "Tag.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
@ -216,8 +216,7 @@ rss_open_stream(struct input_stream *is)
|
|||
&parser, rss_parser_destroy);
|
||||
|
||||
while (true) {
|
||||
nbytes = input_stream_lock_read(is, buffer, sizeof(buffer),
|
||||
error2);
|
||||
nbytes = is->LockRead(buffer, sizeof(buffer), error2);
|
||||
if (nbytes == 0) {
|
||||
if (error2.IsDefined()) {
|
||||
g_markup_parse_context_free(context);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "SoundCloudPlaylistPlugin.hxx"
|
||||
#include "MemoryPlaylistProvider.hxx"
|
||||
#include "conf.h"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "Song.hxx"
|
||||
#include "Tag.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
@ -249,8 +249,8 @@ soundcloud_parse_json(const char *url, yajl_handle hand,
|
|||
unsigned char *ubuffer = (unsigned char *)buffer;
|
||||
|
||||
Error error;
|
||||
input_stream *input_stream = input_stream_open(url, mutex, cond,
|
||||
error);
|
||||
input_stream *input_stream = input_stream::Open(url, mutex, cond,
|
||||
error);
|
||||
if (input_stream == NULL) {
|
||||
if (error.IsDefined())
|
||||
g_warning("%s", error.GetMessage());
|
||||
|
@ -258,24 +258,23 @@ soundcloud_parse_json(const char *url, yajl_handle hand,
|
|||
}
|
||||
|
||||
mutex.lock();
|
||||
input_stream_wait_ready(input_stream);
|
||||
input_stream->WaitReady();
|
||||
|
||||
yajl_status stat;
|
||||
int done = 0;
|
||||
|
||||
while (!done) {
|
||||
const size_t nbytes =
|
||||
input_stream_read(input_stream, buffer, sizeof(buffer),
|
||||
error);
|
||||
input_stream->Read(buffer, sizeof(buffer), error);
|
||||
if (nbytes == 0) {
|
||||
if (error.IsDefined())
|
||||
g_warning("%s", error.GetMessage());
|
||||
|
||||
if (input_stream_eof(input_stream)) {
|
||||
if (input_stream->IsEOF()) {
|
||||
done = true;
|
||||
} else {
|
||||
mutex.unlock();
|
||||
input_stream_close(input_stream);
|
||||
input_stream->Close();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -303,7 +302,7 @@ soundcloud_parse_json(const char *url, yajl_handle hand,
|
|||
}
|
||||
|
||||
mutex.unlock();
|
||||
input_stream_close(input_stream);
|
||||
input_stream->Close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "config.h"
|
||||
#include "XspfPlaylistPlugin.hxx"
|
||||
#include "MemoryPlaylistProvider.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "Tag.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
||||
|
@ -235,8 +235,7 @@ xspf_open_stream(struct input_stream *is)
|
|||
&parser, xspf_parser_destroy);
|
||||
|
||||
while (true) {
|
||||
nbytes = input_stream_lock_read(is, buffer, sizeof(buffer),
|
||||
error2);
|
||||
nbytes = is->LockRead(buffer, sizeof(buffer), error2);
|
||||
if (nbytes == 0) {
|
||||
if (error2.IsDefined()) {
|
||||
g_markup_parse_context_free(context);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "TagSave.hxx"
|
||||
#include "Song.hxx"
|
||||
#include "Directory.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "conf.h"
|
||||
#include "DecoderAPI.hxx"
|
||||
#include "DecoderList.hxx"
|
||||
|
@ -86,7 +86,7 @@ decoder_read(gcc_unused struct decoder *decoder,
|
|||
void *buffer, size_t length)
|
||||
{
|
||||
Error error;
|
||||
return input_stream_lock_read(is, buffer, length, error);
|
||||
return is->LockRead(buffer, length, error);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -190,22 +190,22 @@ int main(int argc, char **argv)
|
|||
if (playlist == NULL) {
|
||||
/* open the stream and wait until it becomes ready */
|
||||
|
||||
is = input_stream_open(uri, mutex, cond, error);
|
||||
is = input_stream::Open(uri, mutex, cond, error);
|
||||
if (is == NULL) {
|
||||
if (error.IsDefined())
|
||||
g_warning("%s", error.GetMessage());
|
||||
else
|
||||
g_printerr("input_stream_open() failed\n");
|
||||
g_printerr("input_stream::Open() failed\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
input_stream_lock_wait_ready(is);
|
||||
is->LockWaitReady();
|
||||
|
||||
/* open the playlist */
|
||||
|
||||
playlist = playlist_list_open_stream(is, uri);
|
||||
if (playlist == NULL) {
|
||||
input_stream_close(is);
|
||||
is->Close();
|
||||
g_printerr("Failed to open playlist\n");
|
||||
return 2;
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ int main(int argc, char **argv)
|
|||
|
||||
playlist_plugin_close(playlist);
|
||||
if (is != NULL)
|
||||
input_stream_close(is);
|
||||
is->Close();
|
||||
|
||||
decoder_plugin_deinit_all();
|
||||
playlist_list_global_finish();
|
||||
|
|
|
@ -59,34 +59,35 @@ dump_input_stream(struct input_stream *is)
|
|||
{
|
||||
Error error;
|
||||
|
||||
input_stream_lock(is);
|
||||
is->Lock();
|
||||
|
||||
/* wait until the stream becomes ready */
|
||||
|
||||
input_stream_wait_ready(is);
|
||||
is->WaitReady();
|
||||
|
||||
if (!input_stream_check(is, error)) {
|
||||
if (!is->Check(error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
input_stream_unlock(is);
|
||||
is->Unlock();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* read data and tags from the stream */
|
||||
|
||||
input_stream_unlock(is);
|
||||
is->Unlock();
|
||||
{
|
||||
TextInputStream tis(is);
|
||||
dump_text_file(tis);
|
||||
}
|
||||
input_stream_lock(is);
|
||||
|
||||
if (!input_stream_check(is, error)) {
|
||||
is->Lock();
|
||||
|
||||
if (!is->Check(error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
input_stream_unlock(is);
|
||||
is->Unlock();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
input_stream_unlock(is);
|
||||
is->Unlock();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -131,15 +132,15 @@ int main(int argc, char **argv)
|
|||
Mutex mutex;
|
||||
Cond cond;
|
||||
|
||||
is = input_stream_open(argv[1], mutex, cond, error);
|
||||
is = input_stream::Open(argv[1], mutex, cond, error);
|
||||
if (is != NULL) {
|
||||
ret = dump_input_stream(is);
|
||||
input_stream_close(is);
|
||||
is->Close();
|
||||
} else {
|
||||
if (error.IsDefined())
|
||||
g_warning("%s", error.GetMessage());
|
||||
else
|
||||
g_printerr("input_stream_open() failed\n");
|
||||
g_printerr("input_stream::Open() failed\n");
|
||||
ret = 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ decoder_read(gcc_unused struct decoder *decoder,
|
|||
void *buffer, size_t length)
|
||||
{
|
||||
Error error;
|
||||
return input_stream_lock_read(is, buffer, length, error);
|
||||
return is->LockRead(buffer, length, error);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -185,9 +185,8 @@ int main(int argc, char **argv)
|
|||
Mutex mutex;
|
||||
Cond cond;
|
||||
|
||||
struct input_stream *is =
|
||||
input_stream_open(path, mutex, cond, error);
|
||||
|
||||
input_stream *is = input_stream::Open(path, mutex, cond,
|
||||
error);
|
||||
if (is == NULL) {
|
||||
g_printerr("Failed to open %s: %s\n",
|
||||
path, error.GetMessage());
|
||||
|
@ -196,9 +195,9 @@ int main(int argc, char **argv)
|
|||
|
||||
mutex.lock();
|
||||
|
||||
input_stream_wait_ready(is);
|
||||
is->WaitReady();
|
||||
|
||||
if (!input_stream_check(is, error)) {
|
||||
if (!is->Check(error)) {
|
||||
mutex.unlock();
|
||||
|
||||
g_printerr("Failed to read %s: %s\n",
|
||||
|
@ -210,7 +209,7 @@ int main(int argc, char **argv)
|
|||
|
||||
success = decoder_plugin_scan_stream(plugin, is,
|
||||
&print_handler, NULL);
|
||||
input_stream_close(is);
|
||||
is->Close();
|
||||
}
|
||||
|
||||
decoder_plugin_deinit_all();
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "DecoderList.hxx"
|
||||
#include "DecoderAPI.hxx"
|
||||
#include "InputInit.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "stdbin.h"
|
||||
|
@ -92,8 +92,7 @@ decoder_read(gcc_unused struct decoder *decoder,
|
|||
struct input_stream *is,
|
||||
void *buffer, size_t length)
|
||||
{
|
||||
Error error;
|
||||
return input_stream_lock_read(is, buffer, length, error);
|
||||
return is->LockRead(buffer, length, IgnoreError());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -189,20 +188,20 @@ int main(int argc, char **argv)
|
|||
Mutex mutex;
|
||||
Cond cond;
|
||||
|
||||
struct input_stream *is =
|
||||
input_stream_open(decoder.uri, mutex, cond, error);
|
||||
input_stream *is =
|
||||
input_stream::Open(decoder.uri, mutex, cond, error);
|
||||
if (is == NULL) {
|
||||
if (error.IsDefined())
|
||||
g_warning("%s", error.GetMessage());
|
||||
else
|
||||
g_printerr("input_stream_open() failed\n");
|
||||
g_printerr("input_stream::Open() failed\n");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
decoder_plugin_stream_decode(decoder.plugin, &decoder, is);
|
||||
|
||||
input_stream_close(is);
|
||||
is->Close();
|
||||
} else {
|
||||
g_printerr("Decoder plugin is not usable\n");
|
||||
return 1;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "stdbin.h"
|
||||
#include "Tag.hxx"
|
||||
#include "conf.h"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "InputInit.hxx"
|
||||
#include "IOThread.hxx"
|
||||
|
@ -55,15 +54,15 @@ dump_input_stream(struct input_stream *is)
|
|||
size_t num_read;
|
||||
ssize_t num_written;
|
||||
|
||||
input_stream_lock(is);
|
||||
is->Lock();
|
||||
|
||||
/* wait until the stream becomes ready */
|
||||
|
||||
input_stream_wait_ready(is);
|
||||
is->WaitReady();
|
||||
|
||||
if (!input_stream_check(is, error)) {
|
||||
if (!is->Check(error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
input_stream_unlock(is);
|
||||
is->Unlock();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -74,16 +73,15 @@ dump_input_stream(struct input_stream *is)
|
|||
|
||||
/* read data and tags from the stream */
|
||||
|
||||
while (!input_stream_eof(is)) {
|
||||
Tag *tag = input_stream_tag(is);
|
||||
while (!is->IsEOF()) {
|
||||
Tag *tag = is->ReadTag();
|
||||
if (tag != NULL) {
|
||||
g_printerr("Received a tag:\n");
|
||||
tag_save(stderr, *tag);
|
||||
delete tag;
|
||||
}
|
||||
|
||||
num_read = input_stream_read(is, buffer, sizeof(buffer),
|
||||
error);
|
||||
num_read = is->Read(buffer, sizeof(buffer), error);
|
||||
if (num_read == 0) {
|
||||
if (error.IsDefined())
|
||||
g_warning("%s", error.GetMessage());
|
||||
|
@ -96,13 +94,13 @@ dump_input_stream(struct input_stream *is)
|
|||
break;
|
||||
}
|
||||
|
||||
if (!input_stream_check(is, error)) {
|
||||
if (!is->Check(error)) {
|
||||
g_warning("%s", error.GetMessage());
|
||||
input_stream_unlock(is);
|
||||
is->Unlock();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
input_stream_unlock(is);
|
||||
is->Unlock();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -147,15 +145,15 @@ int main(int argc, char **argv)
|
|||
Mutex mutex;
|
||||
Cond cond;
|
||||
|
||||
is = input_stream_open(argv[1], mutex, cond, error);
|
||||
is = input_stream::Open(argv[1], mutex, cond, error);
|
||||
if (is != NULL) {
|
||||
ret = dump_input_stream(is);
|
||||
input_stream_close(is);
|
||||
is->Close();
|
||||
} else {
|
||||
if (error.IsDefined())
|
||||
g_warning("%s", error.GetMessage());
|
||||
else
|
||||
g_printerr("input_stream_open() failed\n");
|
||||
g_printerr("input_stream::Open() failed\n");
|
||||
ret = 2;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue