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
f1027ed1
Commit
f1027ed1
authored
Oct 23, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InputStream: add method Rewind()
parent
fe3c5e4e
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
31 additions
and
28 deletions
+31
-28
DecoderThread.cxx
src/DecoderThread.cxx
+1
-4
InputStream.cxx
src/InputStream.cxx
+13
-0
InputStream.hxx
src/InputStream.hxx
+7
-0
PlaylistRegistry.cxx
src/PlaylistRegistry.cxx
+2
-3
TagFile.cxx
src/TagFile.cxx
+1
-2
FfmpegDecoderPlugin.cxx
src/decoder/FfmpegDecoderPlugin.cxx
+4
-10
FlacDecoderPlugin.cxx
src/decoder/FlacDecoderPlugin.cxx
+1
-5
OpusDecoderPlugin.cxx
src/decoder/OpusDecoderPlugin.cxx
+1
-2
VorbisDecoderPlugin.cxx
src/decoder/VorbisDecoderPlugin.cxx
+1
-2
No files found.
src/DecoderThread.cxx
View file @
f1027ed1
...
@@ -40,9 +40,6 @@
...
@@ -40,9 +40,6 @@
#include <glib.h>
#include <glib.h>
#include <unistd.h>
#include <stdio.h>
/* for SEEK_SET */
static
constexpr
Domain
decoder_thread_domain
(
"decoder_thread"
);
static
constexpr
Domain
decoder_thread_domain
(
"decoder_thread"
);
/**
/**
...
@@ -128,7 +125,7 @@ decoder_stream_decode(const DecoderPlugin &plugin,
...
@@ -128,7 +125,7 @@ decoder_stream_decode(const DecoderPlugin &plugin,
return
true
;
return
true
;
/* rewind the stream, so each plugin gets a fresh start */
/* rewind the stream, so each plugin gets a fresh start */
input_stream
->
Seek
(
0
,
SEEK_SET
,
IgnoreError
());
input_stream
->
Rewind
(
IgnoreError
());
decoder
.
dc
.
Unlock
();
decoder
.
dc
.
Unlock
();
...
...
src/InputStream.cxx
View file @
f1027ed1
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "util/Domain.hxx"
#include "util/Domain.hxx"
#include <assert.h>
#include <assert.h>
#include <stdio.h>
/* for SEEK_SET */
static
constexpr
Domain
input_domain
(
"input"
);
static
constexpr
Domain
input_domain
(
"input"
);
...
@@ -113,6 +114,18 @@ input_stream::LockSeek(offset_type _offset, int whence, Error &error)
...
@@ -113,6 +114,18 @@ input_stream::LockSeek(offset_type _offset, int whence, Error &error)
return
Seek
(
_offset
,
whence
,
error
);
return
Seek
(
_offset
,
whence
,
error
);
}
}
bool
input_stream
::
Rewind
(
Error
&
error
)
{
return
Seek
(
0
,
SEEK_SET
,
error
);
}
bool
input_stream
::
LockRewind
(
Error
&
error
)
{
return
LockSeek
(
0
,
SEEK_SET
,
error
);
}
Tag
*
Tag
*
input_stream
::
ReadTag
()
input_stream
::
ReadTag
()
{
{
...
...
src/InputStream.hxx
View file @
f1027ed1
...
@@ -218,6 +218,13 @@ struct input_stream {
...
@@ -218,6 +218,13 @@ struct input_stream {
bool
LockSeek
(
offset_type
offset
,
int
whence
,
Error
&
error
);
bool
LockSeek
(
offset_type
offset
,
int
whence
,
Error
&
error
);
/**
/**
* Rewind to the beginning of the stream. This is a wrapper
* for Seek(0, SEEK_SET, error).
*/
bool
Rewind
(
Error
&
error
);
bool
LockRewind
(
Error
&
error
);
/**
* Returns true if the stream has reached end-of-file.
* Returns true if the stream has reached end-of-file.
*
*
* The caller must lock the mutex.
* The caller must lock the mutex.
...
...
src/PlaylistRegistry.cxx
View file @
f1027ed1
...
@@ -44,7 +44,6 @@
...
@@ -44,7 +44,6 @@
#include <assert.h>
#include <assert.h>
#include <string.h>
#include <string.h>
#include <stdio.h>
const
struct
playlist_plugin
*
const
playlist_plugins
[]
=
{
const
struct
playlist_plugin
*
const
playlist_plugins
[]
=
{
&
extm3u_playlist_plugin
,
&
extm3u_playlist_plugin
,
...
@@ -221,7 +220,7 @@ playlist_list_open_stream_mime2(struct input_stream *is, const char *mime)
...
@@ -221,7 +220,7 @@ playlist_list_open_stream_mime2(struct input_stream *is, const char *mime)
string_array_contains
(
plugin
->
mime_types
,
mime
))
{
string_array_contains
(
plugin
->
mime_types
,
mime
))
{
/* rewind the stream, so each plugin gets a
/* rewind the stream, so each plugin gets a
fresh start */
fresh start */
is
->
Seek
(
0
,
SEEK_SET
,
IgnoreError
());
is
->
Rewind
(
IgnoreError
());
auto
playlist
=
playlist_plugin_open_stream
(
plugin
,
is
);
auto
playlist
=
playlist_plugin_open_stream
(
plugin
,
is
);
if
(
playlist
!=
nullptr
)
if
(
playlist
!=
nullptr
)
...
@@ -261,7 +260,7 @@ playlist_list_open_stream_suffix(struct input_stream *is, const char *suffix)
...
@@ -261,7 +260,7 @@ playlist_list_open_stream_suffix(struct input_stream *is, const char *suffix)
string_array_contains
(
plugin
->
suffixes
,
suffix
))
{
string_array_contains
(
plugin
->
suffixes
,
suffix
))
{
/* rewind the stream, so each plugin gets a
/* rewind the stream, so each plugin gets a
fresh start */
fresh start */
is
->
Seek
(
0
,
SEEK_SET
,
IgnoreError
());
is
->
Rewind
(
IgnoreError
());
auto
playlist
=
playlist_plugin_open_stream
(
plugin
,
is
);
auto
playlist
=
playlist_plugin_open_stream
(
plugin
,
is
);
if
(
playlist
!=
nullptr
)
if
(
playlist
!=
nullptr
)
...
...
src/TagFile.cxx
View file @
f1027ed1
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
#include "thread/Cond.hxx"
#include "thread/Cond.hxx"
#include <assert.h>
#include <assert.h>
#include <unistd.h>
/* for SEEK_SET */
bool
bool
tag_file_scan
(
const
char
*
path_fs
,
tag_file_scan
(
const
char
*
path_fs
,
...
@@ -71,7 +70,7 @@ tag_file_scan(const char *path_fs,
...
@@ -71,7 +70,7 @@ tag_file_scan(const char *path_fs,
*
handler
,
handler_ctx
))
*
handler
,
handler_ctx
))
break
;
break
;
is
->
Lock
Seek
(
0
,
SEEK_SET
,
IgnoreError
());
is
->
Lock
Rewind
(
IgnoreError
());
}
}
}
}
...
...
src/decoder/FfmpegDecoderPlugin.cxx
View file @
f1027ed1
...
@@ -31,15 +31,6 @@
...
@@ -31,15 +31,6 @@
#include "util/Domain.hxx"
#include "util/Domain.hxx"
#include "LogV.hxx"
#include "LogV.hxx"
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
extern
"C"
{
extern
"C"
{
#include <libavcodec/avcodec.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavformat/avformat.h>
...
@@ -50,6 +41,9 @@ extern "C" {
...
@@ -50,6 +41,9 @@ extern "C" {
#include <libavutil/dict.h>
#include <libavutil/dict.h>
}
}
#include <assert.h>
#include <string.h>
static
constexpr
Domain
ffmpeg_domain
(
"ffmpeg"
);
static
constexpr
Domain
ffmpeg_domain
(
"ffmpeg"
);
/* suppress the ffmpeg compatibility macro */
/* suppress the ffmpeg compatibility macro */
...
@@ -352,7 +346,7 @@ ffmpeg_probe(Decoder *decoder, struct input_stream *is)
...
@@ -352,7 +346,7 @@ ffmpeg_probe(Decoder *decoder, struct input_stream *is)
unsigned
char
buffer
[
BUFFER_SIZE
];
unsigned
char
buffer
[
BUFFER_SIZE
];
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
BUFFER_SIZE
);
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
BUFFER_SIZE
);
if
(
nbytes
<=
PADDING
||
!
is
->
Lock
Seek
(
0
,
SEEK_SET
,
error
))
if
(
nbytes
<=
PADDING
||
!
is
->
Lock
Rewind
(
error
))
return
nullptr
;
return
nullptr
;
/* some ffmpeg parsers (e.g. ac3_parser.c) read a few bytes
/* some ffmpeg parsers (e.g. ac3_parser.c) read a few bytes
...
...
src/decoder/FlacDecoderPlugin.cxx
View file @
f1027ed1
...
@@ -29,10 +29,6 @@
...
@@ -29,10 +29,6 @@
#include <glib.h>
#include <glib.h>
#include <assert.h>
#include <assert.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
#error libFLAC is too old
#error libFLAC is too old
...
@@ -340,7 +336,7 @@ oggflac_decode(Decoder &decoder, struct input_stream *input_stream)
...
@@ -340,7 +336,7 @@ oggflac_decode(Decoder &decoder, struct input_stream *input_stream)
/* rewind the stream, because ogg_codec_detect() has
/* rewind the stream, because ogg_codec_detect() has
moved it */
moved it */
input_stream
->
Lock
Seek
(
0
,
SEEK_SET
,
IgnoreError
());
input_stream
->
Lock
Rewind
(
IgnoreError
());
flac_decode_internal
(
decoder
,
input_stream
,
true
);
flac_decode_internal
(
decoder
,
input_stream
,
true
);
}
}
...
...
src/decoder/OpusDecoderPlugin.cxx
View file @
f1027ed1
...
@@ -39,7 +39,6 @@
...
@@ -39,7 +39,6 @@
#include <glib.h>
#include <glib.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
static
const
opus_int32
opus_sample_rate
=
48000
;
static
const
opus_int32
opus_sample_rate
=
48000
;
...
@@ -273,7 +272,7 @@ mpd_opus_stream_decode(Decoder &decoder,
...
@@ -273,7 +272,7 @@ mpd_opus_stream_decode(Decoder &decoder,
/* rewind the stream, because ogg_codec_detect() has
/* rewind the stream, because ogg_codec_detect() has
moved it */
moved it */
input_stream
->
Lock
Seek
(
0
,
SEEK_SET
,
IgnoreError
());
input_stream
->
Lock
Rewind
(
IgnoreError
());
MPDOpusDecoder
d
(
decoder
,
input_stream
);
MPDOpusDecoder
d
(
decoder
,
input_stream
);
OggSyncState
oy
(
*
input_stream
,
&
decoder
);
OggSyncState
oy
(
*
input_stream
,
&
decoder
);
...
...
src/decoder/VorbisDecoderPlugin.cxx
View file @
f1027ed1
...
@@ -50,7 +50,6 @@
...
@@ -50,7 +50,6 @@
#include <assert.h>
#include <assert.h>
#include <errno.h>
#include <errno.h>
#include <unistd.h>
struct
vorbis_input_stream
{
struct
vorbis_input_stream
{
Decoder
*
decoder
;
Decoder
*
decoder
;
...
@@ -184,7 +183,7 @@ vorbis_stream_decode(Decoder &decoder,
...
@@ -184,7 +183,7 @@ vorbis_stream_decode(Decoder &decoder,
/* rewind the stream, because ogg_codec_detect() has
/* rewind the stream, because ogg_codec_detect() has
moved it */
moved it */
input_stream
->
Lock
Seek
(
0
,
SEEK_SET
,
IgnoreError
());
input_stream
->
Lock
Rewind
(
IgnoreError
());
struct
vorbis_input_stream
vis
;
struct
vorbis_input_stream
vis
;
OggVorbis_File
vf
;
OggVorbis_File
vf
;
...
...
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