Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
7bce6329
Commit
7bce6329
authored
Dec 26, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
archive/File, input/Plugin: return InputStreamPtr
parent
49619fbd
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
60 additions
and
63 deletions
+60
-63
TagArchive.cxx
src/TagArchive.cxx
+2
-2
ArchiveFile.hxx
src/archive/ArchiveFile.hxx
+4
-3
Bzip2ArchivePlugin.cxx
src/archive/plugins/Bzip2ArchivePlugin.cxx
+4
-4
Iso9660ArchivePlugin.cxx
src/archive/plugins/Iso9660ArchivePlugin.cxx
+5
-5
ZzipArchivePlugin.cxx
src/archive/plugins/ZzipArchivePlugin.cxx
+6
-6
InputPlugin.hxx
src/input/InputPlugin.hxx
+4
-2
Open.cxx
src/input/Open.cxx
+2
-4
AlsaInputPlugin.cxx
src/input/plugins/AlsaInputPlugin.cxx
+7
-7
ArchiveInputPlugin.cxx
src/input/plugins/ArchiveInputPlugin.cxx
+2
-2
CdioParanoiaInputPlugin.cxx
src/input/plugins/CdioParanoiaInputPlugin.cxx
+5
-4
CurlInputPlugin.cxx
src/input/plugins/CurlInputPlugin.cxx
+4
-4
FfmpegInputPlugin.cxx
src/input/plugins/FfmpegInputPlugin.cxx
+2
-2
FileInputPlugin.cxx
src/input/plugins/FileInputPlugin.cxx
+4
-4
MmsInputPlugin.cxx
src/input/plugins/MmsInputPlugin.cxx
+2
-2
NfsInputPlugin.cxx
src/input/plugins/NfsInputPlugin.cxx
+3
-9
RewindInputPlugin.cxx
src/input/plugins/RewindInputPlugin.cxx
+1
-1
SmbclientInputPlugin.cxx
src/input/plugins/SmbclientInputPlugin.cxx
+3
-2
No files found.
src/TagArchive.cxx
View file @
7bce6329
...
...
@@ -31,7 +31,7 @@ try {
Mutex
mutex
;
Cond
cond
;
InputStreamPtr
is
(
archive
.
OpenStream
(
path_utf8
,
mutex
,
cond
)
);
auto
is
=
archive
.
OpenStream
(
path_utf8
,
mutex
,
cond
);
if
(
!
is
)
return
false
;
...
...
@@ -47,7 +47,7 @@ try {
Mutex
mutex
;
Cond
cond
;
InputStreamPtr
is
(
archive
.
OpenStream
(
path_utf8
,
mutex
,
cond
)
);
auto
is
=
archive
.
OpenStream
(
path_utf8
,
mutex
,
cond
);
return
is
&&
tag_stream_scan
(
*
is
,
builder
);
}
catch
(
const
std
::
exception
&
e
)
{
return
false
;
...
...
src/archive/ArchiveFile.hxx
View file @
7bce6329
...
...
@@ -20,10 +20,11 @@
#ifndef MPD_ARCHIVE_FILE_HXX
#define MPD_ARCHIVE_FILE_HXX
#include "input/Ptr.hxx"
class
Mutex
;
class
Cond
;
class
ArchiveVisitor
;
class
InputStream
;
class
ArchiveFile
{
public
:
...
...
@@ -41,8 +42,8 @@ public:
*
* @param path the path within the archive
*/
virtual
InputStream
*
OpenStream
(
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
)
=
0
;
virtual
InputStream
Ptr
OpenStream
(
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
)
=
0
;
};
#endif
src/archive/plugins/Bzip2ArchivePlugin.cxx
View file @
7bce6329
...
...
@@ -53,8 +53,8 @@ public:
visitor
.
VisitArchiveEntry
(
name
.
c_str
());
}
InputStream
*
OpenStream
(
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
)
override
;
InputStream
Ptr
OpenStream
(
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
)
override
;
};
class
Bzip2InputStream
final
:
public
InputStream
{
...
...
@@ -127,11 +127,11 @@ Bzip2InputStream::~Bzip2InputStream()
BZ2_bzDecompressEnd
(
&
bzstream
);
}
InputStream
*
InputStream
Ptr
Bzip2ArchiveFile
::
OpenStream
(
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
)
{
return
new
Bzip2InputStream
(
istream
,
path
,
mutex
,
cond
);
return
std
::
make_unique
<
Bzip2InputStream
>
(
istream
,
path
,
mutex
,
cond
);
}
inline
bool
...
...
src/archive/plugins/Iso9660ArchivePlugin.cxx
View file @
7bce6329
...
...
@@ -74,8 +74,8 @@ public:
virtual
void
Visit
(
ArchiveVisitor
&
visitor
)
override
;
InputStream
*
OpenStream
(
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
)
override
;
InputStream
Ptr
OpenStream
(
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
)
override
;
};
/* archive open && listing routine */
...
...
@@ -156,7 +156,7 @@ public:
size_t
Read
(
void
*
ptr
,
size_t
size
)
override
;
};
InputStream
*
InputStream
Ptr
Iso9660ArchiveFile
::
OpenStream
(
const
char
*
pathname
,
Mutex
&
mutex
,
Cond
&
cond
)
{
...
...
@@ -165,8 +165,8 @@ Iso9660ArchiveFile::OpenStream(const char *pathname,
throw
FormatRuntimeError
(
"not found in the ISO file: %s"
,
pathname
);
return
new
Iso9660InputStream
(
iso
,
pathname
,
mutex
,
cond
,
statbuf
);
return
std
::
make_unique
<
Iso9660InputStream
>
(
iso
,
pathname
,
mutex
,
cond
,
statbuf
);
}
size_t
...
...
src/archive/plugins/ZzipArchivePlugin.cxx
View file @
7bce6329
...
...
@@ -59,8 +59,8 @@ public:
virtual
void
Visit
(
ArchiveVisitor
&
visitor
)
override
;
InputStream
*
OpenStream
(
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
)
override
;
InputStream
Ptr
OpenStream
(
const
char
*
path
,
Mutex
&
mutex
,
Cond
&
cond
)
override
;
};
/* archive open && listing routine */
...
...
@@ -116,7 +116,7 @@ public:
void
Seek
(
offset_type
offset
)
override
;
};
InputStream
*
InputStream
Ptr
ZzipArchiveFile
::
OpenStream
(
const
char
*
pathname
,
Mutex
&
mutex
,
Cond
&
cond
)
{
...
...
@@ -125,9 +125,9 @@ ZzipArchiveFile::OpenStream(const char *pathname,
throw
FormatRuntimeError
(
"not found in the ZIP file: %s"
,
pathname
);
return
new
ZzipInputStream
(
dir
,
pathname
,
mutex
,
cond
,
_file
);
return
std
::
make_unique
<
ZzipInputStream
>
(
dir
,
pathname
,
mutex
,
cond
,
_file
);
}
size_t
...
...
src/input/InputPlugin.hxx
View file @
7bce6329
...
...
@@ -20,6 +20,8 @@
#ifndef MPD_INPUT_PLUGIN_HXX
#define MPD_INPUT_PLUGIN_HXX
#include "Ptr.hxx"
struct
ConfigBlock
;
class
Mutex
;
class
Cond
;
...
...
@@ -48,8 +50,8 @@ struct InputPlugin {
/**
* Throws std::runtime_error on error.
*/
InputStream
*
(
*
open
)(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
);
InputStream
Ptr
(
*
open
)(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
);
};
#endif
src/input/Open.cxx
View file @
7bce6329
...
...
@@ -39,11 +39,9 @@ InputStream::Open(const char *url,
}
input_plugins_for_each_enabled
(
plugin
)
{
InputStream
*
is
;
is
=
plugin
->
open
(
url
,
mutex
,
cond
);
auto
is
=
plugin
->
open
(
url
,
mutex
,
cond
);
if
(
is
!=
nullptr
)
return
input_rewind_open
(
InputStreamPtr
(
is
));
return
input_rewind_open
(
std
::
move
(
is
));
}
throw
std
::
runtime_error
(
"Unrecognized URI"
);
...
...
src/input/plugins/AlsaInputPlugin.cxx
View file @
7bce6329
...
...
@@ -110,8 +110,8 @@ public:
snd_pcm_close
(
capture_handle
);
}
static
InputStream
*
Create
(
EventLoop
&
event_loop
,
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
);
static
InputStream
Ptr
Create
(
EventLoop
&
event_loop
,
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
);
protected
:
/* virtual methods from AsyncInputStream */
...
...
@@ -146,7 +146,7 @@ private:
void
DispatchSockets
()
noexcept
override
;
};
inline
InputStream
*
inline
InputStream
Ptr
AlsaInputStream
::
Create
(
EventLoop
&
event_loop
,
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
)
{
...
...
@@ -167,9 +167,9 @@ AlsaInputStream::Create(EventLoop &event_loop, const char *uri,
snd_pcm_t
*
handle
=
OpenDevice
(
device
,
rate
,
format
,
channels
);
int
frame_size
=
snd_pcm_format_width
(
format
)
/
8
*
channels
;
return
new
AlsaInputStream
(
event_loop
,
uri
,
mutex
,
cond
,
device
,
handle
,
frame_size
);
return
std
::
make_unique
<
AlsaInputStream
>
(
event_loop
,
uri
,
mutex
,
cond
,
device
,
handle
,
frame_size
);
}
std
::
chrono
::
steady_clock
::
duration
...
...
@@ -396,7 +396,7 @@ alsa_input_init(EventLoop &event_loop, const ConfigBlock &)
alsa_input_event_loop
=
&
event_loop
;
}
static
InputStream
*
static
InputStream
Ptr
alsa_input_open
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
)
{
return
AlsaInputStream
::
Create
(
*
alsa_input_event_loop
,
uri
,
...
...
src/input/plugins/ArchiveInputPlugin.cxx
View file @
7bce6329
...
...
@@ -66,10 +66,10 @@ OpenArchiveInputStream(Path path, Mutex &mutex, Cond &cond)
delete
file
;
};
return
InputStreamPtr
(
file
->
OpenStream
(
filename
,
mutex
,
cond
)
);
return
file
->
OpenStream
(
filename
,
mutex
,
cond
);
}
static
InputStream
*
static
InputStream
Ptr
input_archive_open
(
gcc_unused
const
char
*
filename
,
gcc_unused
Mutex
&
mutex
,
gcc_unused
Cond
&
cond
)
{
...
...
src/input/plugins/CdioParanoiaInputPlugin.cxx
View file @
7bce6329
...
...
@@ -182,7 +182,7 @@ cdio_detect_device(void)
return
path
;
}
static
InputStream
*
static
InputStream
Ptr
input_cdio_open
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
)
{
...
...
@@ -250,9 +250,10 @@ input_cdio_open(const char *uri,
lsn_to
=
cdio_get_disc_last_lsn
(
cdio
);
}
return
new
CdioParanoiaInputStream
(
uri
,
mutex
,
cond
,
drv
,
cdio
,
reverse_endian
,
lsn_from
,
lsn_to
);
return
std
::
make_unique
<
CdioParanoiaInputStream
>
(
uri
,
mutex
,
cond
,
drv
,
cdio
,
reverse_endian
,
lsn_from
,
lsn_to
);
}
void
...
...
src/input/plugins/CurlInputPlugin.cxx
View file @
7bce6329
...
...
@@ -88,7 +88,7 @@ struct CurlInputStream final : public AsyncInputStream, CurlResponseHandler {
CurlInputStream
(
const
CurlInputStream
&
)
=
delete
;
CurlInputStream
&
operator
=
(
const
CurlInputStream
&
)
=
delete
;
static
InputStream
*
Open
(
const
char
*
url
,
Mutex
&
mutex
,
Cond
&
cond
);
static
InputStream
Ptr
Open
(
const
char
*
url
,
Mutex
&
mutex
,
Cond
&
cond
);
/**
* Create and initialize a new #CurlRequest instance. After
...
...
@@ -435,7 +435,7 @@ CurlInputStream::DoSeek(offset_type new_offset)
});
}
inline
InputStream
*
inline
InputStream
Ptr
CurlInputStream
::
Open
(
const
char
*
url
,
Mutex
&
mutex
,
Cond
&
cond
)
{
auto
c
=
std
::
make_unique
<
CurlInputStream
>
((
*
curl_init
)
->
GetEventLoop
(),
...
...
@@ -447,10 +447,10 @@ CurlInputStream::Open(const char *url, Mutex &mutex, Cond &cond)
});
auto
icy
=
c
->
icy
;
return
new
IcyInputStream
(
std
::
move
(
c
),
std
::
move
(
icy
));
return
std
::
make_unique
<
IcyInputStream
>
(
std
::
move
(
c
),
std
::
move
(
icy
));
}
static
InputStream
*
static
InputStream
Ptr
input_curl_open
(
const
char
*
url
,
Mutex
&
mutex
,
Cond
&
cond
)
{
if
(
strncmp
(
url
,
"http://"
,
7
)
!=
0
&&
...
...
src/input/plugins/FfmpegInputPlugin.cxx
View file @
7bce6329
...
...
@@ -81,7 +81,7 @@ input_ffmpeg_init(EventLoop &, const ConfigBlock &)
throw
PluginUnavailable
(
"No protocol"
);
}
static
InputStream
*
static
InputStream
Ptr
input_ffmpeg_open
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
)
{
...
...
@@ -98,7 +98,7 @@ input_ffmpeg_open(const char *uri,
if
(
result
!=
0
)
throw
MakeFfmpegError
(
result
);
return
new
FfmpegInputStream
(
uri
,
mutex
,
cond
,
h
);
return
std
::
make_unique
<
FfmpegInputStream
>
(
uri
,
mutex
,
cond
,
h
);
}
size_t
...
...
src/input/plugins/FileInputPlugin.cxx
View file @
7bce6329
...
...
@@ -70,12 +70,12 @@ OpenFileInputStream(Path path,
POSIX_FADV_SEQUENTIAL
);
#endif
return
InputStreamPtr
(
new
FileInputStream
(
path
.
ToUTF8
().
c_str
(),
std
::
move
(
reader
),
info
.
GetSize
(),
mutex
,
cond
)
);
return
std
::
make_unique
<
FileInputStream
>
(
path
.
ToUTF8
().
c_str
(),
std
::
move
(
reader
),
info
.
GetSize
(),
mutex
,
cond
);
}
static
InputStream
*
static
InputStream
Ptr
input_file_open
(
gcc_unused
const
char
*
filename
,
gcc_unused
Mutex
&
mutex
,
gcc_unused
Cond
&
cond
)
{
...
...
src/input/plugins/MmsInputPlugin.cxx
View file @
7bce6329
...
...
@@ -66,7 +66,7 @@ MmsInputStream::Open()
SetMimeType
(
"audio/x-ms-wma"
);
}
static
InputStream
*
static
InputStream
Ptr
input_mms_open
(
const
char
*
url
,
Mutex
&
mutex
,
Cond
&
cond
)
{
...
...
@@ -76,7 +76,7 @@ input_mms_open(const char *url,
!
StringStartsWith
(
url
,
"mmsu://"
))
return
nullptr
;
auto
m
=
new
MmsInputStream
(
url
,
mutex
,
cond
);
auto
m
=
std
::
make_unique
<
MmsInputStream
>
(
url
,
mutex
,
cond
);
m
->
Start
();
return
m
;
}
...
...
src/input/plugins/NfsInputPlugin.cxx
View file @
7bce6329
...
...
@@ -216,21 +216,15 @@ input_nfs_finish() noexcept
nfs_finish
();
}
static
InputStream
*
static
InputStream
Ptr
input_nfs_open
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
)
{
if
(
!
StringStartsWith
(
uri
,
"nfs://"
))
return
nullptr
;
NfsInputStream
*
is
=
new
NfsInputStream
(
uri
,
mutex
,
cond
);
try
{
is
->
Open
();
}
catch
(...)
{
delete
is
;
throw
;
}
auto
is
=
std
::
make_unique
<
NfsInputStream
>
(
uri
,
mutex
,
cond
);
is
->
Open
();
return
is
;
}
...
...
src/input/plugins/RewindInputPlugin.cxx
View file @
7bce6329
...
...
@@ -147,5 +147,5 @@ input_rewind_open(InputStreamPtr is)
/* seekable resources don't need this plugin */
return
is
;
return
InputStreamPtr
(
new
RewindInputStream
(
std
::
move
(
is
)
));
return
std
::
make_unique
<
RewindInputStream
>
(
std
::
move
(
is
));
}
src/input/plugins/SmbclientInputPlugin.cxx
View file @
7bce6329
...
...
@@ -83,7 +83,7 @@ input_smbclient_init(EventLoop &, const ConfigBlock &)
// TODO: evaluate ConfigBlock, call smbc_setOption*()
}
static
InputStream
*
static
InputStream
Ptr
input_smbclient_open
(
const
char
*
uri
,
Mutex
&
mutex
,
Cond
&
cond
)
{
...
...
@@ -119,7 +119,8 @@ input_smbclient_open(const char *uri,
throw
MakeErrno
(
e
,
"smbc_fstat() failed"
);
}
return
new
SmbclientInputStream
(
uri
,
mutex
,
cond
,
ctx
,
fd
,
st
);
return
std
::
make_unique
<
SmbclientInputStream
>
(
uri
,
mutex
,
cond
,
ctx
,
fd
,
st
);
}
size_t
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment