aboutsummaryrefslogtreecommitdiffstats
path: root/src/input/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/input/plugins')
-rw-r--r--src/input/plugins/AlsaInputPlugin.cxx2
-rw-r--r--src/input/plugins/AlsaInputPlugin.hxx2
-rw-r--r--src/input/plugins/ArchiveInputPlugin.cxx2
-rw-r--r--src/input/plugins/ArchiveInputPlugin.hxx2
-rw-r--r--src/input/plugins/CdioParanoiaInputPlugin.cxx11
-rw-r--r--src/input/plugins/CdioParanoiaInputPlugin.hxx2
-rw-r--r--src/input/plugins/CurlInputPlugin.cxx29
-rw-r--r--src/input/plugins/CurlInputPlugin.hxx2
-rw-r--r--src/input/plugins/FfmpegInputPlugin.cxx8
-rw-r--r--src/input/plugins/FfmpegInputPlugin.hxx2
-rw-r--r--src/input/plugins/FileInputPlugin.cxx57
-rw-r--r--src/input/plugins/FileInputPlugin.hxx2
-rw-r--r--src/input/plugins/MmsInputPlugin.cxx2
-rw-r--r--src/input/plugins/MmsInputPlugin.hxx2
-rw-r--r--src/input/plugins/NfsInputPlugin.cxx8
-rw-r--r--src/input/plugins/NfsInputPlugin.hxx2
-rw-r--r--src/input/plugins/RewindInputPlugin.cxx2
-rw-r--r--src/input/plugins/RewindInputPlugin.hxx2
-rw-r--r--src/input/plugins/SmbclientInputPlugin.cxx6
-rw-r--r--src/input/plugins/SmbclientInputPlugin.hxx2
20 files changed, 66 insertions, 81 deletions
diff --git a/src/input/plugins/AlsaInputPlugin.cxx b/src/input/plugins/AlsaInputPlugin.cxx
index f03f745c6..d2be734b5 100644
--- a/src/input/plugins/AlsaInputPlugin.cxx
+++ b/src/input/plugins/AlsaInputPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/input/plugins/AlsaInputPlugin.hxx b/src/input/plugins/AlsaInputPlugin.hxx
index dddf7dfd7..eb50ec8d6 100644
--- a/src/input/plugins/AlsaInputPlugin.hxx
+++ b/src/input/plugins/AlsaInputPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/input/plugins/ArchiveInputPlugin.cxx b/src/input/plugins/ArchiveInputPlugin.cxx
index da3d7ca71..b6472e00a 100644
--- a/src/input/plugins/ArchiveInputPlugin.cxx
+++ b/src/input/plugins/ArchiveInputPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/input/plugins/ArchiveInputPlugin.hxx b/src/input/plugins/ArchiveInputPlugin.hxx
index b6158684a..79331cd5a 100644
--- a/src/input/plugins/ArchiveInputPlugin.hxx
+++ b/src/input/plugins/ArchiveInputPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/input/plugins/CdioParanoiaInputPlugin.cxx b/src/input/plugins/CdioParanoiaInputPlugin.cxx
index f847b35c1..dda5cb83f 100644
--- a/src/input/plugins/CdioParanoiaInputPlugin.cxx
+++ b/src/input/plugins/CdioParanoiaInputPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -31,7 +31,7 @@
#include "system/ByteOrder.hxx"
#include "fs/AllocatedPath.hxx"
#include "Log.hxx"
-#include "config/ConfigData.hxx"
+#include "config/Block.hxx"
#include "config/ConfigError.hxx"
#include <stdio.h>
@@ -39,7 +39,6 @@
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
-#include <glib.h>
#include <assert.h>
#ifdef HAVE_CDIO_PARANOIA_PARANOIA_H
@@ -107,9 +106,9 @@ static constexpr Domain cdio_domain("cdio");
static bool default_reverse_endian;
static InputPlugin::InitResult
-input_cdio_init(const config_param &param, Error &error)
+input_cdio_init(const ConfigBlock &block, Error &error)
{
- const char *value = param.GetBlockValue("default_byte_order");
+ const char *value = block.GetBlockValue("default_byte_order");
if (value != nullptr) {
if (strcmp(value, "little_endian") == 0)
default_reverse_endian = IsBigEndian();
@@ -149,7 +148,7 @@ parse_cdio_uri(struct cdio_uri *dest, const char *src, Error &error)
const char *slash = strrchr(src, '/');
if (slash == nullptr) {
/* play the whole CD in the specified drive */
- g_strlcpy(dest->device, src, sizeof(dest->device));
+ CopyString(dest->device, src, sizeof(dest->device));
dest->track = -1;
return true;
}
diff --git a/src/input/plugins/CdioParanoiaInputPlugin.hxx b/src/input/plugins/CdioParanoiaInputPlugin.hxx
index e2804e8c7..a51b43827 100644
--- a/src/input/plugins/CdioParanoiaInputPlugin.hxx
+++ b/src/input/plugins/CdioParanoiaInputPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/input/plugins/CurlInputPlugin.cxx b/src/input/plugins/CurlInputPlugin.cxx
index 3aa3b0018..ade8324ec 100644
--- a/src/input/plugins/CurlInputPlugin.cxx
+++ b/src/input/plugins/CurlInputPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -23,7 +23,7 @@
#include "../IcyInputStream.hxx"
#include "../InputPlugin.hxx"
#include "config/ConfigGlobal.hxx"
-#include "config/ConfigData.hxx"
+#include "config/Block.hxx"
#include "tag/Tag.hxx"
#include "tag/TagBuilder.hxx"
#include "event/SocketMonitor.hxx"
@@ -537,7 +537,7 @@ CurlMulti::OnTimeout()
*/
static InputPlugin::InitResult
-input_curl_init(const config_param &param, Error &error)
+input_curl_init(const ConfigBlock &block, Error &error)
{
CURLcode code = curl_global_init(CURL_GLOBAL_ALL);
if (code != CURLE_OK) {
@@ -559,22 +559,22 @@ input_curl_init(const config_param &param, Error &error)
http_200_aliases = curl_slist_append(http_200_aliases, "ICY 200 OK");
- proxy = param.GetBlockValue("proxy");
- proxy_port = param.GetBlockValue("proxy_port", 0u);
- proxy_user = param.GetBlockValue("proxy_user");
- proxy_password = param.GetBlockValue("proxy_password");
+ proxy = block.GetBlockValue("proxy");
+ proxy_port = block.GetBlockValue("proxy_port", 0u);
+ proxy_user = block.GetBlockValue("proxy_user");
+ proxy_password = block.GetBlockValue("proxy_password");
if (proxy == nullptr) {
/* deprecated proxy configuration */
- proxy = config_get_string(CONF_HTTP_PROXY_HOST, nullptr);
- proxy_port = config_get_positive(CONF_HTTP_PROXY_PORT, 0);
- proxy_user = config_get_string(CONF_HTTP_PROXY_USER, nullptr);
- proxy_password = config_get_string(CONF_HTTP_PROXY_PASSWORD,
+ proxy = config_get_string(ConfigOption::HTTP_PROXY_HOST, nullptr);
+ proxy_port = config_get_positive(ConfigOption::HTTP_PROXY_PORT, 0);
+ proxy_user = config_get_string(ConfigOption::HTTP_PROXY_USER, nullptr);
+ proxy_password = config_get_string(ConfigOption::HTTP_PROXY_PASSWORD,
"");
}
- verify_peer = param.GetBlockValue("verify_peer", true);
- verify_host = param.GetBlockValue("verify_host", true);
+ verify_peer = block.GetBlockValue("verify_peer", true);
+ verify_host = block.GetBlockValue("verify_host", true);
CURLM *multi = curl_multi_init();
if (multi == nullptr) {
@@ -651,7 +651,10 @@ CurlInputStream::HeaderReceived(const char *name, std::string &&value)
return;
size_t icy_metaint = ParseUint64(value.c_str());
+#ifndef WIN32
+ /* Windows doesn't know "%z" */
FormatDebug(curl_domain, "icy-metaint=%zu", icy_metaint);
+#endif
if (icy_metaint > 0) {
icy->Enable(icy_metaint);
diff --git a/src/input/plugins/CurlInputPlugin.hxx b/src/input/plugins/CurlInputPlugin.hxx
index 4acb18bfc..57bbe714b 100644
--- a/src/input/plugins/CurlInputPlugin.hxx
+++ b/src/input/plugins/CurlInputPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/input/plugins/FfmpegInputPlugin.cxx b/src/input/plugins/FfmpegInputPlugin.cxx
index 669f8d403..444273d90 100644
--- a/src/input/plugins/FfmpegInputPlugin.cxx
+++ b/src/input/plugins/FfmpegInputPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -22,6 +22,7 @@
#include "config.h"
#include "FfmpegInputPlugin.hxx"
+#include "lib/ffmpeg/Init.hxx"
#include "lib/ffmpeg/Domain.hxx"
#include "lib/ffmpeg/Error.hxx"
#include "../InputStream.hxx"
@@ -31,7 +32,6 @@
extern "C" {
#include <libavformat/avio.h>
-#include <libavformat/avformat.h>
}
struct FfmpegInputStream final : public InputStream {
@@ -72,10 +72,10 @@ input_ffmpeg_supported(void)
}
static InputPlugin::InitResult
-input_ffmpeg_init(gcc_unused const config_param &param,
+input_ffmpeg_init(gcc_unused const ConfigBlock &block,
Error &error)
{
- av_register_all();
+ FfmpegInit();
/* disable this plugin if there's no registered protocol */
if (!input_ffmpeg_supported()) {
diff --git a/src/input/plugins/FfmpegInputPlugin.hxx b/src/input/plugins/FfmpegInputPlugin.hxx
index 43f829e89..40a834bdc 100644
--- a/src/input/plugins/FfmpegInputPlugin.hxx
+++ b/src/input/plugins/FfmpegInputPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/input/plugins/FileInputPlugin.cxx b/src/input/plugins/FileInputPlugin.cxx
index 867b5722d..aa4676470 100644
--- a/src/input/plugins/FileInputPlugin.cxx
+++ b/src/input/plugins/FileInputPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -23,34 +23,30 @@
#include "../InputPlugin.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
-#include "fs/FileSystem.hxx"
#include "fs/Path.hxx"
-#include "system/fd_util.h"
-#include "open.h"
+#include "fs/FileInfo.hxx"
+#include "fs/io/FileReader.hxx"
+#include "system/FileDescriptor.hxx"
#include <sys/stat.h>
-#include <unistd.h>
+#include <fcntl.h>
#include <errno.h>
static constexpr Domain file_domain("file");
class FileInputStream final : public InputStream {
- const int fd;
+ FileReader reader;
public:
- FileInputStream(const char *path, int _fd, off_t _size,
+ FileInputStream(const char *path, FileReader &&_reader, off_t _size,
Mutex &_mutex, Cond &_cond)
:InputStream(path, _mutex, _cond),
- fd(_fd) {
+ reader(std::move(_reader)) {
size = _size;
seekable = true;
SetReady();
}
- ~FileInputStream() {
- close(fd);
- }
-
/* virtual methods from InputStream */
bool IsEOF() override {
@@ -66,32 +62,28 @@ OpenFileInputStream(Path path,
Mutex &mutex, Cond &cond,
Error &error)
{
- const int fd = OpenFile(path, O_RDONLY|O_BINARY, 0);
- if (fd < 0) {
- error.FormatErrno("Failed to open \"%s\"",
- path.c_str());
+ FileReader reader(path, error);
+ if (!reader.IsDefined())
return nullptr;
- }
- struct stat st;
- if (fstat(fd, &st) < 0) {
- error.FormatErrno("Failed to stat \"%s\"", path.c_str());
- close(fd);
+ FileInfo info;
+ if (!reader.GetFileInfo(info, error))
return nullptr;
- }
- if (!S_ISREG(st.st_mode)) {
+ if (!info.IsRegular()) {
error.Format(file_domain, "Not a regular file: %s",
path.c_str());
- close(fd);
return nullptr;
}
#ifdef POSIX_FADV_SEQUENTIAL
- posix_fadvise(fd, (off_t)0, st.st_size, POSIX_FADV_SEQUENTIAL);
+ posix_fadvise(reader.GetFD().Get(), (off_t)0, info.GetSize(),
+ POSIX_FADV_SEQUENTIAL);
#endif
- return new FileInputStream(path.c_str(), fd, st.st_size, mutex, cond);
+ return new FileInputStream(path.ToUTF8().c_str(),
+ std::move(reader), info.GetSize(),
+ mutex, cond);
}
static InputStream *
@@ -107,24 +99,19 @@ input_file_open(gcc_unused const char *filename,
bool
FileInputStream::Seek(offset_type new_offset, Error &error)
{
- auto result = lseek(fd, (off_t)new_offset, SEEK_SET);
- if (result < 0) {
- error.SetErrno("Failed to seek");
+ if (!reader.Seek((off_t)new_offset, error))
return false;
- }
- offset = (offset_type)result;
+ offset = new_offset;
return true;
}
size_t
FileInputStream::Read(void *ptr, size_t read_size, Error &error)
{
- ssize_t nbytes = read(fd, ptr, read_size);
- if (nbytes < 0) {
- error.SetErrno("Failed to read");
+ ssize_t nbytes = reader.Read(ptr, read_size, error);
+ if (nbytes < 0)
return 0;
- }
offset += nbytes;
return (size_t)nbytes;
diff --git a/src/input/plugins/FileInputPlugin.hxx b/src/input/plugins/FileInputPlugin.hxx
index ee194ec34..a00401c53 100644
--- a/src/input/plugins/FileInputPlugin.hxx
+++ b/src/input/plugins/FileInputPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/input/plugins/MmsInputPlugin.cxx b/src/input/plugins/MmsInputPlugin.cxx
index d01cff3b3..244dfd945 100644
--- a/src/input/plugins/MmsInputPlugin.cxx
+++ b/src/input/plugins/MmsInputPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/input/plugins/MmsInputPlugin.hxx b/src/input/plugins/MmsInputPlugin.hxx
index b4017ffd6..cf1b9ba65 100644
--- a/src/input/plugins/MmsInputPlugin.hxx
+++ b/src/input/plugins/MmsInputPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/input/plugins/NfsInputPlugin.cxx b/src/input/plugins/NfsInputPlugin.cxx
index c6c0970b9..077362c18 100644
--- a/src/input/plugins/NfsInputPlugin.cxx
+++ b/src/input/plugins/NfsInputPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -28,10 +28,6 @@
#include "util/StringUtil.hxx"
#include "util/Error.hxx"
-extern "C" {
-#include <nfsc/libnfs.h>
-}
-
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -225,7 +221,7 @@ NfsInputStream::OnNfsFileError(Error &&error)
*/
static InputPlugin::InitResult
-input_nfs_init(const config_param &, Error &)
+input_nfs_init(const ConfigBlock &, Error &)
{
nfs_init();
return InputPlugin::InitResult::SUCCESS;
diff --git a/src/input/plugins/NfsInputPlugin.hxx b/src/input/plugins/NfsInputPlugin.hxx
index d2cc87549..5420ec967 100644
--- a/src/input/plugins/NfsInputPlugin.hxx
+++ b/src/input/plugins/NfsInputPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/input/plugins/RewindInputPlugin.cxx b/src/input/plugins/RewindInputPlugin.cxx
index 95f604044..cd027299c 100644
--- a/src/input/plugins/RewindInputPlugin.cxx
+++ b/src/input/plugins/RewindInputPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/input/plugins/RewindInputPlugin.hxx b/src/input/plugins/RewindInputPlugin.hxx
index 56b01b585..099921e7a 100644
--- a/src/input/plugins/RewindInputPlugin.hxx
+++ b/src/input/plugins/RewindInputPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
diff --git a/src/input/plugins/SmbclientInputPlugin.cxx b/src/input/plugins/SmbclientInputPlugin.cxx
index 399613720..ec6857c19 100644
--- a/src/input/plugins/SmbclientInputPlugin.cxx
+++ b/src/input/plugins/SmbclientInputPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -66,14 +66,14 @@ public:
*/
static InputPlugin::InitResult
-input_smbclient_init(gcc_unused const config_param &param, Error &error)
+input_smbclient_init(gcc_unused const ConfigBlock &block, Error &error)
{
if (!SmbclientInit(error))
return InputPlugin::InitResult::UNAVAILABLE;
// TODO: create one global SMBCCTX here?
- // TODO: evaluate config_param, call smbc_setOption*()
+ // TODO: evaluate ConfigBlock, call smbc_setOption*()
return InputPlugin::InitResult::SUCCESS;
}
diff --git a/src/input/plugins/SmbclientInputPlugin.hxx b/src/input/plugins/SmbclientInputPlugin.hxx
index a0539d020..31c55196c 100644
--- a/src/input/plugins/SmbclientInputPlugin.hxx
+++ b/src/input/plugins/SmbclientInputPlugin.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify