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
7d0269d2
Commit
7d0269d2
authored
Sep 05, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InputLegacy: move functions to the input_stream class
parent
52ffdb0a
Hide whitespace changes
Inline
Side-by-side
Showing
47 changed files
with
458 additions
and
605 deletions
+458
-605
Makefile.am
Makefile.am
+0
-1
DecoderAPI.cxx
src/DecoderAPI.cxx
+7
-7
DecoderAPI.hxx
src/DecoderAPI.hxx
+0
-1
DecoderThread.cxx
src/DecoderThread.cxx
+8
-11
InputLegacy.hxx
src/InputLegacy.hxx
+0
-225
InputPlugin.hxx
src/InputPlugin.hxx
+5
-1
InputStream.cxx
src/InputStream.cxx
+51
-119
InputStream.hxx
src/InputStream.hxx
+184
-15
PlaylistAny.cxx
src/PlaylistAny.cxx
+3
-3
PlaylistPrint.cxx
src/PlaylistPrint.cxx
+2
-2
PlaylistQueue.cxx
src/PlaylistQueue.cxx
+2
-2
PlaylistRegistry.cxx
src/PlaylistRegistry.cxx
+8
-10
SongUpdate.cxx
src/SongUpdate.cxx
+7
-10
TagFile.cxx
src/TagFile.cxx
+5
-6
TextInputStream.cxx
src/TextInputStream.cxx
+2
-3
Bzip2ArchivePlugin.cxx
src/archive/Bzip2ArchivePlugin.cxx
+4
-5
AudiofileDecoderPlugin.cxx
src/decoder/AudiofileDecoderPlugin.cxx
+8
-7
DsdLib.cxx
src/decoder/DsdLib.cxx
+12
-11
DsdiffDecoderPlugin.cxx
src/decoder/DsdiffDecoderPlugin.cxx
+12
-12
DsfDecoderPlugin.cxx
src/decoder/DsfDecoderPlugin.cxx
+2
-1
FaadDecoderPlugin.cxx
src/decoder/FaadDecoderPlugin.cxx
+5
-5
FfmpegDecoderPlugin.cxx
src/decoder/FfmpegDecoderPlugin.cxx
+2
-3
FlacDecoderPlugin.cxx
src/decoder/FlacDecoderPlugin.cxx
+1
-1
FlacIOHandle.cxx
src/decoder/FlacIOHandle.cxx
+3
-3
FlacInput.cxx
src/decoder/FlacInput.cxx
+3
-5
MadDecoderPlugin.cxx
src/decoder/MadDecoderPlugin.cxx
+7
-8
ModplugDecoderPlugin.cxx
src/decoder/ModplugDecoderPlugin.cxx
+4
-3
MpcdecDecoderPlugin.cxx
src/decoder/MpcdecDecoderPlugin.cxx
+6
-6
OpusDecoderPlugin.cxx
src/decoder/OpusDecoderPlugin.cxx
+3
-3
PcmDecoderPlugin.cxx
src/decoder/PcmDecoderPlugin.cxx
+6
-6
SndfileDecoderPlugin.cxx
src/decoder/SndfileDecoderPlugin.cxx
+6
-5
VorbisDecoderPlugin.cxx
src/decoder/VorbisDecoderPlugin.cxx
+3
-3
WavpackDecoderPlugin.cxx
src/decoder/WavpackDecoderPlugin.cxx
+5
-10
CurlInputPlugin.cxx
src/input/CurlInputPlugin.cxx
+1
-1
RewindInputPlugin.cxx
src/input/RewindInputPlugin.cxx
+7
-8
AsxPlaylistPlugin.cxx
src/playlist/AsxPlaylistPlugin.cxx
+2
-3
CuePlaylistPlugin.cxx
src/playlist/CuePlaylistPlugin.cxx
+0
-1
LastFMPlaylistPlugin.cxx
src/playlist/LastFMPlaylistPlugin.cxx
+13
-13
PlsPlaylistPlugin.cxx
src/playlist/PlsPlaylistPlugin.cxx
+2
-3
RssPlaylistPlugin.cxx
src/playlist/RssPlaylistPlugin.cxx
+2
-3
SoundCloudPlaylistPlugin.cxx
src/playlist/SoundCloudPlaylistPlugin.cxx
+8
-9
XspfPlaylistPlugin.cxx
src/playlist/XspfPlaylistPlugin.cxx
+2
-3
dump_playlist.cxx
test/dump_playlist.cxx
+7
-7
dump_text_file.cxx
test/dump_text_file.cxx
+13
-12
read_tags.cxx
test/read_tags.cxx
+6
-7
run_decoder.cxx
test/run_decoder.cxx
+6
-7
run_input.cxx
test/run_input.cxx
+13
-15
No files found.
Makefile.am
View file @
7d0269d2
...
...
@@ -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
\
...
...
src/DecoderAPI.cxx
View file @
7d0269d2
...
...
@@ -268,29 +268,29 @@ size_t decoder_read(struct decoder *decoder,
if
(
length
==
0
)
return
0
;
i
nput_stream_lock
(
is
);
i
s
->
Lock
(
);
while
(
true
)
{
if
(
decoder_check_cancel_read
(
decoder
))
{
i
nput_stream_unlock
(
is
);
i
s
->
Unlock
(
);
return
0
;
}
if
(
i
nput_stream_available
(
is
))
if
(
i
s
->
IsAvailable
(
))
break
;
is
->
cond
.
wait
(
is
->
mutex
);
}
Error
error
;
size_t
nbytes
=
i
nput_stream_read
(
is
,
buffer
,
length
,
error
);
size_t
nbytes
=
i
s
->
Read
(
buffer
,
length
,
error
);
assert
(
nbytes
==
0
||
!
error
.
IsDefined
());
assert
(
nbytes
>
0
||
error
.
IsDefined
()
||
i
nput_stream_eof
(
is
));
assert
(
nbytes
>
0
||
error
.
IsDefined
()
||
i
s
->
IsEOF
(
));
if
(
gcc_unlikely
(
nbytes
==
0
&&
error
.
IsDefined
()))
g_warning
(
"%s"
,
error
.
GetMessage
());
i
nput_stream_unlock
(
is
);
i
s
->
Unlock
(
);
return
nbytes
;
}
...
...
@@ -338,7 +338,7 @@ update_stream_tag(struct decoder *decoder, struct input_stream *is)
Tag
*
tag
;
tag
=
is
!=
NULL
?
i
nput_stream_lock_tag
(
is
)
?
i
s
->
LockReadTag
(
)
:
NULL
;
if
(
tag
==
NULL
)
{
tag
=
decoder
->
song_tag
;
...
...
src/DecoderAPI.hxx
View file @
7d0269d2
...
...
@@ -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"
...
...
src/DecoderThread.cxx
View file @
7d0269d2
...
...
@@ -60,7 +60,7 @@ decoder_command_finished_locked(struct decoder_control *dc)
}
/**
* Opens the input stream with input_stream
_o
pen(), and waits until
* Opens the input stream with input_stream
::O
pen(), 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
_o
pen
(
uri
,
dc
->
mutex
,
dc
->
cond
,
error
);
input_stream
*
is
=
input_stream
::
O
pen
(
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
();
i
nput_stream_update
(
is
);
i
s
->
Update
(
);
while
(
!
is
->
ready
&&
dc
->
command
!=
DECODE_COMMAND_STOP
)
{
dc
->
Wait
();
i
nput_stream_update
(
is
);
i
s
->
Update
(
);
}
if
(
!
i
nput_stream_check
(
is
,
error
))
{
if
(
!
i
s
->
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
();
...
...
src/InputLegacy.hxx
deleted
100644 → 0
View file @
52ffdb0a
/*
* 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
src/InputPlugin.hxx
View file @
7d0269d2
...
...
@@ -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
;
...
...
src/InputStream.cxx
View file @
7d0269d2
...
...
@@ -31,9 +31,9 @@
static
constexpr
Domain
input_domain
(
"input"
);
struct
input_stream
*
input_stream
_o
pen
(
const
char
*
url
,
Mutex
&
mutex
,
Cond
&
cond
,
Error
&
error
)
input_stream
::
O
pen
(
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
)
{
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
)
input_stream
::
LockWaitReady
()
{
assert
(
is
!=
NULL
);
assert
(
is
->
ready
);
return
is
->
offset
;
}
bool
input_stream_is_seekable
(
const
struct
input_stream
*
is
)
{
assert
(
is
!=
NULL
);
assert
(
is
->
ready
);
return
is
->
seekable
;
const
ScopeLock
protect
(
mutex
);
WaitReady
();
}
bool
input_stream
_cheap_seeking
(
const
struct
input_stream
*
is
)
input_stream
::
CheapSeeking
()
const
{
return
is
->
seekable
&&
!
uri_has_scheme
(
is
->
uri
.
c_str
());
return
IsSeekable
()
&&
!
uri_has_scheme
(
uri
.
c_str
());
}
bool
input_stream_seek
(
struct
input_stream
*
is
,
goffset
offset
,
int
whence
,
Error
&
error
)
input_stream
::
Seek
(
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
);
plugin
.
close
(
th
is
);
}
bool
input_stream_eof
(
struct
input_stream
*
is
)
bool
input_stream
::
IsEOF
()
{
return
is
->
plugin
.
eof
(
is
);
return
plugin
.
eof
(
th
is
);
}
bool
input_stream
_lock_eof
(
struct
input_stream
*
is
)
input_stream
::
LockIsEOF
(
)
{
assert
(
is
!=
NULL
);
const
ScopeLock
protect
(
is
->
mutex
);
return
input_stream_eof
(
is
);
const
ScopeLock
protect
(
mutex
);
return
IsEOF
();
}
src/InputStream.hxx
View file @
7d0269d2
...
...
@@ -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
);
}
};
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
();
}
/**
* 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
);
};
#endif
src/PlaylistAny.cxx
View file @
7d0269d2
...
...
@@ -23,7 +23,7 @@
#include "PlaylistRegistry.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
#include "Input
Legacy
.hxx"
#include "Input
Stream
.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
_o
pen
(
uri
,
mutex
,
cond
,
error
);
input_stream
*
is
=
input_stream
::
O
pen
(
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
)
{
i
nput_stream_close
(
is
);
i
s
->
Close
(
);
return
NULL
;
}
...
...
src/PlaylistPrint.cxx
View file @
7d0269d2
...
...
@@ -30,7 +30,7 @@
#include "DatabaseGlue.hxx"
#include "DatabasePlugin.hxx"
#include "Client.hxx"
#include "Input
Legacy
.hxx"
#include "Input
Stream
.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
)
i
nput_stream_close
(
is
);
i
s
->
Close
(
);
return
true
;
}
src/PlaylistQueue.cxx
View file @
7d0269d2
...
...
@@ -23,7 +23,7 @@
#include "PlaylistAny.hxx"
#include "PlaylistSong.hxx"
#include "Playlist.hxx"
#include "Input
Legacy
.hxx"
#include "Input
Stream
.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
)
i
nput_stream_close
(
is
);
i
s
->
Close
(
);
return
result
;
}
src/PlaylistRegistry.cxx
View file @
7d0269d2
...
...
@@ -31,7 +31,7 @@
#include "playlist/RssPlaylistPlugin.hxx"
#include "playlist/CuePlaylistPlugin.hxx"
#include "playlist/EmbeddedCuePlaylistPlugin.hxx"
#include "Input
Legacy
.hxx"
#include "Input
Stream
.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
;
i
nput_stream_lock_wait_ready
(
is
);
i
s
->
LockWaitReady
(
);
const
char
*
const
mime
=
i
nput_stream_get_mime_type
(
is
);
const
char
*
const
mime
=
i
s
->
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
_o
pen
(
path_fs
,
mutex
,
cond
,
error
);
input_stream
*
is
=
input_stream
::
O
pen
(
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
;
}
i
nput_stream_lock_wait_ready
(
is
);
i
s
->
LockWaitReady
(
);
playlist
=
playlist_list_open_stream_suffix
(
is
,
suffix
);
if
(
playlist
!=
NULL
)
*
is_r
=
is
;
else
i
nput_stream_close
(
is
);
i
s
->
Close
(
);
return
playlist
;
}
src/SongUpdate.cxx
View file @
7d0269d2
...
...
@@ -26,7 +26,7 @@
#include "fs/Path.hxx"
#include "fs/FileSystem.hxx"
#include "Tag.hxx"
#include "Input
Legacy
.hxx"
#include "Input
Stream
.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
)
i
nput_stream_close
(
is
);
i
s
->
Close
(
);
if
(
tag
!=
nullptr
&&
tag
->
IsEmpty
())
tag_scan_fallback
(
path_fs
.
c_str
(),
&
full_tag_handler
,
tag
);
...
...
src/TagFile.cxx
View file @
7d0269d2
...
...
@@ -23,7 +23,7 @@
#include "util/Error.hxx"
#include "DecoderList.hxx"
#include "DecoderPlugin.hxx"
#include "Input
Legacy
.hxx"
#include "Input
Stream
.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
_o
pen
(
path_fs
,
mutex
,
cond
,
error
);
is
=
input_stream
::
O
pen
(
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
)
i
nput_stream_close
(
is
);
i
s
->
Close
(
);
return
plugin
!=
NULL
;
}
src/TextInputStream.cxx
View file @
7d0269d2
...
...
@@ -19,7 +19,7 @@
#include "config.h"
#include "TextInputStream.hxx"
#include "Input
Legacy
.hxx"
#include "Input
Stream
.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
())
{
...
...
src/archive/Bzip2ArchivePlugin.cxx
View file @
7d0269d2
...
...
@@ -62,7 +62,7 @@ public:
}
~
Bzip2ArchiveFile
()
{
i
nput_stream_close
(
istream
);
i
stream
->
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
_o
pen
(
pathname
,
mutex
,
cond
,
error
);
input_stream
*
is
=
input_stream
::
O
pen
(
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
;
...
...
src/decoder/AudiofileDecoderPlugin.cxx
View file @
7d0269d2
...
...
@@ -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
=
i
nput_stream_lock_read
(
is
,
data
,
length
,
error
);
size_t
nbytes
=
i
s
->
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
i
nput_stream_get_size
(
is
);
return
i
s
->
GetSize
(
);
}
static
AFfileoffset
audiofile_file_tell
(
AFvirtualfile
*
vfile
)
{
struct
input_stream
*
is
=
(
struct
input_stream
*
)
vfile
->
closure
;
return
i
nput_stream_get_offset
(
is
);
return
i
s
->
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
(
i
nput_stream_lock_seek
(
is
,
offset
,
whence
,
error
))
{
return
i
nput_stream_get_offset
(
is
);
if
(
i
s
->
LockSeek
(
offset
,
whence
,
error
))
{
return
i
s
->
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
(
!
i
nput_stream_is_seekable
(
is
))
{
if
(
!
i
s
->
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
)(
i
nput_stream_get_size
(
is
)
*
8.0
/
total_time
/
1000.0
+
0.5
);
bit_rate
=
(
uint16_t
)(
i
s
->
GetSize
(
)
*
8.0
/
total_time
/
1000.0
+
0.5
);
fs
=
(
int
)
afGetVirtualFrameSize
(
af_fp
,
AF_DEFAULT_TRACK
,
1
);
...
...
src/decoder/DsdLib.cxx
View file @
7d0269d2
...
...
@@ -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
(
i
nput_stream_is_seekable
(
is
))
return
i
nput_stream_seek
(
is
,
offset
,
SEEK_SET
,
IgnoreError
());
if
(
i
s
->
IsSeekable
(
))
return
i
s
->
Seek
(
offset
,
SEEK_SET
,
IgnoreError
());
if
(
i
nput_stream_get_offset
(
is
)
>
offset
)
if
(
i
s
->
GetOffset
(
)
>
offset
)
return
false
;
char
buffer
[
8192
];
while
(
i
nput_stream_get_offset
(
is
)
<
offset
)
{
while
(
i
s
->
GetOffset
(
)
<
offset
)
{
size_t
length
=
sizeof
(
buffer
);
if
(
offset
-
i
nput_stream_get_offset
(
is
)
<
(
goffset
)
length
)
length
=
offset
-
i
nput_stream_get_offset
(
is
);
if
(
offset
-
i
s
->
GetOffset
(
)
<
(
goffset
)
length
)
length
=
offset
-
i
s
->
GetOffset
(
);
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
length
);
if
(
nbytes
==
0
)
return
false
;
}
assert
(
i
nput_stream_get_offset
(
is
)
==
offset
);
assert
(
i
s
->
GetOffset
(
)
==
offset
);
return
true
;
}
...
...
@@ -97,8 +98,8 @@ dsdlib_skip(struct decoder *decoder, struct input_stream *is,
if
(
delta
==
0
)
return
true
;
if
(
i
nput_stream_is_seekable
(
is
))
return
i
nput_stream_seek
(
is
,
delta
,
SEEK_CUR
,
IgnoreError
());
if
(
i
s
->
IsSeekable
(
))
return
i
s
->
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
=
i
nput_stream_get_size
(
is
);
const
goffset
offset
=
i
nput_stream_get_offset
(
is
);
const
goffset
size
=
i
s
->
GetSize
(
);
const
goffset
offset
=
i
s
->
GetOffset
(
);
if
(
offset
>=
size
)
return
;
...
...
src/decoder/DsdiffDecoderPlugin.cxx
View file @
7d0269d2
...
...
@@ -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
)(
i
nput_stream_get_offset
(
is
)
+
sizeof
(
header
))
<=
end_offset
)
{
while
((
goffset
)(
i
s
->
GetOffset
(
)
+
sizeof
(
header
))
<=
end_offset
)
{
if
(
!
dsdiff_read_chunk_header
(
decoder
,
is
,
&
header
))
return
false
;
goffset
chunk_end_offset
=
i
nput_stream_get_offset
(
is
)
goffset
chunk_end_offset
=
i
s
->
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
i
nput_stream_get_offset
(
is
)
==
end_offset
;
return
i
s
->
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
=
i
nput_stream_get_offset
(
is
)
+
prop_size
;
goffset
end_offset
=
i
s
->
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
=
i
nput_stream_get_size
(
is
);
while
(
i
nput_stream_get_offset
(
is
)
<
size
)
{
const
goffset
size
=
i
s
->
GetSize
(
);
while
(
i
s
->
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
=
i
nput_stream_get_offset
(
is
);
metadata
->
diar_offset
=
i
s
->
GetOffset
(
);
}
/* DITI chunk - DSDIFF native tag for Title */
if
(
dsdlib_id_equals
(
&
chunk_header
->
id
,
"DITI"
))
{
chunk_size
=
chunk_header
->
GetSize
();
metadata
->
diti_offset
=
i
nput_stream_get_offset
(
is
);
metadata
->
diti_offset
=
i
s
->
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
=
i
nput_stream_get_offset
(
is
);
metadata
->
id3_offset
=
i
s
->
GetOffset
(
);
metadata
->
id3_size
=
chunk_size
;
}
#endif
...
...
@@ -292,7 +292,7 @@ dsdiff_read_metadata_extra(struct decoder *decoder, struct input_stream *is,
break
;
}
if
(
i
nput_stream_get_offset
(
is
)
<
size
)
{
if
(
i
s
->
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
=
i
nput_stream_get_offset
(
is
)
goffset
chunk_end_offset
=
i
s
->
GetOffset
(
)
+
chunk_size
;
if
(
!
dsdlib_skip_to
(
decoder
,
is
,
chunk_end_offset
))
...
...
src/decoder/DsfDecoderPlugin.cxx
View file @
7d0269d2
...
...
@@ -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
)
i
nput_stream_get_size
(
is
);
const
uint64_t
size
=
(
uint64_t
)
i
s
->
GetSize
(
);
if
(
data_size
>=
size
)
return
false
;
...
...
src/decoder/FaadDecoderPlugin.cxx
View file @
7d0269d2
...
...
@@ -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
=
i
nput_stream_get_size
(
is
);
const
goffset
size
=
i
s
->
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
(
i
nput_stream_is_seekable
(
is
)
&&
length
>=
2
&&
if
(
i
s
->
IsSeekable
(
)
&&
length
>=
2
&&
data
[
0
]
==
0xFF
&&
((
data
[
1
]
&
0xF6
)
==
0xF0
))
{
/* obtain the duration from the ADTS header */
float
song_length
=
adts_song_duration
(
buffer
);
i
nput_stream_lock_seek
(
is
,
tagsize
,
SEEK_SET
,
IgnoreError
());
i
s
->
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
);
...
...
src/decoder/FfmpegDecoderPlugin.cxx
View file @
7d0269d2
...
...
@@ -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
;
}
...
...
src/decoder/FlacDecoderPlugin.cxx
View file @
7d0269d2
...
...
@@ -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
);
}
...
...
src/decoder/FlacIOHandle.cxx
View file @
7d0269d2
...
...
@@ -37,7 +37,7 @@ FlacIORead(void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle)
Error
error
;
while
(
p
<
end
)
{
size_t
nbytes
=
i
nput_stream_lock_read
(
is
,
p
,
end
-
p
,
error
);
size_t
nbytes
=
i
s
->
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
i
nput_stream_lock_seek
(
is
,
offset
,
whence
,
error
)
?
0
:
-
1
;
return
i
s
->
LockSeek
(
offset
,
whence
,
error
)
?
0
:
-
1
;
}
static
FLAC__int64
...
...
@@ -83,7 +83,7 @@ FlacIOEof(FLAC__IOHandle handle)
{
input_stream
*
is
=
(
input_stream
*
)
handle
;
return
i
nput_stream_lock_eof
(
is
);
return
i
s
->
LockIsEOF
(
);
}
static
int
...
...
src/decoder/FlacInput.cxx
View file @
7d0269d2
...
...
@@ -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
...
...
src/decoder/MadDecoderPlugin.cxx
View file @
7d0269d2
...
...
@@ -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
)
{
...
...
src/decoder/ModplugDecoderPlugin.cxx
View file @
7d0269d2
...
...
@@ -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
=
i
nput_stream_get_size
(
is
);
const
goffset
size
=
i
s
->
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
(
i
nput_stream_lock_eof
(
is
))
if
(
i
s
->
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
,
i
nput_stream_is_seekable
(
is
),
i
s
->
IsSeekable
(
),
ModPlug_GetLength
(
f
)
/
1000.0
);
do
{
...
...
src/decoder/MpcdecDecoderPlugin.cxx
View file @
7d0269d2
...
...
@@ -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
,
i
nput_stream_is_seekable
(
is
),
i
s
->
IsSeekable
(
),
mpc_streaminfo_get_length
(
&
info
));
enum
decoder_command
cmd
=
DECODE_COMMAND_NONE
;
...
...
src/decoder/OpusDecoderPlugin.cxx
View file @
7d0269d2
...
...
@@ -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
(
!
i
nput_stream_cheap_seeking
(
is
))
if
(
!
i
s
->
CheapSeeking
(
))
return
false
;
oy
.
Reset
();
Error
error
;
return
i
nput_stream_lock_seek
(
is
,
-
65536
,
SEEK_END
,
error
)
&&
return
i
s
->
LockSeek
(
-
65536
,
SEEK_END
,
error
)
&&
oy
.
ExpectPageSeekIn
(
os
)
&&
OggFindEOS
(
oy
,
os
,
packet
);
}
...
...
src/decoder/PcmDecoderPlugin.cxx
View file @
7d0269d2
...
...
@@ -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
=
i
nput_stream_get_mime_type
(
is
);
const
char
*
const
mime
=
i
s
->
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
=
i
nput_stream_get_size
(
is
);
const
goffset
size
=
i
s
->
GetSize
(
);
if
(
size
>=
0
)
total_time
=
size
/
time_to_size
;
decoder_initialized
(
decoder
,
audio_format
,
i
nput_stream_is_seekable
(
is
),
total_time
);
i
s
->
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
&&
i
nput_stream_lock_eof
(
is
))
if
(
nbytes
==
0
&&
i
s
->
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
());
...
...
src/decoder/SndfileDecoderPlugin.cxx
View file @
7d0269d2
...
...
@@ -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
i
nput_stream_get_size
(
is
);
return
i
s
->
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
(
!
i
nput_stream_lock_seek
(
is
,
offset
,
whence
,
IgnoreError
()))
if
(
!
i
s
->
LockSeek
(
offset
,
whence
,
IgnoreError
()))
return
-
1
;
return
i
nput_stream_get_offset
(
is
);
return
i
s
->
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
=
i
nput_stream_lock_read
(
is
,
ptr
,
count
,
error
);
size_t
nbytes
=
i
s
->
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
i
nput_stream_get_offset
(
is
);
return
i
s
->
GetOffset
(
);
}
/**
...
...
src/decoder/VorbisDecoderPlugin.cxx
View file @
7d0269d2
...
...
@@ -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
;
...
...
src/decoder/WavpackDecoderPlugin.cxx
View file @
7d0269d2
...
...
@@ -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
)
{
i
nput_stream_close
(
is_wvc
);
i
s_wvc
->
Close
(
);
return
NULL
;
}
...
...
@@ -545,7 +540,7 @@ wavpack_streamdecode(struct decoder * decoder, struct input_stream *is)
WavpackCloseFile
(
wpc
);
if
(
open_flags
&
OPEN_WVC
)
{
i
nput_stream_close
(
is_wvc
);
i
s_wvc
->
Close
(
);
}
}
...
...
src/input/CurlInputPlugin.cxx
View file @
7d0269d2
...
...
@@ -161,7 +161,7 @@ struct input_curl {
char
*
meta_name
;
/** the tag object ready to be requested via
input_stream
_t
ag() */
input_stream
::ReadT
ag() */
Tag
*
tag
;
Error
postponed_error
;
...
...
src/input/RewindInputPlugin.cxx
View file @
7d0269d2
...
...
@@ -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
...
...
src/playlist/AsxPlaylistPlugin.cxx
View file @
7d0269d2
...
...
@@ -20,7 +20,7 @@
#include "config.h"
#include "AsxPlaylistPlugin.hxx"
#include "MemoryPlaylistProvider.hxx"
#include "Input
Legacy
.hxx"
#include "Input
Stream
.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
);
...
...
src/playlist/CuePlaylistPlugin.cxx
View file @
7d0269d2
...
...
@@ -22,7 +22,6 @@
#include "PlaylistPlugin.hxx"
#include "Tag.hxx"
#include "Song.hxx"
#include "InputLegacy.hxx"
#include "cue/CueParser.hxx"
#include "TextInputStream.hxx"
...
...
src/playlist/LastFMPlaylistPlugin.cxx
View file @
7d0269d2
...
...
@@ -23,7 +23,7 @@
#include "PlaylistRegistry.hxx"
#include "conf.h"
#include "Song.hxx"
#include "Input
Legacy
.hxx"
#include "Input
Stream
.hxx"
#include "util/Error.hxx"
#include <glib.h>
...
...
@@ -45,7 +45,7 @@ struct LastfmPlaylist {
~
LastfmPlaylist
()
{
playlist_plugin_close
(
xspf
);
i
nput_stream_close
(
is
);
i
s
->
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
_o
pen
(
url
,
mutex
,
cond
,
error
);
input_stream
=
input_stream
::
O
pen
(
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
_o
pen
(
p
,
mutex
,
cond
,
error
);
const
auto
is
=
input_stream
::
O
pen
(
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
();
i
nput_stream_wait_ready
(
is
);
i
s
->
WaitReady
(
);
/* last.fm does not send a MIME type, we have to fake it here
:-( */
i
nput_stream_override_mime_type
(
is
,
"application/xspf+xml"
);
i
s
->
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
)
{
i
nput_stream_close
(
is
);
i
s
->
Close
(
);
g_warning
(
"Failed to parse XSPF playlist"
);
return
NULL
;
}
...
...
src/playlist/PlsPlaylistPlugin.cxx
View file @
7d0269d2
...
...
@@ -20,7 +20,7 @@
#include "config.h"
#include "PlsPlaylistPlugin.hxx"
#include "MemoryPlaylistProvider.hxx"
#include "Input
Legacy
.hxx"
#include "Input
Stream
.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
());
...
...
src/playlist/RssPlaylistPlugin.cxx
View file @
7d0269d2
...
...
@@ -20,7 +20,7 @@
#include "config.h"
#include "RssPlaylistPlugin.hxx"
#include "MemoryPlaylistProvider.hxx"
#include "Input
Legacy
.hxx"
#include "Input
Stream
.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
);
...
...
src/playlist/SoundCloudPlaylistPlugin.cxx
View file @
7d0269d2
...
...
@@ -21,7 +21,7 @@
#include "SoundCloudPlaylistPlugin.hxx"
#include "MemoryPlaylistProvider.hxx"
#include "conf.h"
#include "Input
Legacy
.hxx"
#include "Input
Stream
.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
_o
pen
(
url
,
mutex
,
cond
,
error
);
input_stream
*
input_stream
=
input_stream
::
O
pen
(
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
;
}
...
...
src/playlist/XspfPlaylistPlugin.cxx
View file @
7d0269d2
...
...
@@ -20,7 +20,7 @@
#include "config.h"
#include "XspfPlaylistPlugin.hxx"
#include "MemoryPlaylistProvider.hxx"
#include "Input
Legacy
.hxx"
#include "Input
Stream
.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
);
...
...
test/dump_playlist.cxx
View file @
7d0269d2
...
...
@@ -21,7 +21,7 @@
#include "TagSave.hxx"
#include "Song.hxx"
#include "Directory.hxx"
#include "Input
Legacy
.hxx"
#include "Input
Stream
.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
i
nput_stream_lock_read
(
is
,
buffer
,
length
,
error
);
return
i
s
->
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
_o
pen
(
uri
,
mutex
,
cond
,
error
);
is
=
input_stream
::
O
pen
(
uri
,
mutex
,
cond
,
error
);
if
(
is
==
NULL
)
{
if
(
error
.
IsDefined
())
g_warning
(
"%s"
,
error
.
GetMessage
());
else
g_printerr
(
"input_stream
_o
pen() failed
\n
"
);
g_printerr
(
"input_stream
::O
pen() failed
\n
"
);
return
2
;
}
i
nput_stream_lock_wait_ready
(
is
);
i
s
->
LockWaitReady
(
);
/* open the playlist */
playlist
=
playlist_list_open_stream
(
is
,
uri
);
if
(
playlist
==
NULL
)
{
i
nput_stream_close
(
is
);
i
s
->
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
)
i
nput_stream_close
(
is
);
i
s
->
Close
(
);
decoder_plugin_deinit_all
();
playlist_list_global_finish
();
...
...
test/dump_text_file.cxx
View file @
7d0269d2
...
...
@@ -59,34 +59,35 @@ dump_input_stream(struct input_stream *is)
{
Error
error
;
i
nput_stream_lock
(
is
);
i
s
->
Lock
(
);
/* wait until the stream becomes ready */
i
nput_stream_wait_ready
(
is
);
i
s
->
WaitReady
(
);
if
(
!
i
nput_stream_check
(
is
,
error
))
{
if
(
!
i
s
->
Check
(
error
))
{
g_warning
(
"%s"
,
error
.
GetMessage
());
i
nput_stream_unlock
(
is
);
i
s
->
Unlock
(
);
return
EXIT_FAILURE
;
}
/* read data and tags from the stream */
i
nput_stream_unlock
(
is
);
i
s
->
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
());
i
nput_stream_unlock
(
is
);
i
s
->
Unlock
(
);
return
EXIT_FAILURE
;
}
i
nput_stream_unlock
(
is
);
i
s
->
Unlock
(
);
return
0
;
}
...
...
@@ -131,15 +132,15 @@ int main(int argc, char **argv)
Mutex
mutex
;
Cond
cond
;
is
=
input_stream
_o
pen
(
argv
[
1
],
mutex
,
cond
,
error
);
is
=
input_stream
::
O
pen
(
argv
[
1
],
mutex
,
cond
,
error
);
if
(
is
!=
NULL
)
{
ret
=
dump_input_stream
(
is
);
i
nput_stream_close
(
is
);
i
s
->
Close
(
);
}
else
{
if
(
error
.
IsDefined
())
g_warning
(
"%s"
,
error
.
GetMessage
());
else
g_printerr
(
"input_stream
_o
pen() failed
\n
"
);
g_printerr
(
"input_stream
::O
pen() failed
\n
"
);
ret
=
2
;
}
...
...
test/read_tags.cxx
View file @
7d0269d2
...
...
@@ -72,7 +72,7 @@ decoder_read(gcc_unused struct decoder *decoder,
void
*
buffer
,
size_t
length
)
{
Error
error
;
return
i
nput_stream_lock_read
(
is
,
buffer
,
length
,
error
);
return
i
s
->
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
();
i
nput_stream_wait_ready
(
is
);
i
s
->
WaitReady
(
);
if
(
!
i
nput_stream_check
(
is
,
error
))
{
if
(
!
i
s
->
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
);
i
nput_stream_close
(
is
);
i
s
->
Close
(
);
}
decoder_plugin_deinit_all
();
...
...
test/run_decoder.cxx
View file @
7d0269d2
...
...
@@ -22,7 +22,7 @@
#include "DecoderList.hxx"
#include "DecoderAPI.hxx"
#include "InputInit.hxx"
#include "Input
Legacy
.hxx"
#include "Input
Stream
.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
_o
pen
(
decoder
.
uri
,
mutex
,
cond
,
error
);
input_stream
*
is
=
input_stream
::
O
pen
(
decoder
.
uri
,
mutex
,
cond
,
error
);
if
(
is
==
NULL
)
{
if
(
error
.
IsDefined
())
g_warning
(
"%s"
,
error
.
GetMessage
());
else
g_printerr
(
"input_stream
_o
pen() failed
\n
"
);
g_printerr
(
"input_stream
::O
pen() failed
\n
"
);
return
1
;
}
decoder_plugin_stream_decode
(
decoder
.
plugin
,
&
decoder
,
is
);
i
nput_stream_close
(
is
);
i
s
->
Close
(
);
}
else
{
g_printerr
(
"Decoder plugin is not usable
\n
"
);
return
1
;
...
...
test/run_input.cxx
View file @
7d0269d2
...
...
@@ -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
;
i
nput_stream_lock
(
is
);
i
s
->
Lock
(
);
/* wait until the stream becomes ready */
i
nput_stream_wait_ready
(
is
);
i
s
->
WaitReady
(
);
if
(
!
i
nput_stream_check
(
is
,
error
))
{
if
(
!
i
s
->
Check
(
error
))
{
g_warning
(
"%s"
,
error
.
GetMessage
());
i
nput_stream_unlock
(
is
);
i
s
->
Unlock
(
);
return
EXIT_FAILURE
;
}
...
...
@@ -74,16 +73,15 @@ dump_input_stream(struct input_stream *is)
/* read data and tags from the stream */
while
(
!
i
nput_stream_eof
(
is
))
{
Tag
*
tag
=
i
nput_stream_tag
(
is
);
while
(
!
i
s
->
IsEOF
(
))
{
Tag
*
tag
=
i
s
->
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
(
!
i
nput_stream_check
(
is
,
error
))
{
if
(
!
i
s
->
Check
(
error
))
{
g_warning
(
"%s"
,
error
.
GetMessage
());
i
nput_stream_unlock
(
is
);
i
s
->
Unlock
(
);
return
EXIT_FAILURE
;
}
i
nput_stream_unlock
(
is
);
i
s
->
Unlock
(
);
return
0
;
}
...
...
@@ -147,15 +145,15 @@ int main(int argc, char **argv)
Mutex
mutex
;
Cond
cond
;
is
=
input_stream
_o
pen
(
argv
[
1
],
mutex
,
cond
,
error
);
is
=
input_stream
::
O
pen
(
argv
[
1
],
mutex
,
cond
,
error
);
if
(
is
!=
NULL
)
{
ret
=
dump_input_stream
(
is
);
i
nput_stream_close
(
is
);
i
s
->
Close
(
);
}
else
{
if
(
error
.
IsDefined
())
g_warning
(
"%s"
,
error
.
GetMessage
());
else
g_printerr
(
"input_stream
_o
pen() failed
\n
"
);
g_printerr
(
"input_stream
::O
pen() failed
\n
"
);
ret
=
2
;
}
...
...
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