InputLegacy: move functions to the input_stream class
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user