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
ef48eca9
Commit
ef48eca9
authored
Jun 24, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
git://git.musicpd.org/dk/mpd
parents
906d2fba
e9e55b08
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
366 additions
and
378 deletions
+366
-378
.gitignore
.gitignore
+1
-1
Makefile.am
Makefile.am
+15
-15
ClientFile.cxx
src/ClientFile.cxx
+5
-2
ClientFile.hxx
src/ClientFile.hxx
+2
-1
DecoderList.cxx
src/DecoderList.cxx
+1
-1
ExcludeList.cxx
src/ExcludeList.cxx
+3
-3
ExcludeList.hxx
src/ExcludeList.hxx
+1
-1
Mapper.cxx
src/Mapper.cxx
+1
-1
OtherCommands.cxx
src/OtherCommands.cxx
+9
-1
PlaylistFile.cxx
src/PlaylistFile.cxx
+24
-27
QueueCommands.cxx
src/QueueCommands.cxx
+21
-6
TextInputStream.cxx
src/TextInputStream.cxx
+28
-47
TextInputStream.hxx
src/TextInputStream.hxx
+33
-26
Timer.cxx
src/Timer.cxx
+19
-28
Timer.hxx
src/Timer.hxx
+17
-27
UpdateWalk.cxx
src/UpdateWalk.cxx
+23
-27
clock.h
src/clock.h
+8
-0
FlacCommon.cxx
src/decoder/FlacCommon.cxx
+4
-4
FlacCommon.hxx
src/decoder/FlacCommon.hxx
+2
-2
FlacDecoderPlugin.cxx
src/decoder/FlacDecoderPlugin.cxx
+19
-19
FlacDecoderPlugin.h
src/decoder/FlacDecoderPlugin.h
+0
-0
FlacIOHandle.cxx
src/decoder/FlacIOHandle.cxx
+14
-14
FlacIOHandle.hxx
src/decoder/FlacIOHandle.hxx
+2
-2
FlacInput.cxx
src/decoder/FlacInput.cxx
+19
-19
FlacInput.hxx
src/decoder/FlacInput.hxx
+2
-2
FlacMetadata.cxx
src/decoder/FlacMetadata.cxx
+2
-2
FlacMetadata.hxx
src/decoder/FlacMetadata.hxx
+7
-7
FlacPcm.cxx
src/decoder/FlacPcm.cxx
+1
-1
FlacPcm.hxx
src/decoder/FlacPcm.hxx
+0
-0
DirectoryReader.hxx
src/fs/DirectoryReader.hxx
+4
-4
FifoOutputPlugin.cxx
src/output/FifoOutputPlugin.cxx
+10
-10
HttpdInternal.hxx
src/output/HttpdInternal.hxx
+3
-3
HttpdOutputPlugin.cxx
src/output/HttpdOutputPlugin.cxx
+8
-8
NullOutputPlugin.cxx
src/output/NullOutputPlugin.cxx
+11
-11
CuePlaylistPlugin.cxx
src/playlist/CuePlaylistPlugin.cxx
+6
-10
ExtM3uPlaylistPlugin.cxx
src/playlist/ExtM3uPlaylistPlugin.cxx
+19
-19
M3uPlaylistPlugin.cxx
src/playlist/M3uPlaylistPlugin.cxx
+13
-14
dump_text_file.cxx
test/dump_text_file.cxx
+9
-13
No files found.
.gitignore
View file @
ef48eca9
...
...
@@ -5,6 +5,7 @@
*.la
*.lo
*.o
*.exe
.deps
.dirstamp
Makefile
...
...
@@ -31,7 +32,6 @@ ltmain.sh
missing
mkinstalldirs
mpd
mpd.exe
mpd.service
stamp-h1
tags
...
...
Makefile.am
View file @
ef48eca9
...
...
@@ -70,7 +70,7 @@ mpd_headers = \
src/gcc.h
\
src/decoder/pcm_decoder_plugin.h
\
src/input_stream.h
\
src/
text_input_stream.h
\
src/
TextInputStream.hxx
\
src/ls.h
\
src/mixer_plugin.h
\
src/daemon.h
\
...
...
@@ -94,7 +94,7 @@ mpd_headers = \
src/tag_ape.h
\
src/tag_id3.h
\
src/tag_rva2.h
\
src/
timer.h
\
src/
Timer.hxx
\
src/mpd_error.h
src_mpd_SOURCES
=
\
...
...
@@ -238,12 +238,12 @@ src_mpd_SOURCES = \
src/tag_handler.c src/tag_handler.h
\
src/TagFile.cxx src/TagFile.hxx
\
src/TextFile.cxx src/TextFile.hxx
\
src/
text_input_stream.c
\
src/
TextInputStream.cxx
\
src/Volume.cxx src/Volume.hxx
\
src/SongFilter.cxx src/SongFilter.hxx
\
src/SongPointer.hxx
\
src/PlaylistFile.cxx src/PlaylistFile.hxx
\
src/
timer.c
src/
Timer.cxx
#
# Windows resource file
...
...
@@ -555,13 +555,13 @@ endif
if
HAVE_FLAC
libdecoder_plugins_a_SOURCES
+=
\
src/decoder/F
LACInput.cxx src/decoder/FLAC
Input.hxx
\
src/decoder/F
LACIOHandle.cxx src/decoder/FLAC
IOHandle.hxx
\
src/decoder/F
LACMetaData.cxx src/decoder/FLACMetaD
ata.hxx
\
src/decoder/F
LAC_PCM.cxx src/decoder/FLAC_PCM
.hxx
\
src/decoder/F
LACCommon.cxx src/decoder/FLAC
Common.hxx
\
src/decoder/F
LAC
DecoderPlugin.cxx
\
src/decoder/F
LAC
DecoderPlugin.h
src/decoder/F
lacInput.cxx src/decoder/Flac
Input.hxx
\
src/decoder/F
lacIOHandle.cxx src/decoder/Flac
IOHandle.hxx
\
src/decoder/F
lacMetadata.cxx src/decoder/FlacMetad
ata.hxx
\
src/decoder/F
lacPcm.cxx src/decoder/FlacPcm
.hxx
\
src/decoder/F
lacCommon.cxx src/decoder/Flac
Common.hxx
\
src/decoder/F
lac
DecoderPlugin.cxx
\
src/decoder/F
lac
DecoderPlugin.h
endif
if
HAVE_AUDIOFILE
...
...
@@ -1108,7 +1108,7 @@ test_dump_text_file_SOURCES = test/dump_text_file.cxx \
test
/stdbin.h
\
src/IOThread.cxx
\
src/Tag.cxx src/TagNames.c src/TagPool.cxx
\
src/
text_input_stream.c
\
src/
TextInputStream.cxx
\
src/fd_util.c
test_dump_playlist_LDADD
=
\
...
...
@@ -1130,14 +1130,14 @@ test_dump_playlist_SOURCES = test/dump_playlist.cxx \
src/Song.cxx src/Tag.cxx src/TagNames.c src/TagPool.cxx src/TagSave.cxx
\
src/tag_handler.c src/TagFile.cxx
\
src/audio_check.c
\
src/
text_input_stream.c
\
src/
TextInputStream.cxx
\
src/cue/CueParser.cxx src/cue/CueParser.hxx
\
src/fd_util.c
if
HAVE_FLAC
test_dump_playlist_SOURCES
+=
\
src/ReplayGainInfo.cxx
\
src/decoder/F
LACMetaD
ata.cxx
src/decoder/F
lacMetad
ata.cxx
endif
test_run_decoder_LDADD
=
\
...
...
@@ -1299,7 +1299,7 @@ test_run_output_SOURCES = test/run_output.cxx \
src/audio_check.c
\
src/audio_format.c
\
src/AudioParser.cxx
\
src/
timer.c
src/clock.c
\
src/
Timer.cxx
src/clock.c
\
src/Tag.cxx src/TagNames.c src/TagPool.cxx
\
src/Page.cxx
\
src/SocketUtil.cxx
\
...
...
src/ClientFile.cxx
View file @
ef48eca9
...
...
@@ -17,10 +17,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ClientFile.hxx"
#include "Client.hxx"
#include "ack.h"
#include "io_error.h"
#include "fs/Path.hxx"
#include "fs/FileSystem.hxx"
#include <sys/stat.h>
#include <sys/types.h>
...
...
@@ -28,7 +31,7 @@
#include <unistd.h>
bool
client_allow_file
(
const
Client
*
client
,
const
char
*
path_fs
,
client_allow_file
(
const
Client
*
client
,
const
Path
&
path_fs
,
GError
**
error_r
)
{
#ifdef WIN32
...
...
@@ -53,7 +56,7 @@ client_allow_file(const Client *client, const char *path_fs,
}
struct
stat
st
;
if
(
stat
(
path_fs
,
&
st
)
<
0
)
{
if
(
!
StatFile
(
path_fs
,
st
)
)
{
set_error_errno
(
error_r
);
return
false
;
}
...
...
src/ClientFile.hxx
View file @
ef48eca9
...
...
@@ -25,6 +25,7 @@
#include <stdbool.h>
class
Client
;
class
Path
;
/**
* Is this client allowed to use the specified local file?
...
...
@@ -37,7 +38,7 @@ class Client;
* @return true if access is allowed
*/
bool
client_allow_file
(
const
Client
*
client
,
const
char
*
path_fs
,
client_allow_file
(
const
Client
*
client
,
const
Path
&
path_fs
,
GError
**
error_r
);
#endif
src/DecoderList.cxx
View file @
ef48eca9
...
...
@@ -25,7 +25,7 @@
#include "decoder/pcm_decoder_plugin.h"
#include "decoder/dsdiff_decoder_plugin.h"
#include "decoder/dsf_decoder_plugin.h"
#include "decoder/F
LAC
DecoderPlugin.h"
#include "decoder/F
lac
DecoderPlugin.h"
#include "decoder/OpusDecoderPlugin.h"
#include "decoder/VorbisDecoderPlugin.h"
#include "decoder/AdPlugDecoderPlugin.h"
...
...
src/ExcludeList.cxx
View file @
ef48eca9
...
...
@@ -63,14 +63,14 @@ ExcludeList::LoadFile(const Path &path_fs)
}
bool
ExcludeList
::
Check
(
const
char
*
name_fs
)
const
ExcludeList
::
Check
(
const
Path
&
name_fs
)
const
{
assert
(
name_fs
!=
NULL
);
assert
(
!
name_fs
.
IsNull
()
);
/* XXX include full path name in check */
for
(
const
auto
&
i
:
patterns
)
if
(
i
.
Check
(
name_fs
))
if
(
i
.
Check
(
name_fs
.
c_str
()
))
return
true
;
return
false
;
...
...
src/ExcludeList.hxx
View file @
ef48eca9
...
...
@@ -73,7 +73,7 @@ public:
* Checks whether one of the patterns in the .mpdignore file matches
* the specified file name.
*/
bool
Check
(
const
char
*
name_fs
)
const
;
bool
Check
(
const
Path
&
name_fs
)
const
;
};
...
...
src/Mapper.cxx
View file @
ef48eca9
...
...
@@ -100,7 +100,7 @@ check_directory(const char *path_utf8, const Path &path_fs)
#endif
const
DirectoryReader
reader
(
path_fs
);
if
(
reader
.
Failed
()
&&
errno
==
EACCES
)
if
(
reader
.
Has
Failed
()
&&
errno
==
EACCES
)
g_warning
(
"No permission to read directory: %s"
,
path_utf8
);
}
...
...
src/OtherCommands.cxx
View file @
ef48eca9
...
...
@@ -34,6 +34,7 @@
#include "ls.hxx"
#include "Volume.hxx"
#include "util/UriUtil.hxx"
#include "fs/Path.hxx"
extern
"C"
{
#include "stats.h"
...
...
@@ -117,9 +118,16 @@ handle_lsinfo(Client *client, int argc, char *argv[])
if
(
strncmp
(
uri
,
"file:///"
,
8
)
==
0
)
{
/* print information about an arbitrary local file */
const
char
*
path_utf8
=
uri
+
7
;
const
Path
path_fs
=
Path
::
FromUTF8
(
path_utf8
);
if
(
path_fs
.
IsNull
())
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"unsupported file name"
);
return
COMMAND_RETURN_ERROR
;
}
GError
*
error
=
NULL
;
if
(
!
client_allow_file
(
client
,
path_
utf8
,
&
error
))
if
(
!
client_allow_file
(
client
,
path_
fs
,
&
error
))
return
print_error
(
client
,
error
);
struct
song
*
song
=
song_file_load
(
path_utf8
,
NULL
);
...
...
src/PlaylistFile.cxx
View file @
ef48eca9
...
...
@@ -32,6 +32,7 @@
#include "Idle.hxx"
#include "fs/Path.hxx"
#include "fs/FileSystem.hxx"
#include "fs/DirectoryReader.hxx"
#include "util/UriUtil.hxx"
#include <assert.h>
...
...
@@ -77,7 +78,7 @@ spl_valid_name(const char *name_utf8)
strchr
(
name_utf8
,
'\r'
)
==
NULL
;
}
static
const
char
*
static
const
Path
&
spl_map
(
GError
**
error_r
)
{
const
Path
&
path_fs
=
map_spl_path
();
...
...
@@ -85,8 +86,7 @@ spl_map(GError **error_r)
g_set_error_literal
(
error_r
,
playlist_quark
(),
PLAYLIST_RESULT_DISABLED
,
"Stored playlists are disabled"
);
return
path_fs
.
c_str
();
return
path_fs
;
}
static
bool
...
...
@@ -105,8 +105,7 @@ spl_check_name(const char *name_utf8, GError **error_r)
static
Path
spl_map_to_fs
(
const
char
*
name_utf8
,
GError
**
error_r
)
{
if
(
spl_map
(
error_r
)
==
NULL
||
!
spl_check_name
(
name_utf8
,
error_r
))
if
(
spl_map
(
error_r
).
IsNull
()
||
!
spl_check_name
(
name_utf8
,
error_r
))
return
Path
::
Null
();
Path
path_fs
=
map_spl_utf8_to_fs
(
name_utf8
);
...
...
@@ -139,25 +138,24 @@ playlist_errno(GError **error_r)
static
bool
LoadPlaylistFileInfo
(
PlaylistInfo
&
info
,
const
char
*
parent_path_fs
,
const
char
*
name_fs
)
const
Path
&
parent_path_fs
,
const
Path
&
name_fs
)
{
size_t
name_length
=
strlen
(
name_fs
);
const
char
*
name_fs_str
=
name_fs
.
c_str
();
size_t
name_length
=
strlen
(
name_fs_str
);
if
(
name_length
<
sizeof
(
PLAYLIST_FILE_SUFFIX
)
||
memchr
(
name_fs
,
'\n'
,
name_length
)
!=
NULL
)
memchr
(
name_fs
_str
,
'\n'
,
name_length
)
!=
NULL
)
return
false
;
if
(
!
g_str_has_suffix
(
name_fs
,
PLAYLIST_FILE_SUFFIX
))
if
(
!
g_str_has_suffix
(
name_fs
_str
,
PLAYLIST_FILE_SUFFIX
))
return
false
;
char
*
path_fs
=
g_build_filename
(
parent_path_fs
,
name_fs
,
NULL
);
Path
path_fs
=
Path
::
Build
(
parent_path_fs
,
name_fs
);
struct
stat
st
;
int
ret
=
stat
(
path_fs
,
&
st
);
g_free
(
path_fs
);
if
(
ret
<
0
||
!
S_ISREG
(
st
.
st_mode
))
if
(
!
StatFile
(
path_fs
,
st
)
||
!
S_ISREG
(
st
.
st_mode
))
return
false
;
char
*
name
=
g_strndup
(
name_fs
,
char
*
name
=
g_strndup
(
name_fs
_str
,
name_length
+
1
-
sizeof
(
PLAYLIST_FILE_SUFFIX
));
std
::
string
name_utf8
=
Path
::
ToUTF8
(
name
);
g_free
(
name
);
...
...
@@ -174,24 +172,23 @@ ListPlaylistFiles(GError **error_r)
{
PlaylistVector
list
;
const
char
*
parent_path_fs
=
spl_map
(
error_r
);
if
(
parent_path_fs
==
NULL
)
const
Path
&
parent_path_fs
=
spl_map
(
error_r
);
if
(
parent_path_fs
.
IsNull
()
)
return
list
;
D
IR
*
dir
=
opendi
r
(
parent_path_fs
);
if
(
dir
==
NULL
)
{
D
irectoryReader
reade
r
(
parent_path_fs
);
if
(
reader
.
HasFailed
()
)
{
set_error_errno
(
error_r
);
return
list
;
}
PlaylistInfo
info
;
struct
dirent
*
ent
;
while
((
ent
=
readdir
(
dir
))
!=
NULL
)
{
if
(
LoadPlaylistFileInfo
(
info
,
parent_path_fs
,
ent
->
d_name
))
while
(
reader
.
ReadEntry
())
{
const
Path
entry
=
reader
.
GetEntry
();
if
(
LoadPlaylistFileInfo
(
info
,
parent_path_fs
,
ent
ry
))
list
.
push_back
(
std
::
move
(
info
));
}
closedir
(
dir
);
return
list
;
}
...
...
@@ -201,7 +198,7 @@ SavePlaylistFile(const PlaylistFileContents &contents, const char *utf8path,
{
assert
(
utf8path
!=
NULL
);
if
(
spl_map
(
error_r
)
==
NULL
)
if
(
spl_map
(
error_r
)
.
IsNull
()
)
return
false
;
const
Path
path_fs
=
spl_map_to_fs
(
utf8path
,
error_r
);
...
...
@@ -226,7 +223,7 @@ LoadPlaylistFile(const char *utf8path, GError **error_r)
{
PlaylistFileContents
contents
;
if
(
spl_map
(
error_r
)
==
NULL
)
if
(
spl_map
(
error_r
)
.
IsNull
()
)
return
contents
;
const
Path
path_fs
=
spl_map_to_fs
(
utf8path
,
error_r
);
...
...
@@ -302,7 +299,7 @@ spl_move_index(const char *utf8path, unsigned src, unsigned dest,
bool
spl_clear
(
const
char
*
utf8path
,
GError
**
error_r
)
{
if
(
spl_map
(
error_r
)
==
NULL
)
if
(
spl_map
(
error_r
)
.
IsNull
()
)
return
false
;
const
Path
path_fs
=
spl_map_to_fs
(
utf8path
,
error_r
);
...
...
@@ -365,7 +362,7 @@ spl_remove_index(const char *utf8path, unsigned pos, GError **error_r)
bool
spl_append_song
(
const
char
*
utf8path
,
struct
song
*
song
,
GError
**
error_r
)
{
if
(
spl_map
(
error_r
)
==
NULL
)
if
(
spl_map
(
error_r
)
.
IsNull
()
)
return
false
;
const
Path
path_fs
=
spl_map_to_fs
(
utf8path
,
error_r
);
...
...
@@ -454,7 +451,7 @@ spl_rename_internal(const Path &from_path_fs, const Path &to_path_fs,
bool
spl_rename
(
const
char
*
utf8from
,
const
char
*
utf8to
,
GError
**
error_r
)
{
if
(
spl_map
(
error_r
)
==
NULL
)
if
(
spl_map
(
error_r
)
.
IsNull
()
)
return
false
;
Path
from_path_fs
=
spl_map_to_fs
(
utf8from
,
error_r
);
...
...
src/QueueCommands.cxx
View file @
ef48eca9
...
...
@@ -32,6 +32,7 @@
#include "protocol/Result.hxx"
#include "ls.hxx"
#include "util/UriUtil.hxx"
#include "fs/Path.hxx"
#include <string.h>
...
...
@@ -42,13 +43,20 @@ handle_add(Client *client, G_GNUC_UNUSED int argc, char *argv[])
enum
playlist_result
result
;
if
(
strncmp
(
uri
,
"file:///"
,
8
)
==
0
)
{
const
char
*
path
=
uri
+
7
;
const
char
*
path_utf8
=
uri
+
7
;
const
Path
path_fs
=
Path
::
FromUTF8
(
path_utf8
);
if
(
path_fs
.
IsNull
())
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"unsupported file name"
);
return
COMMAND_RETURN_ERROR
;
}
GError
*
error
=
NULL
;
if
(
!
client_allow_file
(
client
,
path
,
&
error
))
if
(
!
client_allow_file
(
client
,
path
_fs
,
&
error
))
return
print_error
(
client
,
error
);
result
=
client
->
partition
.
AppendFile
(
path
);
result
=
client
->
partition
.
AppendFile
(
path
_utf8
);
return
print_playlist_result
(
client
,
result
);
}
...
...
@@ -78,13 +86,20 @@ handle_addid(Client *client, int argc, char *argv[])
enum
playlist_result
result
;
if
(
strncmp
(
uri
,
"file:///"
,
8
)
==
0
)
{
const
char
*
path
=
uri
+
7
;
const
char
*
path_utf8
=
uri
+
7
;
const
Path
path_fs
=
Path
::
FromUTF8
(
path_utf8
);
if
(
path_fs
.
IsNull
())
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
"unsupported file name"
);
return
COMMAND_RETURN_ERROR
;
}
GError
*
error
=
NULL
;
if
(
!
client_allow_file
(
client
,
path
,
&
error
))
if
(
!
client_allow_file
(
client
,
path
_fs
,
&
error
))
return
print_error
(
client
,
error
);
result
=
client
->
partition
.
AppendFile
(
path
,
&
added_id
);
result
=
client
->
partition
.
AppendFile
(
path
_utf8
,
&
added_id
);
}
else
{
if
(
uri_has_scheme
(
uri
)
&&
!
uri_supported_scheme
(
uri
))
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
...
...
src/
text_input_stream.c
→
src/
TextInputStream.cxx
View file @
ef48eca9
...
...
@@ -18,7 +18,7 @@
*/
#include "config.h"
#include "
text_input_stream.h
"
#include "
TextInputStream.hxx
"
#include "input_stream.h"
#include "util/fifo_buffer.h"
...
...
@@ -27,85 +27,66 @@
#include <assert.h>
#include <string.h>
struct
text_input_stream
{
struct
input_stream
*
is
;
struct
fifo_buffer
*
buffer
;
char
*
line
;
};
struct
text_input_stream
*
text_input_stream_new
(
struct
input_stream
*
is
)
TextInputStream
::
TextInputStream
(
struct
input_stream
*
_is
)
:
is
(
_is
),
buffer
(
fifo_buffer_new
(
4096
))
{
struct
text_input_stream
*
tis
=
g_new
(
struct
text_input_stream
,
1
);
tis
->
is
=
is
;
tis
->
buffer
=
fifo_buffer_new
(
4096
);
tis
->
line
=
NULL
;
return
tis
;
}
void
text_input_stream_free
(
struct
text_input_stream
*
tis
)
TextInputStream
::~
TextInputStream
()
{
fifo_buffer_free
(
tis
->
buffer
);
g_free
(
tis
->
line
);
g_free
(
tis
);
fifo_buffer_free
(
buffer
);
}
const
char
*
text_input_stream_read
(
struct
text_input_stream
*
tis
)
bool
TextInputStream
::
ReadLine
(
std
::
string
&
line
)
{
GError
*
error
=
NULL
;
GError
*
error
=
nullptr
;
void
*
dest
;
const
char
*
src
,
*
p
;
size_t
length
,
nbytes
;
g_free
(
tis
->
line
);
tis
->
line
=
NULL
;
do
{
dest
=
fifo_buffer_write
(
tis
->
buffer
,
&
length
);
if
(
dest
!=
NULL
&&
length
>=
2
)
{
dest
=
fifo_buffer_write
(
buffer
,
&
length
);
if
(
dest
!=
nullptr
&&
length
>=
2
)
{
/* reserve one byte for the null terminator if
the last line is not terminated by a
newline character */
--
length
;
nbytes
=
input_stream_lock_read
(
tis
->
is
,
dest
,
length
,
nbytes
=
input_stream_lock_read
(
is
,
dest
,
length
,
&
error
);
if
(
nbytes
>
0
)
fifo_buffer_append
(
tis
->
buffer
,
nbytes
);
else
if
(
error
!=
NULL
)
{
fifo_buffer_append
(
buffer
,
nbytes
);
else
if
(
error
!=
nullptr
)
{
g_warning
(
"%s"
,
error
->
message
);
g_error_free
(
error
);
return
NULL
;
return
false
;
}
}
else
nbytes
=
0
;
src
=
fifo_buffer_read
(
tis
->
buffer
,
&
length
);
if
(
src
==
NULL
)
return
NULL
;
auto
src_p
=
fifo_buffer_read
(
buffer
,
&
length
);
src
=
reinterpret_cast
<
const
char
*>
(
src_p
);
if
(
src
==
nullptr
)
return
false
;
p
=
memchr
(
src
,
'\n'
,
length
);
if
(
p
==
NULL
&&
nbytes
==
0
)
{
p
=
reinterpret_cast
<
const
char
*>
(
memchr
(
src
,
'\n'
,
length
)
);
if
(
p
==
nullptr
&&
nbytes
==
0
)
{
/* end of file (or line too long): terminate
the current line */
dest
=
fifo_buffer_write
(
tis
->
buffer
,
&
nbytes
);
assert
(
dest
!=
NULL
);
dest
=
fifo_buffer_write
(
buffer
,
&
nbytes
);
assert
(
dest
!=
nullptr
);
*
(
char
*
)
dest
=
'\n'
;
fifo_buffer_append
(
tis
->
buffer
,
1
);
fifo_buffer_append
(
buffer
,
1
);
}
}
while
(
p
==
NULL
);
}
while
(
p
==
nullptr
);
length
=
p
-
src
+
1
;
while
(
p
>
src
&&
g_ascii_isspace
(
p
[
-
1
]))
--
p
;
tis
->
line
=
g_strndup
(
src
,
p
-
src
);
fifo_buffer_consume
(
tis
->
buffer
,
length
);
return
t
is
->
lin
e
;
line
=
std
::
string
(
src
,
p
-
src
);
fifo_buffer_consume
(
buffer
,
length
);
return
t
ru
e
;
}
src/
text_input_stream.h
→
src/
TextInputStream.hxx
View file @
ef48eca9
...
...
@@ -17,36 +17,43 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_TEXT_INPUT_STREAM_H
#define MPD_TEXT_INPUT_STREAM_H
#ifndef MPD_TEXT_INPUT_STREAM_HXX
#define MPD_TEXT_INPUT_STREAM_HXX
#include <string>
struct
input_stream
;
struct
text_input_stream
;
struct
fifo_buffer
;
/**
* Wraps an existing #input_stream object into a #text_input_stream,
* to read its contents as text lines.
*
* @param is an open #input_stream object
* @return the new #text_input_stream object
*/
struct
text_input_stream
*
text_input_stream_new
(
struct
input_stream
*
is
);
class
TextInputStream
{
struct
input_stream
*
is
;
struct
fifo_buffer
*
buffer
;
public
:
/**
* Wraps an existing #input_stream object into a #TextInputStream,
* to read its contents as text lines.
*
* @param _is an open #input_stream object
*/
explicit
TextInputStream
(
struct
input_stream
*
_is
);
/**
* Frees the #text_input_stream object. Does not close or free the
* underlying #input_stream.
*/
void
text_input_stream_free
(
struct
text_input_stream
*
tis
);
/**
* Frees the #TextInputStream object. Does not close or free the
* underlying #input_stream.
*/
~
TextInputStream
();
/**
* Reads the next line from the stream.
*
* @return a line (newline character stripped), or NULL on end of file
* or error
*/
const
char
*
text_input_stream_read
(
struct
text_input_stream
*
tis
);
TextInputStream
(
const
TextInputStream
&
)
=
delete
;
TextInputStream
&
operator
=
(
const
TextInputStream
&
)
=
delete
;
/**
* Reads the next line from the stream with newline character stripped.
*
* @param line a string to put result to
* @return true if line is read successfully, false on end of file
* or error
*/
bool
ReadLine
(
std
::
string
&
line
);
};
#endif
src/
timer.c
→
src/
Timer.cxx
View file @
ef48eca9
...
...
@@ -18,7 +18,7 @@
*/
#include "config.h"
#include "
timer.h
"
#include "
Timer.hxx
"
#include "audio_format.h"
#include "clock.h"
...
...
@@ -28,46 +28,37 @@
#include <limits.h>
#include <stddef.h>
struct
timer
*
timer_new
(
const
struct
audio_format
*
af
)
Timer
::
Timer
(
const
struct
audio_format
&
af
)
:
time
(
0
),
started
(
false
),
rate
(
af
.
sample_rate
*
audio_format_frame_size
(
&
af
))
{
struct
timer
*
timer
=
g_new
(
struct
timer
,
1
);
timer
->
time
=
0
;
// us
timer
->
started
=
0
;
// false
timer
->
rate
=
af
->
sample_rate
*
audio_format_frame_size
(
af
);
// samples per second
return
timer
;
}
void
timer_free
(
struct
timer
*
timer
)
{
g_free
(
timer
);
}
void
timer_start
(
struct
timer
*
timer
)
void
Timer
::
Start
(
)
{
time
r
->
time
=
monotonic_clock_us
();
timer
->
started
=
1
;
time
=
monotonic_clock_us
();
started
=
true
;
}
void
timer_reset
(
struct
timer
*
timer
)
void
Timer
::
Reset
(
)
{
time
r
->
time
=
0
;
timer
->
started
=
0
;
time
=
0
;
started
=
false
;
}
void
timer_add
(
struct
timer
*
timer
,
int
size
)
void
Timer
::
Add
(
int
size
)
{
assert
(
timer
->
started
);
assert
(
started
);
// (size samples) / (rate samples per second) = duration seconds
// duration seconds * 1000000 = duration us
time
r
->
time
+=
((
uint64_t
)
size
*
1000000
)
/
timer
->
rate
;
time
+=
((
uint64_t
)
size
*
1000000
)
/
rate
;
}
unsigned
timer_delay
(
const
struct
timer
*
timer
)
unsigned
Timer
::
GetDelay
()
const
{
int64_t
delay
=
(
int64_t
)(
time
r
->
time
-
monotonic_clock_us
())
/
1000
;
int64_t
delay
=
(
int64_t
)(
time
-
monotonic_clock_us
())
/
1000
;
if
(
delay
<
0
)
return
0
;
...
...
@@ -77,13 +68,13 @@ timer_delay(const struct timer *timer)
return
delay
;
}
void
timer_sync
(
struct
timer
*
timer
)
void
Timer
::
Synchronize
()
const
{
int64_t
sleep_duration
;
assert
(
timer
->
started
);
assert
(
started
);
sleep_duration
=
time
r
->
time
-
monotonic_clock_us
();
sleep_duration
=
time
-
monotonic_clock_us
();
if
(
sleep_duration
>
0
)
g_usleep
(
sleep_duration
);
}
src/
timer.h
→
src/
Timer.hxx
View file @
ef48eca9
...
...
@@ -17,43 +17,33 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_TIMER_H
#define MPD_TIMER_H
#ifndef MPD_TIMER_H
XX
#define MPD_TIMER_H
XX
#include <stdint.h>
struct
audio_format
;
struct
t
imer
{
class
T
imer
{
uint64_t
time
;
int
started
;
int
rate
;
};
#ifdef __cplusplus
extern
"C"
{
#endif
bool
started
;
const
int
rate
;
public
:
explicit
Timer
(
const
struct
audio_format
&
af
);
struct
timer
*
timer_new
(
const
struct
audio_format
*
af
);
bool
IsStarted
()
const
{
return
started
;
}
void
timer_free
(
struct
timer
*
timer
);
void
Start
();
void
Reset
();
void
timer_start
(
struct
timer
*
timer
);
void
Add
(
int
size
);
void
timer_reset
(
struct
timer
*
timer
);
/**
* Returns the number of milliseconds to sleep to get back to sync.
*/
unsigned
GetDelay
()
const
;
void
timer_add
(
struct
timer
*
timer
,
int
size
);
/**
* Returns the number of milliseconds to sleep to get back to sync.
*/
unsigned
timer_delay
(
const
struct
timer
*
timer
);
void
timer_sync
(
struct
timer
*
timer
);
#ifdef __cplusplus
}
#endif
void
Synchronize
()
const
;
};
#endif
src/UpdateWalk.cxx
View file @
ef48eca9
...
...
@@ -34,6 +34,7 @@
#include "conf.h"
#include "fs/Path.hxx"
#include "fs/FileSystem.hxx"
#include "fs/DirectoryReader.hxx"
#include "util/UriUtil.hxx"
#include <glib.h>
...
...
@@ -102,7 +103,7 @@ remove_excluded_from_directory(Directory *directory,
directory_for_each_child_safe
(
child
,
n
,
directory
)
{
const
Path
name_fs
=
Path
::
FromUTF8
(
child
->
GetName
());
if
(
name_fs
.
IsNull
()
||
exclude_list
.
Check
(
name_fs
.
c_str
()
))
{
if
(
name_fs
.
IsNull
()
||
exclude_list
.
Check
(
name_fs
))
{
delete_directory
(
child
);
modified
=
true
;
}
...
...
@@ -113,7 +114,7 @@ remove_excluded_from_directory(Directory *directory,
assert
(
song
->
parent
==
directory
);
const
Path
name_fs
=
Path
::
FromUTF8
(
song
->
uri
);
if
(
name_fs
.
IsNull
()
||
exclude_list
.
Check
(
name_fs
.
c_str
()
))
{
if
(
name_fs
.
IsNull
()
||
exclude_list
.
Check
(
name_fs
))
{
delete_song
(
directory
,
song
);
modified
=
true
;
}
...
...
@@ -261,8 +262,9 @@ update_directory_child(Directory *directory,
/* we don't look at "." / ".." nor files with newlines in their name */
G_GNUC_PURE
static
bool
skip_path
(
const
char
*
path
)
static
bool
skip_path
(
const
Path
&
path_fs
)
{
const
char
*
path
=
path_fs
.
c_str
();
return
(
path
[
0
]
==
'.'
&&
path
[
1
]
==
0
)
||
(
path
[
0
]
==
'.'
&&
path
[
1
]
==
'.'
&&
path
[
2
]
==
0
)
||
strchr
(
path
,
'\n'
)
!=
NULL
;
...
...
@@ -277,20 +279,11 @@ skip_symlink(const Directory *directory, const char *utf8_name)
if
(
path_fs
.
IsNull
())
return
true
;
char
buffer
[
MPD_PATH_MAX
];
ssize_t
length
=
readlink
(
path_fs
.
c_str
(),
buffer
,
sizeof
(
buffer
));
if
(
length
<
0
)
const
Path
target
=
ReadLink
(
path_fs
);
if
(
target
.
IsNull
())
/* don't skip if this is not a symlink */
return
errno
!=
EINVAL
;
if
((
size_t
)
length
>=
sizeof
(
buffer
))
/* skip symlinks when the buffer is too small for the
link target */
return
true
;
/* null-terminate the buffer, because readlink() will not */
buffer
[
length
]
=
0
;
if
(
!
follow_inside_symlinks
&&
!
follow_outside_symlinks
)
{
/* ignore all symlinks */
return
true
;
...
...
@@ -299,16 +292,18 @@ skip_symlink(const Directory *directory, const char *utf8_name)
return
false
;
}
if
(
g_path_is_absolute
(
buffer
))
{
const
char
*
target_str
=
target
.
c_str
();
if
(
g_path_is_absolute
(
target_str
))
{
/* if the symlink points to an absolute path, see if
that path is inside the music directory */
const
char
*
relative
=
map_to_relative_path
(
buffe
r
);
return
relative
>
buffe
r
const
char
*
relative
=
map_to_relative_path
(
target_st
r
);
return
relative
>
target_st
r
?
!
follow_inside_symlinks
:
!
follow_outside_symlinks
;
}
const
char
*
p
=
buffe
r
;
const
char
*
p
=
target_st
r
;
while
(
*
p
==
'.'
)
{
if
(
p
[
1
]
==
'.'
&&
G_IS_DIR_SEPARATOR
(
p
[
2
]))
{
/* "../" moves to parent directory */
...
...
@@ -352,10 +347,12 @@ update_directory(Directory *directory, const struct stat *st)
if
(
path_fs
.
IsNull
())
return
false
;
DIR
*
dir
=
opendir
(
path_fs
.
c_str
());
if
(
!
dir
)
{
DirectoryReader
reader
(
path_fs
);
if
(
reader
.
HasFailed
())
{
int
error
=
errno
;
const
auto
path_utf8
=
path_fs
.
ToUTF8
();
g_warning
(
"Failed to open directory %s: %s"
,
path_
fs
.
c_str
(),
g_strerror
(
errno
));
path_
utf8
.
c_str
(),
g_strerror
(
error
));
return
false
;
}
...
...
@@ -367,15 +364,16 @@ update_directory(Directory *directory, const struct stat *st)
purge_deleted_from_directory
(
directory
);
struct
dirent
*
ent
;
while
((
ent
=
readdir
(
dir
)))
{
while
(
reader
.
ReadEntry
())
{
std
::
string
utf8
;
struct
stat
st2
;
if
(
skip_path
(
ent
->
d_name
)
||
exclude_list
.
Check
(
ent
->
d_name
))
const
Path
entry
=
reader
.
GetEntry
();
if
(
skip_path
(
entry
)
||
exclude_list
.
Check
(
entry
))
continue
;
utf8
=
Path
::
ToUTF8
(
ent
->
d_name
);
utf8
=
entry
.
ToUTF8
(
);
if
(
utf8
.
empty
())
continue
;
...
...
@@ -390,8 +388,6 @@ update_directory(Directory *directory, const struct stat *st)
modified
|=
delete_name_in
(
directory
,
utf8
.
c_str
());
}
closedir
(
dir
);
directory
->
mtime
=
st
->
st_mtime
;
return
true
;
...
...
src/clock.h
View file @
ef48eca9
...
...
@@ -24,6 +24,10 @@
#include <stdint.h>
#ifdef __cplusplus
extern
"C"
{
#endif
/**
* Returns the value of a monotonic clock in milliseconds.
*/
...
...
@@ -38,4 +42,8 @@ gcc_pure
uint64_t
monotonic_clock_us
(
void
);
#ifdef __cplusplus
}
#endif
#endif
src/decoder/F
LAC
Common.cxx
→
src/decoder/F
lac
Common.cxx
View file @
ef48eca9
...
...
@@ -22,9 +22,9 @@
*/
#include "config.h"
#include "F
LAC
Common.hxx"
#include "F
LACMetaD
ata.hxx"
#include "F
LAC_PCM
.hxx"
#include "F
lac
Common.hxx"
#include "F
lacMetad
ata.hxx"
#include "F
lacPcm
.hxx"
extern
"C"
{
#include "audio_check.h"
...
...
@@ -36,7 +36,7 @@ extern "C" {
flac_data
::
flac_data
(
struct
decoder
*
_decoder
,
struct
input_stream
*
_input_stream
)
:
F
LAC
Input
(
_input_stream
,
_decoder
),
:
F
lac
Input
(
_input_stream
,
_decoder
),
initialized
(
false
),
unsupported
(
false
),
total_frames
(
0
),
first_frame
(
0
),
next_frame
(
0
),
position
(
0
),
decoder
(
_decoder
),
input_stream
(
_input_stream
),
...
...
src/decoder/F
LAC
Common.hxx
→
src/decoder/F
lac
Common.hxx
View file @
ef48eca9
...
...
@@ -24,7 +24,7 @@
#ifndef MPD_FLAC_COMMON_HXX
#define MPD_FLAC_COMMON_HXX
#include "F
LAC
Input.hxx"
#include "F
lac
Input.hxx"
#include "decoder_api.h"
extern
"C"
{
...
...
@@ -37,7 +37,7 @@ extern "C" {
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "flac"
struct
flac_data
:
public
F
LAC
Input
{
struct
flac_data
:
public
F
lac
Input
{
struct
pcm_buffer
buffer
;
/**
...
...
src/decoder/F
LAC
DecoderPlugin.cxx
→
src/decoder/F
lac
DecoderPlugin.cxx
View file @
ef48eca9
...
...
@@ -18,9 +18,9 @@
*/
#include "config.h"
/* must be first for large file support */
#include "F
LAC
DecoderPlugin.h"
#include "F
LAC
Common.hxx"
#include "F
LACMetaD
ata.hxx"
#include "F
lac
DecoderPlugin.h"
#include "F
lac
Common.hxx"
#include "F
lacMetad
ata.hxx"
#include "OggCodec.hxx"
#include <glib.h>
...
...
@@ -87,7 +87,7 @@ static bool
flac_scan_file
(
const
char
*
file
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
F
LAC
MetadataChain
chain
;
F
lac
MetadataChain
chain
;
if
(
!
chain
.
Read
(
file
))
{
g_debug
(
"Failed to read FLAC tags: %s"
,
chain
.
GetStatusString
());
...
...
@@ -102,7 +102,7 @@ static bool
flac_scan_stream
(
struct
input_stream
*
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
F
LAC
MetadataChain
chain
;
F
lac
MetadataChain
chain
;
if
(
!
chain
.
Read
(
is
))
{
g_debug
(
"Failed to read FLAC tags: %s"
,
chain
.
GetStatusString
());
...
...
@@ -214,14 +214,14 @@ static FLAC__StreamDecoderInitStatus
stream_init_oggflac
(
FLAC__StreamDecoder
*
flac_dec
,
struct
flac_data
*
data
)
{
return
FLAC__stream_decoder_init_ogg_stream
(
flac_dec
,
F
LAC
Input
::
Read
,
F
LAC
Input
::
Seek
,
F
LAC
Input
::
Tell
,
F
LAC
Input
::
Length
,
F
LAC
Input
::
Eof
,
F
lac
Input
::
Read
,
F
lac
Input
::
Seek
,
F
lac
Input
::
Tell
,
F
lac
Input
::
Length
,
F
lac
Input
::
Eof
,
flac_write_cb
,
flacMetadata
,
F
LAC
Input
::
Error
,
F
lac
Input
::
Error
,
data
);
}
...
...
@@ -229,14 +229,14 @@ static FLAC__StreamDecoderInitStatus
stream_init_flac
(
FLAC__StreamDecoder
*
flac_dec
,
struct
flac_data
*
data
)
{
return
FLAC__stream_decoder_init_stream
(
flac_dec
,
F
LAC
Input
::
Read
,
F
LAC
Input
::
Seek
,
F
LAC
Input
::
Tell
,
F
LAC
Input
::
Length
,
F
LAC
Input
::
Eof
,
F
lac
Input
::
Read
,
F
lac
Input
::
Seek
,
F
lac
Input
::
Tell
,
F
lac
Input
::
Length
,
F
lac
Input
::
Eof
,
flac_write_cb
,
flacMetadata
,
F
LAC
Input
::
Error
,
F
lac
Input
::
Error
,
data
);
}
...
...
@@ -298,7 +298,7 @@ static bool
oggflac_scan_file
(
const
char
*
file
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
F
LAC
MetadataChain
chain
;
F
lac
MetadataChain
chain
;
if
(
!
chain
.
ReadOgg
(
file
))
{
g_debug
(
"Failed to read OggFLAC tags: %s"
,
chain
.
GetStatusString
());
...
...
@@ -313,7 +313,7 @@ static bool
oggflac_scan_stream
(
struct
input_stream
*
is
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
F
LAC
MetadataChain
chain
;
F
lac
MetadataChain
chain
;
if
(
!
chain
.
ReadOgg
(
is
))
{
g_debug
(
"Failed to read OggFLAC tags: %s"
,
chain
.
GetStatusString
());
...
...
src/decoder/F
LAC
DecoderPlugin.h
→
src/decoder/F
lac
DecoderPlugin.h
View file @
ef48eca9
File moved
src/decoder/F
LAC
IOHandle.cxx
→
src/decoder/F
lac
IOHandle.cxx
View file @
ef48eca9
...
...
@@ -18,14 +18,14 @@
*/
#include "config.h"
#include "F
LAC
IOHandle.hxx"
#include "F
lac
IOHandle.hxx"
#include "io_error.h"
#include "gcc.h"
#include <errno.h>
static
size_t
F
LAC
IORead
(
void
*
ptr
,
size_t
size
,
size_t
nmemb
,
FLAC__IOHandle
handle
)
F
lac
IORead
(
void
*
ptr
,
size_t
size
,
size_t
nmemb
,
FLAC__IOHandle
handle
)
{
input_stream
*
is
=
(
input_stream
*
)
handle
;
...
...
@@ -63,7 +63,7 @@ FLACIORead(void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle)
}
static
int
F
LAC
IOSeek
(
FLAC__IOHandle
handle
,
FLAC__int64
offset
,
int
whence
)
F
lac
IOSeek
(
FLAC__IOHandle
handle
,
FLAC__int64
offset
,
int
whence
)
{
input_stream
*
is
=
(
input_stream
*
)
handle
;
...
...
@@ -71,7 +71,7 @@ FLACIOSeek(FLAC__IOHandle handle, FLAC__int64 offset, int whence)
}
static
FLAC__int64
F
LAC
IOTell
(
FLAC__IOHandle
handle
)
F
lac
IOTell
(
FLAC__IOHandle
handle
)
{
input_stream
*
is
=
(
input_stream
*
)
handle
;
...
...
@@ -79,7 +79,7 @@ FLACIOTell(FLAC__IOHandle handle)
}
static
int
F
LAC
IOEof
(
FLAC__IOHandle
handle
)
F
lac
IOEof
(
FLAC__IOHandle
handle
)
{
input_stream
*
is
=
(
input_stream
*
)
handle
;
...
...
@@ -87,7 +87,7 @@ FLACIOEof(FLAC__IOHandle handle)
}
static
int
F
LAC
IOClose
(
gcc_unused
FLAC__IOHandle
handle
)
F
lac
IOClose
(
gcc_unused
FLAC__IOHandle
handle
)
{
/* no-op because the libFLAC caller is repsonsible for closing
the #input_stream */
...
...
@@ -96,19 +96,19 @@ FLACIOClose(gcc_unused FLAC__IOHandle handle)
}
const
FLAC__IOCallbacks
flac_io_callbacks
=
{
F
LAC
IORead
,
F
lac
IORead
,
nullptr
,
nullptr
,
nullptr
,
F
LAC
IOEof
,
F
LAC
IOClose
,
F
lac
IOEof
,
F
lac
IOClose
,
};
const
FLAC__IOCallbacks
flac_io_callbacks_seekable
=
{
F
LAC
IORead
,
F
lac
IORead
,
nullptr
,
F
LAC
IOSeek
,
F
LAC
IOTell
,
F
LAC
IOEof
,
F
LAC
IOClose
,
F
lac
IOSeek
,
F
lac
IOTell
,
F
lac
IOEof
,
F
lac
IOClose
,
};
src/decoder/F
LAC
IOHandle.hxx
→
src/decoder/F
lac
IOHandle.hxx
View file @
ef48eca9
...
...
@@ -29,13 +29,13 @@ extern const FLAC__IOCallbacks flac_io_callbacks;
extern
const
FLAC__IOCallbacks
flac_io_callbacks_seekable
;
static
inline
FLAC__IOHandle
ToF
LAC
IOHandle
(
input_stream
*
is
)
ToF
lac
IOHandle
(
input_stream
*
is
)
{
return
(
FLAC__IOHandle
)
is
;
}
static
inline
const
FLAC__IOCallbacks
&
GetF
LAC
IOCallbacks
(
const
input_stream
*
is
)
GetF
lac
IOCallbacks
(
const
input_stream
*
is
)
{
return
is
->
seekable
?
flac_io_callbacks_seekable
...
...
src/decoder/F
LAC
Input.cxx
→
src/decoder/F
lac
Input.cxx
View file @
ef48eca9
...
...
@@ -18,13 +18,13 @@
*/
#include "config.h"
#include "F
LAC
Input.hxx"
#include "F
lac
Input.hxx"
#include "decoder_api.h"
#include "gcc.h"
#include "InputStream.hxx"
FLAC__StreamDecoderReadStatus
F
LAC
Input
::
Read
(
FLAC__byte
buffer
[],
size_t
*
bytes
)
F
lac
Input
::
Read
(
FLAC__byte
buffer
[],
size_t
*
bytes
)
{
size_t
r
=
decoder_read
(
decoder
,
input_stream
,
(
void
*
)
buffer
,
*
bytes
);
*
bytes
=
r
;
...
...
@@ -42,7 +42,7 @@ FLACInput::Read(FLAC__byte buffer[], size_t *bytes)
}
FLAC__StreamDecoderSeekStatus
F
LAC
Input
::
Seek
(
FLAC__uint64
absolute_byte_offset
)
F
lac
Input
::
Seek
(
FLAC__uint64
absolute_byte_offset
)
{
if
(
!
input_stream
->
seekable
)
return
FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
;
...
...
@@ -56,7 +56,7 @@ FLACInput::Seek(FLAC__uint64 absolute_byte_offset)
}
FLAC__StreamDecoderTellStatus
F
LAC
Input
::
Tell
(
FLAC__uint64
*
absolute_byte_offset
)
F
lac
Input
::
Tell
(
FLAC__uint64
*
absolute_byte_offset
)
{
if
(
!
input_stream
->
seekable
)
return
FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
;
...
...
@@ -66,7 +66,7 @@ FLACInput::Tell(FLAC__uint64 *absolute_byte_offset)
}
FLAC__StreamDecoderLengthStatus
F
LAC
Input
::
Length
(
FLAC__uint64
*
stream_length
)
F
lac
Input
::
Length
(
FLAC__uint64
*
stream_length
)
{
if
(
input_stream
->
size
<
0
)
return
FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
;
...
...
@@ -76,7 +76,7 @@ FLACInput::Length(FLAC__uint64 *stream_length)
}
FLAC__bool
F
LAC
Input
::
Eof
()
F
lac
Input
::
Eof
()
{
return
(
decoder
!=
nullptr
&&
decoder_get_command
(
decoder
)
!=
DECODE_COMMAND_NONE
&&
...
...
@@ -85,7 +85,7 @@ FLACInput::Eof()
}
void
F
LAC
Input
::
Error
(
FLAC__StreamDecoderErrorStatus
status
)
F
lac
Input
::
Error
(
FLAC__StreamDecoderErrorStatus
status
)
{
if
(
decoder
==
nullptr
||
decoder_get_command
(
decoder
)
!=
DECODE_COMMAND_STOP
)
...
...
@@ -93,56 +93,56 @@ FLACInput::Error(FLAC__StreamDecoderErrorStatus status)
}
FLAC__StreamDecoderReadStatus
F
LAC
Input
::
Read
(
gcc_unused
const
FLAC__StreamDecoder
*
flac_decoder
,
F
lac
Input
::
Read
(
gcc_unused
const
FLAC__StreamDecoder
*
flac_decoder
,
FLAC__byte
buffer
[],
size_t
*
bytes
,
void
*
client_data
)
{
F
LACInput
*
i
=
(
FLAC
Input
*
)
client_data
;
F
lacInput
*
i
=
(
Flac
Input
*
)
client_data
;
return
i
->
Read
(
buffer
,
bytes
);
}
FLAC__StreamDecoderSeekStatus
F
LAC
Input
::
Seek
(
gcc_unused
const
FLAC__StreamDecoder
*
flac_decoder
,
F
lac
Input
::
Seek
(
gcc_unused
const
FLAC__StreamDecoder
*
flac_decoder
,
FLAC__uint64
absolute_byte_offset
,
void
*
client_data
)
{
F
LACInput
*
i
=
(
FLAC
Input
*
)
client_data
;
F
lacInput
*
i
=
(
Flac
Input
*
)
client_data
;
return
i
->
Seek
(
absolute_byte_offset
);
}
FLAC__StreamDecoderTellStatus
F
LAC
Input
::
Tell
(
gcc_unused
const
FLAC__StreamDecoder
*
flac_decoder
,
F
lac
Input
::
Tell
(
gcc_unused
const
FLAC__StreamDecoder
*
flac_decoder
,
FLAC__uint64
*
absolute_byte_offset
,
void
*
client_data
)
{
F
LACInput
*
i
=
(
FLAC
Input
*
)
client_data
;
F
lacInput
*
i
=
(
Flac
Input
*
)
client_data
;
return
i
->
Tell
(
absolute_byte_offset
);
}
FLAC__StreamDecoderLengthStatus
F
LAC
Input
::
Length
(
gcc_unused
const
FLAC__StreamDecoder
*
flac_decoder
,
F
lac
Input
::
Length
(
gcc_unused
const
FLAC__StreamDecoder
*
flac_decoder
,
FLAC__uint64
*
stream_length
,
void
*
client_data
)
{
F
LACInput
*
i
=
(
FLAC
Input
*
)
client_data
;
F
lacInput
*
i
=
(
Flac
Input
*
)
client_data
;
return
i
->
Length
(
stream_length
);
}
FLAC__bool
F
LAC
Input
::
Eof
(
gcc_unused
const
FLAC__StreamDecoder
*
flac_decoder
,
F
lac
Input
::
Eof
(
gcc_unused
const
FLAC__StreamDecoder
*
flac_decoder
,
void
*
client_data
)
{
F
LACInput
*
i
=
(
FLAC
Input
*
)
client_data
;
F
lacInput
*
i
=
(
Flac
Input
*
)
client_data
;
return
i
->
Eof
();
}
void
F
LAC
Input
::
Error
(
gcc_unused
const
FLAC__StreamDecoder
*
decoder
,
F
lac
Input
::
Error
(
gcc_unused
const
FLAC__StreamDecoder
*
decoder
,
FLAC__StreamDecoderErrorStatus
status
,
void
*
client_data
)
{
F
LACInput
*
i
=
(
FLAC
Input
*
)
client_data
;
F
lacInput
*
i
=
(
Flac
Input
*
)
client_data
;
i
->
Error
(
status
);
}
...
...
src/decoder/F
LAC
Input.hxx
→
src/decoder/F
lac
Input.hxx
View file @
ef48eca9
...
...
@@ -26,13 +26,13 @@
* This class wraps an #input_stream in libFLAC stream decoder
* callbacks.
*/
class
F
LAC
Input
{
class
F
lac
Input
{
struct
decoder
*
decoder
;
struct
input_stream
*
input_stream
;
public
:
F
LAC
Input
(
struct
input_stream
*
_input_stream
,
F
lac
Input
(
struct
input_stream
*
_input_stream
,
struct
decoder
*
_decoder
=
nullptr
)
:
decoder
(
_decoder
),
input_stream
(
_input_stream
)
{}
...
...
src/decoder/F
LACMetaD
ata.cxx
→
src/decoder/F
lacMetad
ata.cxx
View file @
ef48eca9
...
...
@@ -18,7 +18,7 @@
*/
#include "config.h"
#include "F
LACMetaD
ata.hxx"
#include "F
lacMetad
ata.hxx"
extern
"C"
{
#include "XiphTags.h"
...
...
@@ -239,7 +239,7 @@ flac_vorbis_comments_to_tag(struct tag *tag,
}
void
F
LAC
MetadataChain
::
Scan
(
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
F
lac
MetadataChain
::
Scan
(
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
FLACMetadataIterator
iterator
(
*
this
);
...
...
src/decoder/F
LACMetaD
ata.hxx
→
src/decoder/F
lacMetad
ata.hxx
View file @
ef48eca9
...
...
@@ -21,19 +21,19 @@
#define MPD_FLAC_METADATA_H
#include "gcc.h"
#include "F
LAC
IOHandle.hxx"
#include "F
lac
IOHandle.hxx"
#include <FLAC/metadata.h>
#include <assert.h>
class
F
LAC
MetadataChain
{
class
F
lac
MetadataChain
{
FLAC__Metadata_Chain
*
chain
;
public
:
F
LAC
MetadataChain
()
:
chain
(
::
FLAC__metadata_chain_new
())
{}
F
lac
MetadataChain
()
:
chain
(
::
FLAC__metadata_chain_new
())
{}
~
F
LAC
MetadataChain
()
{
~
F
lac
MetadataChain
()
{
::
FLAC__metadata_chain_delete
(
chain
);
}
...
...
@@ -52,7 +52,7 @@ public:
}
bool
Read
(
input_stream
*
is
)
{
return
Read
(
::
ToF
LACIOHandle
(
is
),
::
GetFLAC
IOCallbacks
(
is
));
return
Read
(
::
ToF
lacIOHandle
(
is
),
::
GetFlac
IOCallbacks
(
is
));
}
bool
ReadOgg
(
const
char
*
path
)
{
...
...
@@ -66,7 +66,7 @@ public:
}
bool
ReadOgg
(
input_stream
*
is
)
{
return
ReadOgg
(
::
ToF
LACIOHandle
(
is
),
::
GetFLAC
IOCallbacks
(
is
));
return
ReadOgg
(
::
ToF
lacIOHandle
(
is
),
::
GetFlac
IOCallbacks
(
is
));
}
gcc_pure
...
...
@@ -88,7 +88,7 @@ class FLACMetadataIterator {
public
:
FLACMetadataIterator
()
:
iterator
(
::
FLAC__metadata_iterator_new
())
{}
FLACMetadataIterator
(
F
LAC
MetadataChain
&
chain
)
FLACMetadataIterator
(
F
lac
MetadataChain
&
chain
)
:
iterator
(
::
FLAC__metadata_iterator_new
())
{
::
FLAC__metadata_iterator_init
(
iterator
,
(
FLAC__Metadata_Chain
*
)
chain
);
...
...
src/decoder/F
LAC_PCM
.cxx
→
src/decoder/F
lacPcm
.cxx
View file @
ef48eca9
...
...
@@ -18,7 +18,7 @@
*/
#include "config.h"
#include "F
LAC_PCM
.hxx"
#include "F
lacPcm
.hxx"
#include <assert.h>
...
...
src/decoder/F
LAC_PCM
.hxx
→
src/decoder/F
lacPcm
.hxx
View file @
ef48eca9
File moved
src/fs/DirectoryReader.hxx
View file @
ef48eca9
...
...
@@ -47,14 +47,14 @@ public:
* Destroys this instance.
*/
~
DirectoryReader
()
{
if
(
!
Failed
())
if
(
!
Has
Failed
())
closedir
(
dirp
);
}
/**
* Checks if directory failed to open.
*/
bool
Failed
()
const
{
bool
Has
Failed
()
const
{
return
dirp
==
nullptr
;
}
...
...
@@ -62,7 +62,7 @@ public:
* Checks if directory entry is available.
*/
bool
HasEntry
()
const
{
assert
(
!
Failed
());
assert
(
!
Has
Failed
());
return
ent
!=
nullptr
;
}
...
...
@@ -70,7 +70,7 @@ public:
* Reads next directory entry.
*/
bool
ReadEntry
()
{
assert
(
!
Failed
());
assert
(
!
Has
Failed
());
ent
=
readdir
(
dirp
);
return
HasEntry
();
}
...
...
src/output/FifoOutputPlugin.cxx
View file @
ef48eca9
...
...
@@ -20,7 +20,7 @@
#include "config.h"
#include "FifoOutputPlugin.hxx"
#include "output_api.h"
#include "
timer.h
"
#include "
Timer.hxx
"
#include "fd_util.h"
#include "open.h"
...
...
@@ -44,7 +44,7 @@ struct FifoOutput {
int
input
;
int
output
;
bool
created
;
struct
t
imer
*
timer
;
T
imer
*
timer
;
FifoOutput
()
:
path
(
nullptr
),
input
(
-
1
),
output
(
-
1
),
created
(
false
)
{}
...
...
@@ -232,7 +232,7 @@ fifo_output_open(struct audio_output *ao, struct audio_format *audio_format,
{
FifoOutput
*
fd
=
(
FifoOutput
*
)
ao
;
fd
->
timer
=
timer_new
(
audio_format
);
fd
->
timer
=
new
Timer
(
*
audio_format
);
return
true
;
}
...
...
@@ -242,7 +242,7 @@ fifo_output_close(struct audio_output *ao)
{
FifoOutput
*
fd
=
(
FifoOutput
*
)
ao
;
timer_free
(
fd
->
timer
)
;
delete
fd
->
timer
;
}
static
void
...
...
@@ -252,7 +252,7 @@ fifo_output_cancel(struct audio_output *ao)
char
buf
[
FIFO_BUFFER_SIZE
];
int
bytes
=
1
;
timer_reset
(
fd
->
timer
);
fd
->
timer
->
Reset
(
);
while
(
bytes
>
0
&&
errno
!=
EINTR
)
bytes
=
read
(
fd
->
input
,
buf
,
FIFO_BUFFER_SIZE
);
...
...
@@ -268,8 +268,8 @@ fifo_output_delay(struct audio_output *ao)
{
FifoOutput
*
fd
=
(
FifoOutput
*
)
ao
;
return
fd
->
timer
->
started
?
timer_delay
(
fd
->
timer
)
return
fd
->
timer
->
IsStarted
()
?
fd
->
timer
->
GetDelay
(
)
:
0
;
}
...
...
@@ -280,9 +280,9 @@ fifo_output_play(struct audio_output *ao, const void *chunk, size_t size,
FifoOutput
*
fd
=
(
FifoOutput
*
)
ao
;
ssize_t
bytes
;
if
(
!
fd
->
timer
->
started
)
timer_start
(
fd
->
timer
);
timer_add
(
fd
->
timer
,
size
);
if
(
!
fd
->
timer
->
IsStarted
()
)
fd
->
timer
->
Start
(
);
fd
->
timer
->
Add
(
size
);
while
(
true
)
{
bytes
=
write
(
fd
->
output
,
chunk
,
size
);
...
...
src/output/HttpdInternal.hxx
View file @
ef48eca9
...
...
@@ -26,7 +26,7 @@
#define MPD_OUTPUT_HTTPD_INTERNAL_H
#include "OutputInternal.hxx"
#include "
timer.h
"
#include "
Timer.hxx
"
#include "thread/Mutex.hxx"
#include "event/ServerSocket.hxx"
...
...
@@ -72,10 +72,10 @@ struct HttpdOutput final : private ServerSocket {
mutable
Mutex
mutex
;
/**
* A #
t
imer object to synchronize this output with the
* A #
T
imer object to synchronize this output with the
* wallclock.
*/
struct
t
imer
*
timer
;
T
imer
*
timer
;
/**
* The header page, which is sent to every client on connect.
...
...
src/output/HttpdOutputPlugin.cxx
View file @
ef48eca9
...
...
@@ -320,7 +320,7 @@ HttpdOutput::Open(struct audio_format *audio_format, GError **error_r)
/* initialize other attributes */
clients_cnt
=
0
;
timer
=
timer_new
(
audio_format
);
timer
=
new
Timer
(
*
audio_format
);
open
=
true
;
...
...
@@ -346,7 +346,7 @@ HttpdOutput::Close()
open
=
false
;
timer_free
(
timer
)
;
delete
timer
;
clients
.
clear
();
...
...
@@ -398,7 +398,7 @@ httpd_output_delay(struct audio_output *ao)
then httpd_output_pause() will not do anything, it
will not fill the buffer and it will not update the
timer; therefore, we reset the timer here */
timer_reset
(
httpd
->
timer
);
httpd
->
timer
->
Reset
(
);
/* some arbitrary delay that is long enough to avoid
consuming too much CPU, and short enough to notice
...
...
@@ -406,8 +406,8 @@ httpd_output_delay(struct audio_output *ao)
return
1000
;
}
return
httpd
->
timer
->
started
?
timer_delay
(
httpd
->
timer
)
return
httpd
->
timer
->
IsStarted
()
?
httpd
->
timer
->
GetDelay
(
)
:
0
;
}
...
...
@@ -463,9 +463,9 @@ httpd_output_play(struct audio_output *ao, const void *chunk, size_t size,
return
0
;
}
if
(
!
httpd
->
timer
->
started
)
timer_start
(
httpd
->
timer
);
timer_add
(
httpd
->
timer
,
size
);
if
(
!
httpd
->
timer
->
IsStarted
()
)
httpd
->
timer
->
Start
(
);
httpd
->
timer
->
Add
(
size
);
return
size
;
}
...
...
src/output/NullOutputPlugin.cxx
View file @
ef48eca9
...
...
@@ -20,7 +20,7 @@
#include "config.h"
#include "NullOutputPlugin.hxx"
#include "output_api.h"
#include "
timer.h
"
#include "
Timer.hxx
"
#include <assert.h>
...
...
@@ -29,7 +29,7 @@ struct NullOutput {
bool
sync
;
struct
t
imer
*
timer
;
T
imer
*
timer
;
bool
Initialize
(
const
config_param
*
param
,
GError
**
error_r
)
{
return
ao_base_init
(
&
base
,
&
null_output_plugin
,
param
,
...
...
@@ -72,7 +72,7 @@ null_open(struct audio_output *ao, struct audio_format *audio_format,
NullOutput
*
nd
=
(
NullOutput
*
)
ao
;
if
(
nd
->
sync
)
nd
->
timer
=
timer_new
(
audio_format
);
nd
->
timer
=
new
Timer
(
*
audio_format
);
return
true
;
}
...
...
@@ -83,7 +83,7 @@ null_close(struct audio_output *ao)
NullOutput
*
nd
=
(
NullOutput
*
)
ao
;
if
(
nd
->
sync
)
timer_free
(
nd
->
timer
)
;
delete
nd
->
timer
;
}
static
unsigned
...
...
@@ -91,8 +91,8 @@ null_delay(struct audio_output *ao)
{
NullOutput
*
nd
=
(
NullOutput
*
)
ao
;
return
nd
->
sync
&&
nd
->
timer
->
started
?
timer_delay
(
nd
->
timer
)
return
nd
->
sync
&&
nd
->
timer
->
IsStarted
()
?
nd
->
timer
->
GetDelay
(
)
:
0
;
}
...
...
@@ -101,14 +101,14 @@ null_play(struct audio_output *ao, gcc_unused const void *chunk, size_t size,
gcc_unused
GError
**
error
)
{
NullOutput
*
nd
=
(
NullOutput
*
)
ao
;
struct
t
imer
*
timer
=
nd
->
timer
;
T
imer
*
timer
=
nd
->
timer
;
if
(
!
nd
->
sync
)
return
size
;
if
(
!
timer
->
started
)
timer
_start
(
timer
);
timer
_add
(
timer
,
size
);
if
(
!
timer
->
IsStarted
()
)
timer
->
Start
(
);
timer
->
Add
(
size
);
return
size
;
}
...
...
@@ -121,7 +121,7 @@ null_cancel(struct audio_output *ao)
if
(
!
nd
->
sync
)
return
;
timer_reset
(
nd
->
timer
);
nd
->
timer
->
Reset
(
);
}
const
struct
audio_output_plugin
null_output_plugin
=
{
...
...
src/playlist/CuePlaylistPlugin.cxx
View file @
ef48eca9
...
...
@@ -24,10 +24,7 @@
#include "song.h"
#include "input_stream.h"
#include "cue/CueParser.hxx"
extern
"C"
{
#include "text_input_stream.h"
}
#include "TextInputStream.hxx"
#include <glib.h>
#include <assert.h>
...
...
@@ -40,16 +37,15 @@ struct CuePlaylist {
struct
playlist_provider
base
;
struct
input_stream
*
is
;
struct
text_input_stream
*
tis
;
TextInputStream
tis
;
CueParser
parser
;
CuePlaylist
(
struct
input_stream
*
_is
)
:
is
(
_is
),
tis
(
text_input_stream_new
(
is
)
)
{
:
is
(
_is
),
tis
(
is
)
{
playlist_provider_init
(
&
base
,
&
cue_playlist_plugin
);
}
~
CuePlaylist
()
{
text_input_stream_free
(
tis
);
}
};
...
...
@@ -76,9 +72,9 @@ cue_playlist_read(struct playlist_provider *_playlist)
if
(
song
!=
NULL
)
return
song
;
const
char
*
line
;
while
(
(
line
=
text_input_stream_read
(
playlist
->
tis
))
!=
NULL
)
{
playlist
->
parser
.
Feed
(
line
);
std
::
string
line
;
while
(
playlist
->
tis
.
ReadLine
(
line
)
)
{
playlist
->
parser
.
Feed
(
line
.
c_str
()
);
song
=
playlist
->
parser
.
Get
();
if
(
song
!=
NULL
)
return
song
;
...
...
src/playlist/ExtM3uPlaylistPlugin.cxx
View file @
ef48eca9
...
...
@@ -23,10 +23,7 @@
#include "song.h"
#include "tag.h"
#include "util/StringUtil.hxx"
extern
"C"
{
#include "text_input_stream.h"
}
#include "TextInputStream.hxx"
#include <glib.h>
...
...
@@ -36,20 +33,21 @@ extern "C" {
struct
ExtM3uPlaylist
{
struct
playlist_provider
base
;
struct
text_input_s
tream
*
tis
;
TextInputS
tream
*
tis
;
};
static
struct
playlist_provider
*
extm3u_open_stream
(
struct
input_stream
*
is
)
{
ExtM3uPlaylist
*
playlist
=
g_new
(
ExtM3uPlaylist
,
1
);
playlist
->
tis
=
text_input_stream_new
(
is
);
playlist
->
tis
=
new
TextInputStream
(
is
);
const
char
*
line
=
text_input_stream_read
(
playlist
->
tis
);
if
(
line
==
NULL
||
strcmp
(
line
,
"#EXTM3U"
)
!=
0
)
{
std
::
string
line
;
if
(
!
playlist
->
tis
->
ReadLine
(
line
)
||
strcmp
(
line
.
c_str
(),
"#EXTM3U"
)
!=
0
)
{
/* no EXTM3U header: fall back to the plain m3u
plugin */
text_input_stream_free
(
playlist
->
tis
)
;
delete
playlist
->
tis
;
g_free
(
playlist
);
return
NULL
;
}
...
...
@@ -63,7 +61,7 @@ extm3u_close(struct playlist_provider *_playlist)
{
ExtM3uPlaylist
*
playlist
=
(
ExtM3uPlaylist
*
)
_playlist
;
text_input_stream_free
(
playlist
->
tis
)
;
delete
playlist
->
tis
;
g_free
(
playlist
);
}
...
...
@@ -112,29 +110,31 @@ extm3u_read(struct playlist_provider *_playlist)
{
ExtM3uPlaylist
*
playlist
=
(
ExtM3uPlaylist
*
)
_playlist
;
struct
tag
*
tag
=
NULL
;
const
char
*
line
;
std
::
string
line
;
const
char
*
line_s
;
struct
song
*
song
;
do
{
line
=
text_input_stream_read
(
playlist
->
tis
);
if
(
line
==
NULL
)
{
if
(
!
playlist
->
tis
->
ReadLine
(
line
))
{
if
(
tag
!=
NULL
)
tag_free
(
tag
);
return
NULL
;
}
line_s
=
line
.
c_str
();
if
(
g_str_has_prefix
(
line
,
"#EXTINF:"
))
{
if
(
g_str_has_prefix
(
line
_s
,
"#EXTINF:"
))
{
if
(
tag
!=
NULL
)
tag_free
(
tag
);
tag
=
extm3u_parse_tag
(
line
+
8
);
tag
=
extm3u_parse_tag
(
line
_s
+
8
);
continue
;
}
while
(
*
line
!=
0
&&
g_ascii_isspace
(
*
line
))
++
line
;
}
while
(
line
[
0
]
==
'#'
||
*
line
==
0
);
while
(
*
line
_s
!=
0
&&
g_ascii_isspace
(
*
line_s
))
++
line
_s
;
}
while
(
line
_s
[
0
]
==
'#'
||
*
line_s
==
0
);
song
=
song_remote_new
(
line
);
song
=
song_remote_new
(
line
_s
);
song
->
tag
=
tag
;
return
song
;
}
...
...
src/playlist/M3uPlaylistPlugin.cxx
View file @
ef48eca9
...
...
@@ -21,17 +21,14 @@
#include "M3uPlaylistPlugin.hxx"
#include "PlaylistPlugin.hxx"
#include "song.h"
extern
"C"
{
#include "text_input_stream.h"
}
#include "TextInputStream.hxx"
#include <glib.h>
struct
M3uPlaylist
{
struct
playlist_provider
base
;
struct
text_input_s
tream
*
tis
;
TextInputS
tream
*
tis
;
};
static
struct
playlist_provider
*
...
...
@@ -40,7 +37,7 @@ m3u_open_stream(struct input_stream *is)
M3uPlaylist
*
playlist
=
g_new
(
M3uPlaylist
,
1
);
playlist_provider_init
(
&
playlist
->
base
,
&
m3u_playlist_plugin
);
playlist
->
tis
=
text_input_stream_new
(
is
);
playlist
->
tis
=
new
TextInputStream
(
is
);
return
&
playlist
->
base
;
}
...
...
@@ -50,7 +47,7 @@ m3u_close(struct playlist_provider *_playlist)
{
M3uPlaylist
*
playlist
=
(
M3uPlaylist
*
)
_playlist
;
text_input_stream_free
(
playlist
->
tis
)
;
delete
playlist
->
tis
;
g_free
(
playlist
);
}
...
...
@@ -58,18 +55,20 @@ static struct song *
m3u_read
(
struct
playlist_provider
*
_playlist
)
{
M3uPlaylist
*
playlist
=
(
M3uPlaylist
*
)
_playlist
;
const
char
*
line
;
std
::
string
line
;
const
char
*
line_s
;
do
{
line
=
text_input_stream_read
(
playlist
->
tis
);
if
(
line
==
NULL
)
if
(
!
playlist
->
tis
->
ReadLine
(
line
))
return
NULL
;
while
(
*
line
!=
0
&&
g_ascii_isspace
(
*
line
))
++
line
;
}
while
(
line
[
0
]
==
'#'
||
*
line
==
0
);
line_s
=
line
.
c_str
();
while
(
*
line_s
!=
0
&&
g_ascii_isspace
(
*
line_s
))
++
line_s
;
}
while
(
line_s
[
0
]
==
'#'
||
*
line_s
==
0
);
return
song_remote_new
(
line
);
return
song_remote_new
(
line
_s
);
}
static
const
char
*
const
m3u_suffixes
[]
=
{
...
...
test/dump_text_file.cxx
View file @
ef48eca9
...
...
@@ -23,10 +23,7 @@
#include "InputStream.hxx"
#include "conf.h"
#include "stdbin.h"
extern
"C"
{
#include "text_input_stream.h"
}
#include "TextInputStream.hxx"
#ifdef ENABLE_ARCHIVE
#include "ArchiveList.hxx"
...
...
@@ -49,11 +46,11 @@ my_log_func(const gchar *log_domain, G_GNUC_UNUSED GLogLevelFlags log_level,
}
static
void
dump_text_file
(
struct
text_input_stream
*
is
)
dump_text_file
(
TextInputStream
&
is
)
{
const
char
*
line
;
while
(
(
line
=
text_input_stream_read
(
is
))
!=
NULL
)
printf
(
"'%s'
\n
"
,
line
);
std
::
string
line
;
while
(
is
.
ReadLine
(
line
)
)
printf
(
"'%s'
\n
"
,
line
.
c_str
()
);
}
static
int
...
...
@@ -77,11 +74,10 @@ dump_input_stream(struct input_stream *is)
/* read data and tags from the stream */
input_stream_unlock
(
is
);
struct
text_input_stream
*
tis
=
text_input_stream_new
(
is
);
dump_text_file
(
tis
);
text_input_stream_free
(
tis
);
{
TextInputStream
tis
(
is
);
dump_text_file
(
tis
);
}
input_stream_lock
(
is
);
if
(
!
input_stream_check
(
is
,
&
error
))
{
...
...
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