InputStream: convert to class
This commit is contained in:
@@ -96,8 +96,9 @@ public:
|
||||
/* this mime type forces use of the PcmDecoderPlugin.
|
||||
Needs to be generalised when/if that decoder is
|
||||
updated to support other audio formats */
|
||||
base.mime = "audio/x-mpd-cdda-pcm";
|
||||
base.ready = true;
|
||||
base.SetMimeType("audio/x-mpd-cdda-pcm");
|
||||
base.SetReady();
|
||||
|
||||
frames_to_read = read_buffer_size / frame_size;
|
||||
|
||||
snd_pcm_start(capture_handle);
|
||||
|
||||
@@ -269,9 +269,9 @@ input_cdio_open(const char *uri,
|
||||
i->base.size = (i->lsn_to - i->lsn_from + 1) * CDIO_CD_FRAMESIZE_RAW;
|
||||
|
||||
/* hack to make MPD select the "pcm" decoder plugin */
|
||||
i->base.mime = reverse_endian
|
||||
? "audio/x-mpd-cdda-pcm-reverse"
|
||||
: "audio/x-mpd-cdda-pcm";
|
||||
i->base.SetMimeType(reverse_endian
|
||||
? "audio/x-mpd-cdda-pcm-reverse"
|
||||
: "audio/x-mpd-cdda-pcm");
|
||||
|
||||
return &i->base;
|
||||
}
|
||||
|
||||
@@ -497,8 +497,7 @@ CurlInputStream::RequestDone(CURLcode result, long status)
|
||||
status);
|
||||
}
|
||||
|
||||
base.ready = true;
|
||||
base.cond.broadcast();
|
||||
base.SetReady();
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -833,7 +832,7 @@ CurlInputStream::HeaderReceived(const char *name, std::string &&value)
|
||||
} else if (StringEqualsCaseASCII(name, "content-length")) {
|
||||
base.size = base.offset + ParseUint64(value.c_str());
|
||||
} else if (StringEqualsCaseASCII(name, "content-type")) {
|
||||
base.mime = std::move(value);
|
||||
base.SetMimeType(std::move(value));
|
||||
} else if (StringEqualsCaseASCII(name, "icy-name") ||
|
||||
StringEqualsCaseASCII(name, "ice-name") ||
|
||||
StringEqualsCaseASCII(name, "x-audiocast-name")) {
|
||||
@@ -987,7 +986,7 @@ CurlInputStream::InitEasy(Error &error)
|
||||
curl_easy_setopt(easy, CURLOPT_PROXYUSERPWD, proxy_auth_str);
|
||||
}
|
||||
|
||||
CURLcode code = curl_easy_setopt(easy, CURLOPT_URL, base.uri.c_str());
|
||||
CURLcode code = curl_easy_setopt(easy, CURLOPT_URL, base.GetURI());
|
||||
if (code != CURLE_OK) {
|
||||
error.Format(curl_domain, code,
|
||||
"curl_easy_setopt() failed: %s",
|
||||
@@ -1091,9 +1090,7 @@ CurlInputStream::Seek(InputPlugin::offset_type offset, int whence,
|
||||
return false;
|
||||
|
||||
base.mutex.lock();
|
||||
|
||||
while (!base.ready)
|
||||
base.cond.wait(base.mutex);
|
||||
base.WaitReady();
|
||||
|
||||
if (postponed_error.IsDefined()) {
|
||||
error = std::move(postponed_error);
|
||||
|
||||
@@ -58,8 +58,8 @@ class DespotifyInputStream {
|
||||
memset(&pcm, 0, sizeof(pcm));
|
||||
|
||||
/* Despotify outputs pcm data */
|
||||
base.mime = "audio/x-mpd-cdda-pcm";
|
||||
base.ready = true;
|
||||
base.SetMimeType("audio/x-mpd-cdda-pcm");
|
||||
base.SetReady();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -52,7 +52,7 @@ struct FfmpegInputStream {
|
||||
- since avio.h doesn't tell us the MIME type of the
|
||||
resource, we can't select a decoder plugin, but the
|
||||
"ffmpeg" plugin is quite good at auto-detection */
|
||||
base.mime = "audio/x-mpd-ffmpeg";
|
||||
base.SetMimeType("audio/x-mpd-ffmpeg");
|
||||
}
|
||||
|
||||
~FfmpegInputStream() {
|
||||
|
||||
@@ -44,7 +44,7 @@ struct FileInputStream {
|
||||
fd(_fd) {
|
||||
base.size = size;
|
||||
base.seekable = true;
|
||||
base.ready = true;
|
||||
base.SetReady();
|
||||
}
|
||||
|
||||
~FileInputStream() {
|
||||
@@ -138,7 +138,7 @@ input_file_close(InputStream *is)
|
||||
static bool
|
||||
input_file_eof(InputStream *is)
|
||||
{
|
||||
return is->offset >= is->size;
|
||||
return is->GetOffset() >= is->GetSize();
|
||||
}
|
||||
|
||||
const InputPlugin input_plugin_file = {
|
||||
|
||||
@@ -55,7 +55,7 @@ struct RewindInputStream {
|
||||
char buffer[64 * 1024];
|
||||
|
||||
RewindInputStream(InputStream *_input)
|
||||
:base(rewind_input_plugin, _input->uri.c_str(),
|
||||
:base(rewind_input_plugin, _input->GetURI(),
|
||||
_input->mutex, _input->cond),
|
||||
input(_input), tail(0) {
|
||||
}
|
||||
@@ -84,15 +84,16 @@ struct RewindInputStream {
|
||||
|
||||
assert(dest != src);
|
||||
|
||||
bool dest_ready = dest->ready;
|
||||
if (!dest->IsReady() && src->IsReady()) {
|
||||
if (src->HasMimeType())
|
||||
dest->SetMimeType(src->GetMimeType());
|
||||
|
||||
dest->size = src->GetSize();
|
||||
dest->seekable = src->IsSeekable();
|
||||
dest->SetReady();
|
||||
}
|
||||
|
||||
dest->ready = src->ready;
|
||||
dest->seekable = src->seekable;
|
||||
dest->size = src->size;
|
||||
dest->offset = src->offset;
|
||||
|
||||
if (!dest_ready && src->ready)
|
||||
dest->mime = src->mime;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -195,7 +196,7 @@ input_rewind_seek(InputStream *is, InputPlugin::offset_type offset,
|
||||
{
|
||||
RewindInputStream *r = (RewindInputStream *)is;
|
||||
|
||||
assert(is->ready);
|
||||
assert(is->IsReady());
|
||||
|
||||
if (whence == SEEK_SET && r->tail > 0 &&
|
||||
offset <= (InputPlugin::offset_type)r->tail) {
|
||||
@@ -242,7 +243,7 @@ input_rewind_open(InputStream *is)
|
||||
assert(is != nullptr);
|
||||
assert(is->offset == 0);
|
||||
|
||||
if (is->seekable)
|
||||
if (is->IsReady() && is->IsSeekable())
|
||||
/* seekable resources don't need this plugin */
|
||||
return is;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#include "check.h"
|
||||
|
||||
struct InputStream;
|
||||
class InputStream;
|
||||
|
||||
InputStream *
|
||||
input_rewind_open(InputStream *is);
|
||||
|
||||
Reference in New Issue
Block a user