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
49784513
Commit
49784513
authored
Nov 10, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/{Const,Writable}Buffer, ...: rename IsEmpty() to empty(), imitating STL
parent
52305113
Show whitespace changes
Inline
Side-by-side
Showing
51 changed files
with
142 additions
and
142 deletions
+142
-142
MusicBuffer.hxx
src/MusicBuffer.hxx
+1
-1
TagFile.cxx
src/TagFile.cxx
+1
-1
TagStream.cxx
src/TagStream.cxx
+1
-1
ClientCommands.cxx
src/command/ClientCommands.cxx
+4
-4
DatabaseCommands.cxx
src/command/DatabaseCommands.cxx
+2
-2
MessageCommands.cxx
src/command/MessageCommands.cxx
+2
-2
OtherCommands.cxx
src/command/OtherCommands.cxx
+1
-1
OutputCommands.cxx
src/command/OutputCommands.cxx
+1
-1
PlayerCommands.cxx
src/command/PlayerCommands.cxx
+1
-1
QueueCommands.cxx
src/command/QueueCommands.cxx
+1
-1
ProxyDatabasePlugin.cxx
src/db/plugins/ProxyDatabasePlugin.cxx
+1
-1
Bridge.cxx
src/decoder/Bridge.cxx
+1
-1
DecoderBuffer.cxx
src/decoder/DecoderBuffer.cxx
+1
-1
FaadDecoderPlugin.cxx
src/decoder/plugins/FaadDecoderPlugin.cxx
+3
-3
FfmpegDecoderPlugin.cxx
src/decoder/plugins/FfmpegDecoderPlugin.cxx
+1
-1
FlacMetadata.cxx
src/decoder/plugins/FlacMetadata.cxx
+1
-1
OpusDecoderPlugin.cxx
src/decoder/plugins/OpusDecoderPlugin.cxx
+1
-1
PcmDecoderPlugin.cxx
src/decoder/plugins/PcmDecoderPlugin.cxx
+2
-2
BufferedSocket.cxx
src/event/BufferedSocket.cxx
+2
-2
FullyBufferedSocket.cxx
src/event/FullyBufferedSocket.cxx
+5
-5
BufferedOutputStream.cxx
src/fs/io/BufferedOutputStream.cxx
+3
-3
BufferedReader.cxx
src/fs/io/BufferedReader.cxx
+5
-5
GunzipReader.cxx
src/fs/io/GunzipReader.cxx
+2
-2
AsyncInputStream.cxx
src/input/AsyncInputStream.cxx
+6
-6
AsyncInputStream.hxx
src/input/AsyncInputStream.hxx
+1
-1
TextInputStream.cxx
src/input/TextInputStream.cxx
+3
-3
ThreadInputStream.cxx
src/input/ThreadInputStream.cxx
+3
-3
VorbisComments.cxx
src/lib/xiph/VorbisComments.cxx
+2
-2
Source.cxx
src/output/Source.cxx
+5
-5
Thread.cxx
src/output/Thread.cxx
+1
-1
PcmDsd.cxx
src/pcm/PcmDsd.cxx
+1
-1
Builder.cxx
src/tag/Builder.cxx
+2
-2
Builder.hxx
src/tag/Builder.hxx
+2
-2
Id3Scan.cxx
src/tag/Id3Scan.cxx
+1
-1
AllocatedArray.hxx
src/util/AllocatedArray.hxx
+1
-1
CircularBuffer.hxx
src/util/CircularBuffer.hxx
+1
-1
ConstBuffer.hxx
src/util/ConstBuffer.hxx
+6
-6
DivideString.hxx
src/util/DivideString.hxx
+1
-1
DynamicFifoBuffer.hxx
src/util/DynamicFifoBuffer.hxx
+1
-1
ForeignFifoBuffer.hxx
src/util/ForeignFifoBuffer.hxx
+2
-2
PeakBuffer.cxx
src/util/PeakBuffer.cxx
+10
-10
PeakBuffer.hxx
src/util/PeakBuffer.hxx
+1
-1
SliceBuffer.hxx
src/util/SliceBuffer.hxx
+1
-1
StaticFifoBuffer.hxx
src/util/StaticFifoBuffer.hxx
+2
-2
StringView.cxx
src/util/StringView.cxx
+2
-2
StringView.hxx
src/util/StringView.hxx
+1
-1
UriUtil.cxx
src/util/UriUtil.cxx
+1
-1
WritableBuffer.hxx
src/util/WritableBuffer.hxx
+6
-6
DivideStringTest.hxx
test/DivideStringTest.hxx
+3
-3
TestCircularBuffer.hxx
test/TestCircularBuffer.hxx
+30
-30
run_convert.cxx
test/run_convert.cxx
+3
-3
No files found.
src/MusicBuffer.hxx
View file @
49784513
...
@@ -50,7 +50,7 @@ public:
...
@@ -50,7 +50,7 @@ public:
* object is inaccessible to other threads.
* object is inaccessible to other threads.
*/
*/
bool
IsEmptyUnsafe
()
const
{
bool
IsEmptyUnsafe
()
const
{
return
buffer
.
IsE
mpty
();
return
buffer
.
e
mpty
();
}
}
#endif
#endif
...
...
src/TagFile.cxx
View file @
49784513
...
@@ -109,7 +109,7 @@ tag_file_scan(Path path, TagBuilder &builder)
...
@@ -109,7 +109,7 @@ tag_file_scan(Path path, TagBuilder &builder)
if
(
!
tag_file_scan
(
path
,
full_tag_handler
,
&
builder
))
if
(
!
tag_file_scan
(
path
,
full_tag_handler
,
&
builder
))
return
false
;
return
false
;
if
(
builder
.
IsE
mpty
())
if
(
builder
.
e
mpty
())
ScanGenericTags
(
path
,
full_tag_handler
,
&
builder
);
ScanGenericTags
(
path
,
full_tag_handler
,
&
builder
);
return
true
;
return
true
;
...
...
src/TagStream.cxx
View file @
49784513
...
@@ -94,7 +94,7 @@ tag_stream_scan(InputStream &is, TagBuilder &builder)
...
@@ -94,7 +94,7 @@ tag_stream_scan(InputStream &is, TagBuilder &builder)
if
(
!
tag_stream_scan
(
is
,
full_tag_handler
,
&
builder
))
if
(
!
tag_stream_scan
(
is
,
full_tag_handler
,
&
builder
))
return
false
;
return
false
;
if
(
builder
.
IsE
mpty
())
if
(
builder
.
e
mpty
())
ScanGenericTags
(
is
,
full_tag_handler
,
&
builder
);
ScanGenericTags
(
is
,
full_tag_handler
,
&
builder
);
return
true
;
return
true
;
...
...
src/command/ClientCommands.cxx
View file @
49784513
...
@@ -58,7 +58,7 @@ handle_password(Client &client, Request args, Response &r)
...
@@ -58,7 +58,7 @@ handle_password(Client &client, Request args, Response &r)
static
TagMask
static
TagMask
ParseTagMask
(
Request
request
)
ParseTagMask
(
Request
request
)
{
{
if
(
request
.
IsE
mpty
())
if
(
request
.
e
mpty
())
throw
ProtocolError
(
ACK_ERROR_ARG
,
"Not enough arguments"
);
throw
ProtocolError
(
ACK_ERROR_ARG
,
"Not enough arguments"
);
TagMask
result
=
TagMask
::
None
();
TagMask
result
=
TagMask
::
None
();
...
@@ -77,14 +77,14 @@ ParseTagMask(Request request)
...
@@ -77,14 +77,14 @@ ParseTagMask(Request request)
CommandResult
CommandResult
handle_tagtypes
(
Client
&
client
,
Request
request
,
Response
&
r
)
handle_tagtypes
(
Client
&
client
,
Request
request
,
Response
&
r
)
{
{
if
(
request
.
IsE
mpty
())
{
if
(
request
.
e
mpty
())
{
tag_print_types
(
r
);
tag_print_types
(
r
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
const
char
*
cmd
=
request
.
shift
();
const
char
*
cmd
=
request
.
shift
();
if
(
StringIsEqual
(
cmd
,
"all"
))
{
if
(
StringIsEqual
(
cmd
,
"all"
))
{
if
(
!
request
.
IsE
mpty
())
{
if
(
!
request
.
e
mpty
())
{
r
.
Error
(
ACK_ERROR_ARG
,
"Too many arguments"
);
r
.
Error
(
ACK_ERROR_ARG
,
"Too many arguments"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
...
@@ -92,7 +92,7 @@ handle_tagtypes(Client &client, Request request, Response &r)
...
@@ -92,7 +92,7 @@ handle_tagtypes(Client &client, Request request, Response &r)
client
.
tag_mask
=
TagMask
::
All
();
client
.
tag_mask
=
TagMask
::
All
();
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
else
if
(
StringIsEqual
(
cmd
,
"clear"
))
{
}
else
if
(
StringIsEqual
(
cmd
,
"clear"
))
{
if
(
!
request
.
IsE
mpty
())
{
if
(
!
request
.
e
mpty
())
{
r
.
Error
(
ACK_ERROR_ARG
,
"Too many arguments"
);
r
.
Error
(
ACK_ERROR_ARG
,
"Too many arguments"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
...
...
src/command/DatabaseCommands.cxx
View file @
49784513
...
@@ -169,7 +169,7 @@ handle_count(Client &client, Request args, Response &r)
...
@@ -169,7 +169,7 @@ handle_count(Client &client, Request args, Response &r)
}
}
SongFilter
filter
;
SongFilter
filter
;
if
(
!
args
.
IsE
mpty
()
&&
!
filter
.
Parse
(
args
,
false
))
{
if
(
!
args
.
e
mpty
()
&&
!
filter
.
Parse
(
args
,
false
))
{
r
.
Error
(
ACK_ERROR_ARG
,
"incorrect arguments"
);
r
.
Error
(
ACK_ERROR_ARG
,
"incorrect arguments"
);
return
CommandResult
::
ERROR
;
return
CommandResult
::
ERROR
;
}
}
...
@@ -235,7 +235,7 @@ handle_list(Client &client, Request args, Response &r)
...
@@ -235,7 +235,7 @@ handle_list(Client &client, Request args, Response &r)
args
.
pop_back
();
args
.
pop_back
();
}
}
if
(
!
args
.
IsE
mpty
())
{
if
(
!
args
.
e
mpty
())
{
filter
.
reset
(
new
SongFilter
());
filter
.
reset
(
new
SongFilter
());
if
(
!
filter
->
Parse
(
args
,
false
))
{
if
(
!
filter
->
Parse
(
args
,
false
))
{
r
.
Error
(
ACK_ERROR_ARG
,
"not able to parse args"
);
r
.
Error
(
ACK_ERROR_ARG
,
"not able to parse args"
);
...
...
src/command/MessageCommands.cxx
View file @
49784513
...
@@ -76,7 +76,7 @@ handle_unsubscribe(Client &client, Request args, Response &r)
...
@@ -76,7 +76,7 @@ handle_unsubscribe(Client &client, Request args, Response &r)
CommandResult
CommandResult
handle_channels
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
handle_channels
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
{
{
assert
(
args
.
IsE
mpty
());
assert
(
args
.
e
mpty
());
std
::
set
<
std
::
string
>
channels
;
std
::
set
<
std
::
string
>
channels
;
for
(
const
auto
&
c
:
*
client
.
GetInstance
().
client_list
)
for
(
const
auto
&
c
:
*
client
.
GetInstance
().
client_list
)
...
@@ -93,7 +93,7 @@ CommandResult
...
@@ -93,7 +93,7 @@ CommandResult
handle_read_messages
(
Client
&
client
,
handle_read_messages
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
gcc_unused
Request
args
,
Response
&
r
)
{
{
assert
(
args
.
IsE
mpty
());
assert
(
args
.
e
mpty
());
while
(
!
client
.
messages
.
empty
())
{
while
(
!
client
.
messages
.
empty
())
{
const
ClientMessage
&
msg
=
client
.
messages
.
front
();
const
ClientMessage
&
msg
=
client
.
messages
.
front
();
...
...
src/command/OtherCommands.cxx
View file @
49784513
...
@@ -284,7 +284,7 @@ handle_update(Client &client, Request args, Response &r, bool discard)
...
@@ -284,7 +284,7 @@ handle_update(Client &client, Request args, Response &r, bool discard)
const
char
*
path
=
""
;
const
char
*
path
=
""
;
assert
(
args
.
size
<=
1
);
assert
(
args
.
size
<=
1
);
if
(
!
args
.
IsE
mpty
())
{
if
(
!
args
.
e
mpty
())
{
path
=
args
.
front
();
path
=
args
.
front
();
if
(
*
path
==
0
||
StringIsEqual
(
path
,
"/"
))
if
(
*
path
==
0
||
StringIsEqual
(
path
,
"/"
))
...
...
src/command/OutputCommands.cxx
View file @
49784513
...
@@ -71,7 +71,7 @@ handle_toggleoutput(Client &client, Request args, Response &r)
...
@@ -71,7 +71,7 @@ handle_toggleoutput(Client &client, Request args, Response &r)
CommandResult
CommandResult
handle_devices
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
handle_devices
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
{
{
assert
(
args
.
IsE
mpty
());
assert
(
args
.
e
mpty
());
printAudioDevices
(
r
,
client
.
GetPartition
().
outputs
);
printAudioDevices
(
r
,
client
.
GetPartition
().
outputs
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
...
...
src/command/PlayerCommands.cxx
View file @
49784513
...
@@ -95,7 +95,7 @@ handle_pause(Client &client, Request args, gcc_unused Response &r)
...
@@ -95,7 +95,7 @@ handle_pause(Client &client, Request args, gcc_unused Response &r)
{
{
auto
&
pc
=
client
.
GetPlayerControl
();
auto
&
pc
=
client
.
GetPlayerControl
();
if
(
!
args
.
IsE
mpty
())
{
if
(
!
args
.
e
mpty
())
{
bool
pause_flag
=
args
.
ParseBool
(
0
);
bool
pause_flag
=
args
.
ParseBool
(
0
);
pc
.
LockSetPause
(
pause_flag
);
pc
.
LockSetPause
(
pause_flag
);
}
else
}
else
...
...
src/command/QueueCommands.cxx
View file @
49784513
...
@@ -242,7 +242,7 @@ handle_playlistinfo(Client &client, Request args, Response &r)
...
@@ -242,7 +242,7 @@ handle_playlistinfo(Client &client, Request args, Response &r)
CommandResult
CommandResult
handle_playlistid
(
Client
&
client
,
Request
args
,
Response
&
r
)
handle_playlistid
(
Client
&
client
,
Request
args
,
Response
&
r
)
{
{
if
(
!
args
.
IsE
mpty
())
{
if
(
!
args
.
e
mpty
())
{
unsigned
id
=
args
.
ParseUnsigned
(
0
);
unsigned
id
=
args
.
ParseUnsigned
(
0
);
playlist_print_id
(
r
,
client
.
GetPlaylist
(),
id
);
playlist_print_id
(
r
,
client
.
GetPlaylist
(),
id
);
}
else
{
}
else
{
...
...
src/db/plugins/ProxyDatabasePlugin.cxx
View file @
49784513
...
@@ -801,7 +801,7 @@ ProxyDatabase::VisitUniqueTags(const DatabaseSelection &selection,
...
@@ -801,7 +801,7 @@ ProxyDatabase::VisitUniqueTags(const DatabaseSelection &selection,
TagBuilder
tag
;
TagBuilder
tag
;
tag
.
AddItem
(
tag_type
,
pair
->
value
);
tag
.
AddItem
(
tag_type
,
pair
->
value
);
if
(
tag
.
IsE
mpty
())
if
(
tag
.
e
mpty
())
/* if no tag item has been added, then the
/* if no tag item has been added, then the
given value was not acceptable
given value was not acceptable
(e.g. empty); forcefully insert an empty
(e.g. empty); forcefully insert an empty
...
...
src/decoder/Bridge.cxx
View file @
49784513
...
@@ -496,7 +496,7 @@ DecoderBridge::SubmitData(InputStream *is,
...
@@ -496,7 +496,7 @@ DecoderBridge::SubmitData(InputStream *is,
SongTime
::
FromS
(
timestamp
)
-
SongTime
::
FromS
(
timestamp
)
-
dc
.
song
->
GetStartTime
(),
dc
.
song
->
GetStartTime
(),
kbit_rate
);
kbit_rate
);
if
(
dest
.
IsE
mpty
())
{
if
(
dest
.
e
mpty
())
{
/* the chunk is full, flush it */
/* the chunk is full, flush it */
FlushChunk
();
FlushChunk
();
continue
;
continue
;
...
...
src/decoder/DecoderBuffer.cxx
View file @
49784513
...
@@ -25,7 +25,7 @@ bool
...
@@ -25,7 +25,7 @@ bool
DecoderBuffer
::
Fill
()
DecoderBuffer
::
Fill
()
{
{
auto
w
=
buffer
.
Write
();
auto
w
=
buffer
.
Write
();
if
(
w
.
IsE
mpty
())
if
(
w
.
e
mpty
())
/* buffer is full */
/* buffer is full */
return
false
;
return
false
;
...
...
src/decoder/plugins/FaadDecoderPlugin.cxx
View file @
49784513
...
@@ -127,7 +127,7 @@ adts_song_duration(DecoderBuffer &buffer)
...
@@ -127,7 +127,7 @@ adts_song_duration(DecoderBuffer &buffer)
if
(
frames
==
0
)
{
if
(
frames
==
0
)
{
auto
data
=
ConstBuffer
<
uint8_t
>::
FromVoid
(
buffer
.
Read
());
auto
data
=
ConstBuffer
<
uint8_t
>::
FromVoid
(
buffer
.
Read
());
assert
(
!
data
.
IsE
mpty
());
assert
(
!
data
.
e
mpty
());
assert
(
frame_length
<=
data
.
size
);
assert
(
frame_length
<=
data
.
size
);
sample_rate
=
adts_sample_rates
[(
data
.
data
[
2
]
&
0x3c
)
>>
2
];
sample_rate
=
adts_sample_rates
[(
data
.
data
[
2
]
&
0x3c
)
>>
2
];
...
@@ -255,7 +255,7 @@ faad_decoder_init(NeAACDecHandle decoder, DecoderBuffer &buffer,
...
@@ -255,7 +255,7 @@ faad_decoder_init(NeAACDecHandle decoder, DecoderBuffer &buffer,
AudioFormat
&
audio_format
)
AudioFormat
&
audio_format
)
{
{
auto
data
=
ConstBuffer
<
uint8_t
>::
FromVoid
(
buffer
.
Read
());
auto
data
=
ConstBuffer
<
uint8_t
>::
FromVoid
(
buffer
.
Read
());
if
(
data
.
IsE
mpty
())
if
(
data
.
e
mpty
())
throw
std
::
runtime_error
(
"Empty file"
);
throw
std
::
runtime_error
(
"Empty file"
);
uint8_t
channels
;
uint8_t
channels
;
...
@@ -283,7 +283,7 @@ faad_decoder_decode(NeAACDecHandle decoder, DecoderBuffer &buffer,
...
@@ -283,7 +283,7 @@ faad_decoder_decode(NeAACDecHandle decoder, DecoderBuffer &buffer,
NeAACDecFrameInfo
*
frame_info
)
NeAACDecFrameInfo
*
frame_info
)
{
{
auto
data
=
ConstBuffer
<
uint8_t
>::
FromVoid
(
buffer
.
Read
());
auto
data
=
ConstBuffer
<
uint8_t
>::
FromVoid
(
buffer
.
Read
());
if
(
data
.
IsE
mpty
())
if
(
data
.
e
mpty
())
return
nullptr
;
return
nullptr
;
return
NeAACDecDecode
(
decoder
,
frame_info
,
return
NeAACDecDecode
(
decoder
,
frame_info
,
...
...
src/decoder/plugins/FfmpegDecoderPlugin.cxx
View file @
49784513
...
@@ -617,7 +617,7 @@ FfmpegCheckTag(DecoderClient &client, InputStream &is,
...
@@ -617,7 +617,7 @@ FfmpegCheckTag(DecoderClient &client, InputStream &is,
TagBuilder
tag
;
TagBuilder
tag
;
FfmpegScanTag
(
format_context
,
audio_stream
,
tag
);
FfmpegScanTag
(
format_context
,
audio_stream
,
tag
);
if
(
!
tag
.
IsE
mpty
())
if
(
!
tag
.
e
mpty
())
client
.
SubmitTag
(
is
,
tag
.
Commit
());
client
.
SubmitTag
(
is
,
tag
.
Commit
());
}
}
...
...
src/decoder/plugins/FlacMetadata.cxx
View file @
49784513
...
@@ -97,7 +97,7 @@ flac_scan_comment(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
...
@@ -97,7 +97,7 @@ flac_scan_comment(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
if
(
handler
.
pair
!=
nullptr
)
{
if
(
handler
.
pair
!=
nullptr
)
{
const
char
*
comment
=
(
const
char
*
)
entry
->
entry
;
const
char
*
comment
=
(
const
char
*
)
entry
->
entry
;
const
DivideString
split
(
comment
,
'='
);
const
DivideString
split
(
comment
,
'='
);
if
(
split
.
IsDefined
()
&&
!
split
.
IsE
mpty
())
if
(
split
.
IsDefined
()
&&
!
split
.
e
mpty
())
tag_handler_invoke_pair
(
handler
,
handler_ctx
,
tag_handler_invoke_pair
(
handler
,
handler_ctx
,
split
.
GetFirst
(),
split
.
GetFirst
(),
split
.
GetSecond
());
split
.
GetSecond
());
...
...
src/decoder/plugins/OpusDecoderPlugin.cxx
View file @
49784513
...
@@ -211,7 +211,7 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
...
@@ -211,7 +211,7 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
if
(
ScanOpusTags
(
packet
.
packet
,
packet
.
bytes
,
if
(
ScanOpusTags
(
packet
.
packet
,
packet
.
bytes
,
&
rgi
,
&
rgi
,
add_tag_handler
,
&
tag_builder
)
&&
add_tag_handler
,
&
tag_builder
)
&&
!
tag_builder
.
IsE
mpty
())
{
!
tag_builder
.
e
mpty
())
{
client
.
SubmitReplayGain
(
&
rgi
);
client
.
SubmitReplayGain
(
&
rgi
);
Tag
tag
=
tag_builder
.
Commit
();
Tag
tag
=
tag_builder
.
Commit
();
...
...
src/decoder/plugins/PcmDecoderPlugin.cxx
View file @
49784513
...
@@ -44,7 +44,7 @@ FillBuffer(DecoderClient &client, InputStream &is, B &buffer)
...
@@ -44,7 +44,7 @@ FillBuffer(DecoderClient &client, InputStream &is, B &buffer)
{
{
buffer
.
Shift
();
buffer
.
Shift
();
auto
w
=
buffer
.
Write
();
auto
w
=
buffer
.
Write
();
if
(
w
.
IsE
mpty
())
if
(
w
.
e
mpty
())
return
true
;
return
true
;
size_t
nbytes
=
decoder_read
(
client
,
is
,
w
.
data
,
w
.
size
);
size_t
nbytes
=
decoder_read
(
client
,
is
,
w
.
data
,
w
.
size
);
...
@@ -185,7 +185,7 @@ pcm_stream_decode(DecoderClient &client, InputStream &is)
...
@@ -185,7 +185,7 @@ pcm_stream_decode(DecoderClient &client, InputStream &is)
r
.
size
=
(
r
.
size
/
3
)
*
4
;
r
.
size
=
(
r
.
size
/
3
)
*
4
;
}
}
cmd
=
!
r
.
IsE
mpty
()
cmd
=
!
r
.
e
mpty
()
?
client
.
SubmitData
(
is
,
r
.
data
,
r
.
size
,
0
)
?
client
.
SubmitData
(
is
,
r
.
data
,
r
.
size
,
0
)
:
client
.
GetCommand
();
:
client
.
GetCommand
();
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
...
...
src/event/BufferedSocket.cxx
View file @
49784513
...
@@ -53,7 +53,7 @@ BufferedSocket::ReadToBuffer()
...
@@ -53,7 +53,7 @@ BufferedSocket::ReadToBuffer()
assert
(
IsDefined
());
assert
(
IsDefined
());
const
auto
buffer
=
input
.
Write
();
const
auto
buffer
=
input
.
Write
();
assert
(
!
buffer
.
IsE
mpty
());
assert
(
!
buffer
.
e
mpty
());
const
auto
nbytes
=
DirectRead
(
buffer
.
data
,
buffer
.
size
);
const
auto
nbytes
=
DirectRead
(
buffer
.
data
,
buffer
.
size
);
if
(
nbytes
>
0
)
if
(
nbytes
>
0
)
...
@@ -69,7 +69,7 @@ BufferedSocket::ResumeInput()
...
@@ -69,7 +69,7 @@ BufferedSocket::ResumeInput()
while
(
true
)
{
while
(
true
)
{
const
auto
buffer
=
input
.
Read
();
const
auto
buffer
=
input
.
Read
();
if
(
buffer
.
IsE
mpty
())
{
if
(
buffer
.
e
mpty
())
{
ScheduleRead
();
ScheduleRead
();
return
true
;
return
true
;
}
}
...
...
src/event/FullyBufferedSocket.cxx
View file @
49784513
...
@@ -52,7 +52,7 @@ FullyBufferedSocket::Flush()
...
@@ -52,7 +52,7 @@ FullyBufferedSocket::Flush()
assert
(
IsDefined
());
assert
(
IsDefined
());
const
auto
data
=
output
.
Read
();
const
auto
data
=
output
.
Read
();
if
(
data
.
IsE
mpty
())
{
if
(
data
.
e
mpty
())
{
IdleMonitor
::
Cancel
();
IdleMonitor
::
Cancel
();
CancelWrite
();
CancelWrite
();
return
true
;
return
true
;
...
@@ -64,7 +64,7 @@ FullyBufferedSocket::Flush()
...
@@ -64,7 +64,7 @@ FullyBufferedSocket::Flush()
output
.
Consume
(
nbytes
);
output
.
Consume
(
nbytes
);
if
(
output
.
IsE
mpty
())
{
if
(
output
.
e
mpty
())
{
IdleMonitor
::
Cancel
();
IdleMonitor
::
Cancel
();
CancelWrite
();
CancelWrite
();
}
}
...
@@ -80,7 +80,7 @@ FullyBufferedSocket::Write(const void *data, size_t length)
...
@@ -80,7 +80,7 @@ FullyBufferedSocket::Write(const void *data, size_t length)
if
(
length
==
0
)
if
(
length
==
0
)
return
true
;
return
true
;
const
bool
was_empty
=
output
.
IsE
mpty
();
const
bool
was_empty
=
output
.
e
mpty
();
if
(
!
output
.
Append
(
data
,
length
))
{
if
(
!
output
.
Append
(
data
,
length
))
{
OnSocketError
(
std
::
make_exception_ptr
(
std
::
runtime_error
(
"Output buffer is full"
)));
OnSocketError
(
std
::
make_exception_ptr
(
std
::
runtime_error
(
"Output buffer is full"
)));
...
@@ -96,7 +96,7 @@ bool
...
@@ -96,7 +96,7 @@ bool
FullyBufferedSocket
::
OnSocketReady
(
unsigned
flags
)
FullyBufferedSocket
::
OnSocketReady
(
unsigned
flags
)
{
{
if
(
flags
&
WRITE
)
{
if
(
flags
&
WRITE
)
{
assert
(
!
output
.
IsE
mpty
());
assert
(
!
output
.
e
mpty
());
assert
(
!
IdleMonitor
::
IsActive
());
assert
(
!
IdleMonitor
::
IsActive
());
if
(
!
Flush
())
if
(
!
Flush
())
...
@@ -112,6 +112,6 @@ FullyBufferedSocket::OnSocketReady(unsigned flags)
...
@@ -112,6 +112,6 @@ FullyBufferedSocket::OnSocketReady(unsigned flags)
void
void
FullyBufferedSocket
::
OnIdle
()
FullyBufferedSocket
::
OnIdle
()
{
{
if
(
Flush
()
&&
!
output
.
IsE
mpty
())
if
(
Flush
()
&&
!
output
.
e
mpty
())
ScheduleWrite
();
ScheduleWrite
();
}
}
src/fs/io/BufferedOutputStream.cxx
View file @
49784513
...
@@ -70,7 +70,7 @@ void
...
@@ -70,7 +70,7 @@ void
BufferedOutputStream
::
Format
(
const
char
*
fmt
,
...)
BufferedOutputStream
::
Format
(
const
char
*
fmt
,
...)
{
{
auto
r
=
buffer
.
Write
();
auto
r
=
buffer
.
Write
();
if
(
r
.
IsE
mpty
())
{
if
(
r
.
e
mpty
())
{
Flush
();
Flush
();
r
=
buffer
.
Write
();
r
=
buffer
.
Write
();
}
}
...
@@ -123,7 +123,7 @@ BufferedOutputStream::WriteWideToUTF8(const wchar_t *src, size_t src_length)
...
@@ -123,7 +123,7 @@ BufferedOutputStream::WriteWideToUTF8(const wchar_t *src, size_t src_length)
return
;
return
;
auto
r
=
buffer
.
Write
();
auto
r
=
buffer
.
Write
();
if
(
r
.
IsE
mpty
())
{
if
(
r
.
e
mpty
())
{
Flush
();
Flush
();
r
=
buffer
.
Write
();
r
=
buffer
.
Write
();
}
}
...
@@ -158,7 +158,7 @@ void
...
@@ -158,7 +158,7 @@ void
BufferedOutputStream
::
Flush
()
BufferedOutputStream
::
Flush
()
{
{
auto
r
=
buffer
.
Read
();
auto
r
=
buffer
.
Read
();
if
(
r
.
IsE
mpty
())
if
(
r
.
e
mpty
())
return
;
return
;
os
.
Write
(
r
.
data
,
r
.
size
);
os
.
Write
(
r
.
data
,
r
.
size
);
...
...
src/fs/io/BufferedReader.cxx
View file @
49784513
...
@@ -34,13 +34,13 @@ BufferedReader::Fill(bool need_more)
...
@@ -34,13 +34,13 @@ BufferedReader::Fill(bool need_more)
return
!
need_more
;
return
!
need_more
;
auto
w
=
buffer
.
Write
();
auto
w
=
buffer
.
Write
();
if
(
w
.
IsE
mpty
())
{
if
(
w
.
e
mpty
())
{
if
(
buffer
.
GetCapacity
()
>=
MAX_SIZE
)
if
(
buffer
.
GetCapacity
()
>=
MAX_SIZE
)
return
!
need_more
;
return
!
need_more
;
buffer
.
Grow
(
buffer
.
GetCapacity
()
*
2
);
buffer
.
Grow
(
buffer
.
GetCapacity
()
*
2
);
w
=
buffer
.
Write
();
w
=
buffer
.
Write
();
assert
(
!
w
.
IsE
mpty
());
assert
(
!
w
.
e
mpty
());
}
}
size_t
nbytes
=
reader
.
Read
(
w
.
data
,
w
.
size
);
size_t
nbytes
=
reader
.
Read
(
w
.
data
,
w
.
size
);
...
@@ -104,14 +104,14 @@ BufferedReader::ReadLine()
...
@@ -104,14 +104,14 @@ BufferedReader::ReadLine()
}
}
}
while
(
Fill
(
true
));
}
while
(
Fill
(
true
));
if
(
!
eof
||
buffer
.
IsE
mpty
())
if
(
!
eof
||
buffer
.
e
mpty
())
return
nullptr
;
return
nullptr
;
auto
w
=
buffer
.
Write
();
auto
w
=
buffer
.
Write
();
if
(
w
.
IsE
mpty
())
{
if
(
w
.
e
mpty
())
{
buffer
.
Grow
(
buffer
.
GetCapacity
()
+
1
);
buffer
.
Grow
(
buffer
.
GetCapacity
()
+
1
);
w
=
buffer
.
Write
();
w
=
buffer
.
Write
();
assert
(
!
w
.
IsE
mpty
());
assert
(
!
w
.
e
mpty
());
}
}
/* terminate the last line */
/* terminate the last line */
...
...
src/fs/io/GunzipReader.cxx
View file @
49784513
...
@@ -39,7 +39,7 @@ inline bool
...
@@ -39,7 +39,7 @@ inline bool
GunzipReader
::
FillBuffer
()
GunzipReader
::
FillBuffer
()
{
{
auto
w
=
buffer
.
Write
();
auto
w
=
buffer
.
Write
();
assert
(
!
w
.
IsE
mpty
());
assert
(
!
w
.
e
mpty
());
size_t
nbytes
=
next
.
Read
(
w
.
data
,
w
.
size
);
size_t
nbytes
=
next
.
Read
(
w
.
data
,
w
.
size
);
if
(
nbytes
==
0
)
if
(
nbytes
==
0
)
...
@@ -62,7 +62,7 @@ GunzipReader::Read(void *data, size_t size)
...
@@ -62,7 +62,7 @@ GunzipReader::Read(void *data, size_t size)
int
flush
=
Z_NO_FLUSH
;
int
flush
=
Z_NO_FLUSH
;
auto
r
=
buffer
.
Read
();
auto
r
=
buffer
.
Read
();
if
(
r
.
IsE
mpty
())
{
if
(
r
.
e
mpty
())
{
if
(
FillBuffer
())
if
(
FillBuffer
())
r
=
buffer
.
Read
();
r
=
buffer
.
Read
();
else
else
...
...
src/input/AsyncInputStream.cxx
View file @
49784513
...
@@ -88,7 +88,7 @@ bool
...
@@ -88,7 +88,7 @@ bool
AsyncInputStream
::
IsEOF
()
noexcept
AsyncInputStream
::
IsEOF
()
noexcept
{
{
return
(
KnownSize
()
&&
offset
>=
size
)
||
return
(
KnownSize
()
&&
offset
>=
size
)
||
(
!
open
&&
buffer
.
IsE
mpty
());
(
!
open
&&
buffer
.
e
mpty
());
}
}
void
void
...
@@ -108,7 +108,7 @@ AsyncInputStream::Seek(offset_type new_offset)
...
@@ -108,7 +108,7 @@ AsyncInputStream::Seek(offset_type new_offset)
while
(
new_offset
>
offset
)
{
while
(
new_offset
>
offset
)
{
auto
r
=
buffer
.
Read
();
auto
r
=
buffer
.
Read
();
if
(
r
.
IsE
mpty
())
if
(
r
.
e
mpty
())
break
;
break
;
const
size_t
nbytes
=
const
size_t
nbytes
=
...
@@ -162,7 +162,7 @@ AsyncInputStream::IsAvailable() noexcept
...
@@ -162,7 +162,7 @@ AsyncInputStream::IsAvailable() noexcept
{
{
return
postponed_exception
||
return
postponed_exception
||
IsEOF
()
||
IsEOF
()
||
!
buffer
.
IsE
mpty
();
!
buffer
.
e
mpty
();
}
}
size_t
size_t
...
@@ -176,7 +176,7 @@ AsyncInputStream::Read(void *ptr, size_t read_size)
...
@@ -176,7 +176,7 @@ AsyncInputStream::Read(void *ptr, size_t read_size)
Check
();
Check
();
r
=
buffer
.
Read
();
r
=
buffer
.
Read
();
if
(
!
r
.
IsE
mpty
()
||
IsEOF
())
if
(
!
r
.
e
mpty
()
||
IsEOF
())
break
;
break
;
cond
.
wait
(
mutex
);
cond
.
wait
(
mutex
);
...
@@ -209,7 +209,7 @@ void
...
@@ -209,7 +209,7 @@ void
AsyncInputStream
::
AppendToBuffer
(
const
void
*
data
,
size_t
append_size
)
noexcept
AsyncInputStream
::
AppendToBuffer
(
const
void
*
data
,
size_t
append_size
)
noexcept
{
{
auto
w
=
buffer
.
Write
();
auto
w
=
buffer
.
Write
();
assert
(
!
w
.
IsE
mpty
());
assert
(
!
w
.
e
mpty
());
size_t
nbytes
=
std
::
min
(
w
.
size
,
append_size
);
size_t
nbytes
=
std
::
min
(
w
.
size
,
append_size
);
memcpy
(
w
.
data
,
data
,
nbytes
);
memcpy
(
w
.
data
,
data
,
nbytes
);
...
@@ -218,7 +218,7 @@ AsyncInputStream::AppendToBuffer(const void *data, size_t append_size) noexcept
...
@@ -218,7 +218,7 @@ AsyncInputStream::AppendToBuffer(const void *data, size_t append_size) noexcept
const
size_t
remaining
=
append_size
-
nbytes
;
const
size_t
remaining
=
append_size
-
nbytes
;
if
(
remaining
>
0
)
{
if
(
remaining
>
0
)
{
w
=
buffer
.
Write
();
w
=
buffer
.
Write
();
assert
(
!
w
.
IsE
mpty
());
assert
(
!
w
.
e
mpty
());
assert
(
w
.
size
>=
remaining
);
assert
(
w
.
size
>=
remaining
);
memcpy
(
w
.
data
,
(
const
uint8_t
*
)
data
+
nbytes
,
remaining
);
memcpy
(
w
.
data
,
(
const
uint8_t
*
)
data
+
nbytes
,
remaining
);
...
...
src/input/AsyncInputStream.hxx
View file @
49784513
...
@@ -114,7 +114,7 @@ protected:
...
@@ -114,7 +114,7 @@ protected:
}
}
bool
IsBufferEmpty
()
const
noexcept
{
bool
IsBufferEmpty
()
const
noexcept
{
return
buffer
.
IsE
mpty
();
return
buffer
.
e
mpty
();
}
}
bool
IsBufferFull
()
const
noexcept
{
bool
IsBufferFull
()
const
noexcept
{
...
...
src/input/TextInputStream.cxx
View file @
49784513
...
@@ -47,7 +47,7 @@ TextInputStream::ReadLine()
...
@@ -47,7 +47,7 @@ TextInputStream::ReadLine()
/* line too long: terminate the current
/* line too long: terminate the current
line */
line */
assert
(
!
dest
.
IsE
mpty
());
assert
(
!
dest
.
e
mpty
());
dest
[
0
]
=
0
;
dest
[
0
]
=
0
;
line
=
buffer
.
Read
().
data
;
line
=
buffer
.
Read
().
data
;
buffer
.
Clear
();
buffer
.
Clear
();
...
@@ -79,12 +79,12 @@ TextInputStream::ReadLine()
...
@@ -79,12 +79,12 @@ TextInputStream::ReadLine()
line */
line */
dest
=
buffer
.
Write
();
dest
=
buffer
.
Write
();
assert
(
!
dest
.
IsE
mpty
());
assert
(
!
dest
.
e
mpty
());
dest
[
0
]
=
0
;
dest
[
0
]
=
0
;
auto
r
=
buffer
.
Read
();
auto
r
=
buffer
.
Read
();
buffer
.
Clear
();
buffer
.
Clear
();
return
r
.
IsE
mpty
()
return
r
.
e
mpty
()
?
nullptr
?
nullptr
:
r
.
data
;
:
r
.
data
;
}
}
...
...
src/input/ThreadInputStream.cxx
View file @
49784513
...
@@ -80,7 +80,7 @@ ThreadInputStream::ThreadFunc()
...
@@ -80,7 +80,7 @@ ThreadInputStream::ThreadFunc()
assert
(
!
postponed_exception
);
assert
(
!
postponed_exception
);
auto
w
=
buffer
.
Write
();
auto
w
=
buffer
.
Write
();
if
(
w
.
IsE
mpty
())
{
if
(
w
.
e
mpty
())
{
wake_cond
.
wait
(
mutex
);
wake_cond
.
wait
(
mutex
);
}
else
{
}
else
{
size_t
nbytes
;
size_t
nbytes
;
...
@@ -122,7 +122,7 @@ ThreadInputStream::IsAvailable() noexcept
...
@@ -122,7 +122,7 @@ ThreadInputStream::IsAvailable() noexcept
{
{
assert
(
!
thread
.
IsInside
());
assert
(
!
thread
.
IsInside
());
return
!
buffer
.
IsE
mpty
()
||
eof
||
postponed_exception
;
return
!
buffer
.
e
mpty
()
||
eof
||
postponed_exception
;
}
}
inline
size_t
inline
size_t
...
@@ -135,7 +135,7 @@ ThreadInputStream::Read(void *ptr, size_t read_size)
...
@@ -135,7 +135,7 @@ ThreadInputStream::Read(void *ptr, size_t read_size)
std
::
rethrow_exception
(
postponed_exception
);
std
::
rethrow_exception
(
postponed_exception
);
auto
r
=
buffer
.
Read
();
auto
r
=
buffer
.
Read
();
if
(
!
r
.
IsE
mpty
())
{
if
(
!
r
.
e
mpty
())
{
size_t
nbytes
=
std
::
min
(
read_size
,
r
.
size
);
size_t
nbytes
=
std
::
min
(
read_size
,
r
.
size
);
memcpy
(
ptr
,
r
.
data
,
nbytes
);
memcpy
(
ptr
,
r
.
data
,
nbytes
);
buffer
.
Consume
(
nbytes
);
buffer
.
Consume
(
nbytes
);
...
...
src/lib/xiph/VorbisComments.cxx
View file @
49784513
...
@@ -71,7 +71,7 @@ vorbis_scan_comment(const char *comment,
...
@@ -71,7 +71,7 @@ vorbis_scan_comment(const char *comment,
{
{
if
(
handler
.
pair
!=
nullptr
)
{
if
(
handler
.
pair
!=
nullptr
)
{
const
DivideString
split
(
comment
,
'='
);
const
DivideString
split
(
comment
,
'='
);
if
(
split
.
IsDefined
()
&&
!
split
.
IsE
mpty
())
if
(
split
.
IsDefined
()
&&
!
split
.
e
mpty
())
tag_handler_invoke_pair
(
handler
,
handler_ctx
,
tag_handler_invoke_pair
(
handler
,
handler_ctx
,
split
.
GetFirst
(),
split
.
GetFirst
(),
split
.
GetSecond
());
split
.
GetSecond
());
...
@@ -104,7 +104,7 @@ vorbis_comments_to_tag(char **comments)
...
@@ -104,7 +104,7 @@ vorbis_comments_to_tag(char **comments)
{
{
TagBuilder
tag_builder
;
TagBuilder
tag_builder
;
vorbis_comments_scan
(
comments
,
add_tag_handler
,
&
tag_builder
);
vorbis_comments_scan
(
comments
,
add_tag_handler
,
&
tag_builder
);
return
tag_builder
.
IsE
mpty
()
return
tag_builder
.
e
mpty
()
?
nullptr
?
nullptr
:
tag_builder
.
CommitNew
();
:
tag_builder
.
CommitNew
();
}
}
src/output/Source.cxx
View file @
49784513
...
@@ -138,7 +138,7 @@ AudioOutputSource::GetChunkData(const MusicChunk &chunk,
...
@@ -138,7 +138,7 @@ AudioOutputSource::GetChunkData(const MusicChunk &chunk,
assert
(
data
.
size
%
in_audio_format
.
GetFrameSize
()
==
0
);
assert
(
data
.
size
%
in_audio_format
.
GetFrameSize
()
==
0
);
if
(
!
data
.
IsE
mpty
()
&&
replay_gain_filter
!=
nullptr
)
{
if
(
!
data
.
e
mpty
()
&&
replay_gain_filter
!=
nullptr
)
{
replay_gain_filter_set_mode
(
*
replay_gain_filter
,
replay_gain_filter_set_mode
(
*
replay_gain_filter
,
replay_gain_mode
);
replay_gain_mode
);
...
@@ -161,7 +161,7 @@ AudioOutputSource::FilterChunk(const MusicChunk &chunk)
...
@@ -161,7 +161,7 @@ AudioOutputSource::FilterChunk(const MusicChunk &chunk)
{
{
auto
data
=
GetChunkData
(
chunk
,
replay_gain_filter_instance
,
auto
data
=
GetChunkData
(
chunk
,
replay_gain_filter_instance
,
&
replay_gain_serial
);
&
replay_gain_serial
);
if
(
data
.
IsE
mpty
())
if
(
data
.
e
mpty
())
return
data
;
return
data
;
/* cross-fade */
/* cross-fade */
...
@@ -170,7 +170,7 @@ AudioOutputSource::FilterChunk(const MusicChunk &chunk)
...
@@ -170,7 +170,7 @@ AudioOutputSource::FilterChunk(const MusicChunk &chunk)
auto
other_data
=
GetChunkData
(
*
chunk
.
other
,
auto
other_data
=
GetChunkData
(
*
chunk
.
other
,
other_replay_gain_filter_instance
,
other_replay_gain_filter_instance
,
&
other_replay_gain_serial
);
&
other_replay_gain_serial
);
if
(
other_data
.
IsE
mpty
())
if
(
other_data
.
e
mpty
())
return
data
;
return
data
;
/* if the "other" chunk is longer, then that trailer
/* if the "other" chunk is longer, then that trailer
...
@@ -211,7 +211,7 @@ bool
...
@@ -211,7 +211,7 @@ bool
AudioOutputSource
::
Fill
(
Mutex
&
mutex
)
AudioOutputSource
::
Fill
(
Mutex
&
mutex
)
{
{
if
(
current_chunk
!=
nullptr
&&
pending_tag
==
nullptr
&&
if
(
current_chunk
!=
nullptr
&&
pending_tag
==
nullptr
&&
pending_data
.
IsE
mpty
())
pending_data
.
e
mpty
())
pipe
.
Consume
(
*
std
::
exchange
(
current_chunk
,
nullptr
));
pipe
.
Consume
(
*
std
::
exchange
(
current_chunk
,
nullptr
));
if
(
current_chunk
!=
nullptr
)
if
(
current_chunk
!=
nullptr
)
...
@@ -242,6 +242,6 @@ AudioOutputSource::ConsumeData(size_t nbytes) noexcept
...
@@ -242,6 +242,6 @@ AudioOutputSource::ConsumeData(size_t nbytes) noexcept
{
{
pending_data
.
skip_front
(
nbytes
);
pending_data
.
skip_front
(
nbytes
);
if
(
pending_data
.
IsE
mpty
())
if
(
pending_data
.
e
mpty
())
pipe
.
Consume
(
*
std
::
exchange
(
current_chunk
,
nullptr
));
pipe
.
Consume
(
*
std
::
exchange
(
current_chunk
,
nullptr
));
}
}
src/output/Thread.cxx
View file @
49784513
...
@@ -259,7 +259,7 @@ AudioOutputControl::PlayChunk() noexcept
...
@@ -259,7 +259,7 @@ AudioOutputControl::PlayChunk() noexcept
while
(
command
==
Command
::
NONE
)
{
while
(
command
==
Command
::
NONE
)
{
const
auto
data
=
source
.
PeekData
();
const
auto
data
=
source
.
PeekData
();
if
(
data
.
IsE
mpty
())
if
(
data
.
e
mpty
())
break
;
break
;
if
(
skip_delay
)
if
(
skip_delay
)
...
...
src/pcm/PcmDsd.cxx
View file @
49784513
...
@@ -48,7 +48,7 @@ ConstBuffer<float>
...
@@ -48,7 +48,7 @@ ConstBuffer<float>
PcmDsd
::
ToFloat
(
unsigned
channels
,
ConstBuffer
<
uint8_t
>
src
)
PcmDsd
::
ToFloat
(
unsigned
channels
,
ConstBuffer
<
uint8_t
>
src
)
{
{
assert
(
!
src
.
IsNull
());
assert
(
!
src
.
IsNull
());
assert
(
!
src
.
IsE
mpty
());
assert
(
!
src
.
e
mpty
());
assert
(
src
.
size
%
channels
==
0
);
assert
(
src
.
size
%
channels
==
0
);
assert
(
channels
<=
dsd2pcm
.
max_size
());
assert
(
channels
<=
dsd2pcm
.
max_size
());
...
...
src/tag/Builder.cxx
View file @
49784513
...
@@ -191,7 +191,7 @@ TagBuilder::Complement(const Tag &other)
...
@@ -191,7 +191,7 @@ TagBuilder::Complement(const Tag &other)
inline
void
inline
void
TagBuilder
::
AddItemInternal
(
TagType
type
,
StringView
value
)
TagBuilder
::
AddItemInternal
(
TagType
type
,
StringView
value
)
{
{
assert
(
!
value
.
IsE
mpty
());
assert
(
!
value
.
e
mpty
());
auto
f
=
FixTagString
(
value
);
auto
f
=
FixTagString
(
value
);
if
(
!
f
.
IsNull
())
if
(
!
f
.
IsNull
())
...
@@ -209,7 +209,7 @@ TagBuilder::AddItemInternal(TagType type, StringView value)
...
@@ -209,7 +209,7 @@ TagBuilder::AddItemInternal(TagType type, StringView value)
void
void
TagBuilder
::
AddItem
(
TagType
type
,
StringView
value
)
TagBuilder
::
AddItem
(
TagType
type
,
StringView
value
)
{
{
if
(
value
.
IsE
mpty
()
||
!
IsTagEnabled
(
type
))
if
(
value
.
e
mpty
()
||
!
IsTagEnabled
(
type
))
return
;
return
;
AddItemInternal
(
type
,
value
);
AddItemInternal
(
type
,
value
);
...
...
src/tag/Builder.hxx
View file @
49784513
...
@@ -74,7 +74,7 @@ public:
...
@@ -74,7 +74,7 @@ public:
* Returns true if the tag contains no items. This ignores
* Returns true if the tag contains no items. This ignores
* the "duration" attribute.
* the "duration" attribute.
*/
*/
bool
IsE
mpty
()
const
{
bool
e
mpty
()
const
{
return
items
.
empty
();
return
items
.
empty
();
}
}
...
@@ -83,7 +83,7 @@ public:
...
@@ -83,7 +83,7 @@ public:
*/
*/
gcc_pure
gcc_pure
bool
IsDefined
()
const
noexcept
{
bool
IsDefined
()
const
noexcept
{
return
!
duration
.
IsNegative
()
||
has_playlist
||
!
IsE
mpty
();
return
!
duration
.
IsNegative
()
||
has_playlist
||
!
e
mpty
();
}
}
void
Clear
();
void
Clear
();
...
...
src/tag/Id3Scan.cxx
View file @
49784513
...
@@ -334,7 +334,7 @@ tag_id3_import(struct id3_tag *tag)
...
@@ -334,7 +334,7 @@ tag_id3_import(struct id3_tag *tag)
{
{
TagBuilder
tag_builder
;
TagBuilder
tag_builder
;
scan_id3_tag
(
tag
,
add_tag_handler
,
&
tag_builder
);
scan_id3_tag
(
tag
,
add_tag_handler
,
&
tag_builder
);
return
tag_builder
.
IsE
mpty
()
return
tag_builder
.
e
mpty
()
?
nullptr
?
nullptr
:
tag_builder
.
CommitNew
();
:
tag_builder
.
CommitNew
();
}
}
...
...
src/util/AllocatedArray.hxx
View file @
49784513
...
@@ -112,7 +112,7 @@ public:
...
@@ -112,7 +112,7 @@ public:
* Returns true if no memory was allocated so far.
* Returns true if no memory was allocated so far.
*/
*/
constexpr
bool
empty
()
const
{
constexpr
bool
empty
()
const
{
return
buffer
.
IsE
mpty
();
return
buffer
.
e
mpty
();
}
}
/**
/**
...
...
src/util/CircularBuffer.hxx
View file @
49784513
...
@@ -90,7 +90,7 @@ public:
...
@@ -90,7 +90,7 @@ public:
return
capacity
;
return
capacity
;
}
}
constexpr
bool
IsE
mpty
()
const
{
constexpr
bool
e
mpty
()
const
{
return
head
==
tail
;
return
head
==
tail
;
}
}
...
...
src/util/ConstBuffer.hxx
View file @
49784513
...
@@ -84,7 +84,7 @@ struct ConstBuffer<void> {
...
@@ -84,7 +84,7 @@ struct ConstBuffer<void> {
return
data
!=
nullptr
;
return
data
!=
nullptr
;
}
}
constexpr
bool
IsE
mpty
()
const
{
constexpr
bool
e
mpty
()
const
{
return
size
==
0
;
return
size
==
0
;
}
}
};
};
...
@@ -167,7 +167,7 @@ struct ConstBuffer {
...
@@ -167,7 +167,7 @@ struct ConstBuffer {
return
data
!=
nullptr
;
return
data
!=
nullptr
;
}
}
constexpr
bool
IsE
mpty
()
const
{
constexpr
bool
e
mpty
()
const
{
return
size
==
0
;
return
size
==
0
;
}
}
...
@@ -217,7 +217,7 @@ struct ConstBuffer {
...
@@ -217,7 +217,7 @@ struct ConstBuffer {
#endif
#endif
reference_type
front
()
const
{
reference_type
front
()
const
{
#ifndef NDEBUG
#ifndef NDEBUG
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
#endif
#endif
return
data
[
0
];
return
data
[
0
];
}
}
...
@@ -231,7 +231,7 @@ struct ConstBuffer {
...
@@ -231,7 +231,7 @@ struct ConstBuffer {
#endif
#endif
reference_type
back
()
const
{
reference_type
back
()
const
{
#ifndef NDEBUG
#ifndef NDEBUG
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
#endif
#endif
return
data
[
size
-
1
];
return
data
[
size
-
1
];
}
}
...
@@ -242,7 +242,7 @@ struct ConstBuffer {
...
@@ -242,7 +242,7 @@ struct ConstBuffer {
*/
*/
void
pop_front
()
{
void
pop_front
()
{
#ifndef NDEBUG
#ifndef NDEBUG
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
#endif
#endif
++
data
;
++
data
;
...
@@ -255,7 +255,7 @@ struct ConstBuffer {
...
@@ -255,7 +255,7 @@ struct ConstBuffer {
*/
*/
void
pop_back
()
{
void
pop_back
()
{
#ifndef NDEBUG
#ifndef NDEBUG
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
#endif
#endif
--
size
;
--
size
;
...
...
src/util/DivideString.hxx
View file @
49784513
...
@@ -53,7 +53,7 @@ public:
...
@@ -53,7 +53,7 @@ public:
/**
/**
* Is the first part empty?
* Is the first part empty?
*/
*/
bool
IsE
mpty
()
const
{
bool
e
mpty
()
const
{
assert
(
IsDefined
());
assert
(
IsDefined
());
return
*
first
==
0
;
return
*
first
==
0
;
...
...
src/util/DynamicFifoBuffer.hxx
View file @
49784513
...
@@ -55,7 +55,7 @@ public:
...
@@ -55,7 +55,7 @@ public:
using
ForeignFifoBuffer
<
T
>::
GetCapacity
;
using
ForeignFifoBuffer
<
T
>::
GetCapacity
;
using
ForeignFifoBuffer
<
T
>::
Clear
;
using
ForeignFifoBuffer
<
T
>::
Clear
;
using
ForeignFifoBuffer
<
T
>::
IsE
mpty
;
using
ForeignFifoBuffer
<
T
>::
e
mpty
;
using
ForeignFifoBuffer
<
T
>::
IsFull
;
using
ForeignFifoBuffer
<
T
>::
IsFull
;
using
ForeignFifoBuffer
<
T
>::
GetAvailable
;
using
ForeignFifoBuffer
<
T
>::
GetAvailable
;
using
ForeignFifoBuffer
<
T
>::
Read
;
using
ForeignFifoBuffer
<
T
>::
Read
;
...
...
src/util/ForeignFifoBuffer.hxx
View file @
49784513
...
@@ -134,7 +134,7 @@ public:
...
@@ -134,7 +134,7 @@ public:
head
=
tail
=
0
;
head
=
tail
=
0
;
}
}
constexpr
bool
IsE
mpty
()
const
{
constexpr
bool
e
mpty
()
const
{
return
head
==
tail
;
return
head
==
tail
;
}
}
...
@@ -147,7 +147,7 @@ public:
...
@@ -147,7 +147,7 @@ public:
* When you are finished, call Append().
* When you are finished, call Append().
*/
*/
Range
Write
()
{
Range
Write
()
{
if
(
IsE
mpty
())
if
(
e
mpty
())
Clear
();
Clear
();
else
if
(
tail
==
capacity
)
else
if
(
tail
==
capacity
)
Shift
();
Shift
();
...
...
src/util/PeakBuffer.cxx
View file @
49784513
...
@@ -32,10 +32,10 @@ PeakBuffer::~PeakBuffer()
...
@@ -32,10 +32,10 @@ PeakBuffer::~PeakBuffer()
}
}
bool
bool
PeakBuffer
::
IsE
mpty
()
const
noexcept
PeakBuffer
::
e
mpty
()
const
noexcept
{
{
return
(
normal_buffer
==
nullptr
||
normal_buffer
->
IsE
mpty
())
&&
return
(
normal_buffer
==
nullptr
||
normal_buffer
->
e
mpty
())
&&
(
peak_buffer
==
nullptr
||
peak_buffer
->
IsE
mpty
());
(
peak_buffer
==
nullptr
||
peak_buffer
->
e
mpty
());
}
}
WritableBuffer
<
void
>
WritableBuffer
<
void
>
...
@@ -43,13 +43,13 @@ PeakBuffer::Read() const noexcept
...
@@ -43,13 +43,13 @@ PeakBuffer::Read() const noexcept
{
{
if
(
normal_buffer
!=
nullptr
)
{
if
(
normal_buffer
!=
nullptr
)
{
const
auto
p
=
normal_buffer
->
Read
();
const
auto
p
=
normal_buffer
->
Read
();
if
(
!
p
.
IsE
mpty
())
if
(
!
p
.
e
mpty
())
return
p
.
ToVoid
();
return
p
.
ToVoid
();
}
}
if
(
peak_buffer
!=
nullptr
)
{
if
(
peak_buffer
!=
nullptr
)
{
const
auto
p
=
peak_buffer
->
Read
();
const
auto
p
=
peak_buffer
->
Read
();
if
(
!
p
.
IsE
mpty
())
if
(
!
p
.
e
mpty
())
return
p
.
ToVoid
();
return
p
.
ToVoid
();
}
}
...
@@ -59,14 +59,14 @@ PeakBuffer::Read() const noexcept
...
@@ -59,14 +59,14 @@ PeakBuffer::Read() const noexcept
void
void
PeakBuffer
::
Consume
(
size_t
length
)
noexcept
PeakBuffer
::
Consume
(
size_t
length
)
noexcept
{
{
if
(
normal_buffer
!=
nullptr
&&
!
normal_buffer
->
IsE
mpty
())
{
if
(
normal_buffer
!=
nullptr
&&
!
normal_buffer
->
e
mpty
())
{
normal_buffer
->
Consume
(
length
);
normal_buffer
->
Consume
(
length
);
return
;
return
;
}
}
if
(
peak_buffer
!=
nullptr
&&
!
peak_buffer
->
IsE
mpty
())
{
if
(
peak_buffer
!=
nullptr
&&
!
peak_buffer
->
e
mpty
())
{
peak_buffer
->
Consume
(
length
);
peak_buffer
->
Consume
(
length
);
if
(
peak_buffer
->
IsE
mpty
())
{
if
(
peak_buffer
->
e
mpty
())
{
delete
peak_buffer
;
delete
peak_buffer
;
peak_buffer
=
nullptr
;
peak_buffer
=
nullptr
;
}
}
...
@@ -86,7 +86,7 @@ AppendTo(DynamicFifoBuffer<uint8_t> &buffer,
...
@@ -86,7 +86,7 @@ AppendTo(DynamicFifoBuffer<uint8_t> &buffer,
do
{
do
{
const
auto
p
=
buffer
.
Write
();
const
auto
p
=
buffer
.
Write
();
if
(
p
.
IsE
mpty
())
if
(
p
.
e
mpty
())
break
;
break
;
const
size_t
nbytes
=
std
::
min
(
length
,
p
.
size
);
const
size_t
nbytes
=
std
::
min
(
length
,
p
.
size
);
...
@@ -107,7 +107,7 @@ PeakBuffer::Append(const void *data, size_t length)
...
@@ -107,7 +107,7 @@ PeakBuffer::Append(const void *data, size_t length)
if
(
length
==
0
)
if
(
length
==
0
)
return
true
;
return
true
;
if
(
peak_buffer
!=
nullptr
&&
!
peak_buffer
->
IsE
mpty
())
{
if
(
peak_buffer
!=
nullptr
&&
!
peak_buffer
->
e
mpty
())
{
size_t
nbytes
=
AppendTo
(
*
peak_buffer
,
data
,
length
);
size_t
nbytes
=
AppendTo
(
*
peak_buffer
,
data
,
length
);
return
nbytes
==
length
;
return
nbytes
==
length
;
}
}
...
...
src/util/PeakBuffer.hxx
View file @
49784513
...
@@ -57,7 +57,7 @@ public:
...
@@ -57,7 +57,7 @@ public:
PeakBuffer
&
operator
=
(
const
PeakBuffer
&
)
=
delete
;
PeakBuffer
&
operator
=
(
const
PeakBuffer
&
)
=
delete
;
gcc_pure
gcc_pure
bool
IsE
mpty
()
const
noexcept
;
bool
e
mpty
()
const
noexcept
;
gcc_pure
gcc_pure
WritableBuffer
<
void
>
Read
()
const
noexcept
;
WritableBuffer
<
void
>
Read
()
const
noexcept
;
...
...
src/util/SliceBuffer.hxx
View file @
49784513
...
@@ -79,7 +79,7 @@ public:
...
@@ -79,7 +79,7 @@ public:
return
buffer
.
size
();
return
buffer
.
size
();
}
}
bool
IsE
mpty
()
const
{
bool
e
mpty
()
const
{
return
n_allocated
==
0
;
return
n_allocated
==
0
;
}
}
...
...
src/util/StaticFifoBuffer.hxx
View file @
49784513
...
@@ -78,7 +78,7 @@ public:
...
@@ -78,7 +78,7 @@ public:
head
=
tail
=
0
;
head
=
tail
=
0
;
}
}
bool
IsE
mpty
()
const
{
bool
e
mpty
()
const
{
return
head
==
tail
;
return
head
==
tail
;
}
}
...
@@ -91,7 +91,7 @@ public:
...
@@ -91,7 +91,7 @@ public:
* When you are finished, call Append().
* When you are finished, call Append().
*/
*/
Range
Write
()
{
Range
Write
()
{
if
(
IsE
mpty
())
if
(
e
mpty
())
Clear
();
Clear
();
else
if
(
tail
==
size
)
else
if
(
tail
==
size
)
Shift
();
Shift
();
...
...
src/util/StringView.cxx
View file @
49784513
...
@@ -34,7 +34,7 @@ template<typename T>
...
@@ -34,7 +34,7 @@ template<typename T>
void
void
BasicStringView
<
T
>::
StripLeft
()
noexcept
BasicStringView
<
T
>::
StripLeft
()
noexcept
{
{
while
(
!
IsE
mpty
()
&&
IsWhitespaceOrNull
(
front
()))
while
(
!
e
mpty
()
&&
IsWhitespaceOrNull
(
front
()))
pop_front
();
pop_front
();
}
}
...
@@ -42,7 +42,7 @@ template<typename T>
...
@@ -42,7 +42,7 @@ template<typename T>
void
void
BasicStringView
<
T
>::
StripRight
()
noexcept
BasicStringView
<
T
>::
StripRight
()
noexcept
{
{
while
(
!
IsE
mpty
()
&&
IsWhitespaceOrNull
(
back
()))
while
(
!
e
mpty
()
&&
IsWhitespaceOrNull
(
back
()))
pop_back
();
pop_back
();
}
}
...
...
src/util/StringView.hxx
View file @
49784513
...
@@ -58,7 +58,7 @@ struct BasicStringView : ConstBuffer<T> {
...
@@ -58,7 +58,7 @@ struct BasicStringView : ConstBuffer<T> {
constexpr
BasicStringView
(
std
::
nullptr_t
n
)
noexcept
constexpr
BasicStringView
(
std
::
nullptr_t
n
)
noexcept
:
ConstBuffer
<
T
>
(
n
)
{}
:
ConstBuffer
<
T
>
(
n
)
{}
using
ConstBuffer
<
T
>::
IsE
mpty
;
using
ConstBuffer
<
T
>::
e
mpty
;
using
ConstBuffer
<
T
>::
front
;
using
ConstBuffer
<
T
>::
front
;
using
ConstBuffer
<
T
>::
back
;
using
ConstBuffer
<
T
>::
back
;
using
ConstBuffer
<
T
>::
pop_front
;
using
ConstBuffer
<
T
>::
pop_front
;
...
...
src/util/UriUtil.cxx
View file @
49784513
...
@@ -41,7 +41,7 @@ gcc_pure
...
@@ -41,7 +41,7 @@ gcc_pure
static
bool
static
bool
IsValidScheme
(
StringView
p
)
noexcept
IsValidScheme
(
StringView
p
)
noexcept
{
{
if
(
p
.
IsE
mpty
()
||
!
IsValidSchemeStart
(
p
.
front
()))
if
(
p
.
e
mpty
()
||
!
IsValidSchemeStart
(
p
.
front
()))
return
false
;
return
false
;
for
(
size_t
i
=
1
;
i
<
p
.
size
;
++
i
)
for
(
size_t
i
=
1
;
i
<
p
.
size
;
++
i
)
...
...
src/util/WritableBuffer.hxx
View file @
49784513
...
@@ -76,7 +76,7 @@ struct WritableBuffer<void> {
...
@@ -76,7 +76,7 @@ struct WritableBuffer<void> {
return
data
!=
nullptr
;
return
data
!=
nullptr
;
}
}
constexpr
bool
IsE
mpty
()
const
{
constexpr
bool
e
mpty
()
const
{
return
size
==
0
;
return
size
==
0
;
}
}
};
};
...
@@ -161,7 +161,7 @@ struct WritableBuffer {
...
@@ -161,7 +161,7 @@ struct WritableBuffer {
return
data
!=
nullptr
;
return
data
!=
nullptr
;
}
}
constexpr
bool
IsE
mpty
()
const
{
constexpr
bool
e
mpty
()
const
{
return
size
==
0
;
return
size
==
0
;
}
}
...
@@ -201,7 +201,7 @@ struct WritableBuffer {
...
@@ -201,7 +201,7 @@ struct WritableBuffer {
#endif
#endif
reference_type
front
()
const
{
reference_type
front
()
const
{
#ifndef NDEBUG
#ifndef NDEBUG
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
#endif
#endif
return
data
[
0
];
return
data
[
0
];
}
}
...
@@ -215,7 +215,7 @@ struct WritableBuffer {
...
@@ -215,7 +215,7 @@ struct WritableBuffer {
#endif
#endif
reference_type
back
()
const
{
reference_type
back
()
const
{
#ifndef NDEBUG
#ifndef NDEBUG
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
#endif
#endif
return
data
[
size
-
1
];
return
data
[
size
-
1
];
}
}
...
@@ -225,7 +225,7 @@ struct WritableBuffer {
...
@@ -225,7 +225,7 @@ struct WritableBuffer {
* not actually modify the buffer). Buffer must not be empty.
* not actually modify the buffer). Buffer must not be empty.
*/
*/
void
pop_front
()
{
void
pop_front
()
{
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
++
data
;
++
data
;
--
size
;
--
size
;
...
@@ -236,7 +236,7 @@ struct WritableBuffer {
...
@@ -236,7 +236,7 @@ struct WritableBuffer {
* not actually modify the buffer). Buffer must not be empty.
* not actually modify the buffer). Buffer must not be empty.
*/
*/
void
pop_back
()
{
void
pop_back
()
{
assert
(
!
IsE
mpty
());
assert
(
!
e
mpty
());
--
size
;
--
size
;
}
}
...
...
test/DivideStringTest.hxx
View file @
49784513
...
@@ -23,7 +23,7 @@ public:
...
@@ -23,7 +23,7 @@ public:
constexpr
char
input
[]
=
"foo.bar"
;
constexpr
char
input
[]
=
"foo.bar"
;
const
DivideString
ds
(
input
,
'.'
);
const
DivideString
ds
(
input
,
'.'
);
CPPUNIT_ASSERT
(
ds
.
IsDefined
());
CPPUNIT_ASSERT
(
ds
.
IsDefined
());
CPPUNIT_ASSERT
(
!
ds
.
IsE
mpty
());
CPPUNIT_ASSERT
(
!
ds
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
ds
.
GetFirst
(),
"foo"
));
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
ds
.
GetFirst
(),
"foo"
));
CPPUNIT_ASSERT_EQUAL
(
input
+
4
,
ds
.
GetSecond
());
CPPUNIT_ASSERT_EQUAL
(
input
+
4
,
ds
.
GetSecond
());
}
}
...
@@ -32,7 +32,7 @@ public:
...
@@ -32,7 +32,7 @@ public:
constexpr
char
input
[]
=
".bar"
;
constexpr
char
input
[]
=
".bar"
;
const
DivideString
ds
(
input
,
'.'
);
const
DivideString
ds
(
input
,
'.'
);
CPPUNIT_ASSERT
(
ds
.
IsDefined
());
CPPUNIT_ASSERT
(
ds
.
IsDefined
());
CPPUNIT_ASSERT
(
ds
.
IsE
mpty
());
CPPUNIT_ASSERT
(
ds
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
ds
.
GetFirst
(),
""
));
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
ds
.
GetFirst
(),
""
));
CPPUNIT_ASSERT_EQUAL
(
input
+
1
,
ds
.
GetSecond
());
CPPUNIT_ASSERT_EQUAL
(
input
+
1
,
ds
.
GetSecond
());
}
}
...
@@ -47,7 +47,7 @@ public:
...
@@ -47,7 +47,7 @@ public:
constexpr
char
input
[]
=
" foo
\t
.
\n
bar
\r
"
;
constexpr
char
input
[]
=
" foo
\t
.
\n
bar
\r
"
;
const
DivideString
ds
(
input
,
'.'
,
true
);
const
DivideString
ds
(
input
,
'.'
,
true
);
CPPUNIT_ASSERT
(
ds
.
IsDefined
());
CPPUNIT_ASSERT
(
ds
.
IsDefined
());
CPPUNIT_ASSERT
(
!
ds
.
IsE
mpty
());
CPPUNIT_ASSERT
(
!
ds
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
ds
.
GetFirst
(),
"foo"
));
CPPUNIT_ASSERT_EQUAL
(
0
,
strcmp
(
ds
.
GetFirst
(),
"foo"
));
CPPUNIT_ASSERT_EQUAL
(
input
+
7
,
ds
.
GetSecond
());
CPPUNIT_ASSERT_EQUAL
(
input
+
7
,
ds
.
GetSecond
());
}
}
...
...
test/TestCircularBuffer.hxx
View file @
49784513
...
@@ -25,52 +25,52 @@ public:
...
@@ -25,52 +25,52 @@ public:
/* checks on empty buffer */
/* checks on empty buffer */
/* [.......X] */
/* [.......X] */
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
0
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
0
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
&
data
[
0
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
0
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
Write
().
size
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
Write
().
size
);
/* append one element */
/* append one element */
/* [O......X] */
/* [O......X] */
buffer
.
Append
(
1
);
buffer
.
Append
(
1
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
6
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
6
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
0
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
0
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
&
data
[
1
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
1
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
6
),
buffer
.
Write
().
size
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
6
),
buffer
.
Write
().
size
);
/* append 6 elements, buffer is now full */
/* append 6 elements, buffer is now full */
/* [OOOOOOOX] */
/* [OOOOOOOX] */
buffer
.
Append
(
6
);
buffer
.
Append
(
6
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
0
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
0
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
0
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
0
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Write
().
e
mpty
());
/* consume [0]; can append one at [7] */
/* consume [0]; can append one at [7] */
/* [XOOOOOO.] */
/* [XOOOOOO.] */
buffer
.
Consume
(
1
);
buffer
.
Consume
(
1
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
6
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
6
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
6
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
6
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
1
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
1
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
&
data
[
7
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
7
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
Write
().
size
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
Write
().
size
);
...
@@ -78,66 +78,66 @@ public:
...
@@ -78,66 +78,66 @@ public:
be written to because head==1 */
be written to because head==1 */
/* [XOOOOOOO] */
/* [XOOOOOOO] */
buffer
.
Append
(
1
);
buffer
.
Append
(
1
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
0
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
0
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
1
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
1
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Write
().
e
mpty
());
/* consume [1..3]; can append [0..2] */
/* consume [1..3]; can append [0..2] */
/* [...XOOOO] */
/* [...XOOOO] */
buffer
.
Consume
(
3
);
buffer
.
Consume
(
3
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
3
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
3
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
4
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
4
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
&
data
[
0
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
0
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
3
),
buffer
.
Write
().
size
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
3
),
buffer
.
Write
().
size
);
/* append [0..1] */
/* append [0..1] */
/* [OO.XOOOO] */
/* [OO.XOOOO] */
buffer
.
Append
(
2
);
buffer
.
Append
(
2
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
6
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
6
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
4
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
4
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
&
data
[
2
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
2
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
Write
().
size
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
1
),
buffer
.
Write
().
size
);
/* append [2] */
/* append [2] */
/* [OOOXOOOO] */
/* [OOOXOOOO] */
buffer
.
Append
(
1
);
buffer
.
Append
(
1
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
0
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
0
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
4
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
4
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Write
().
e
mpty
());
/* consume [4..7] */
/* consume [4..7] */
/* [OOO....X] */
/* [OOO....X] */
buffer
.
Consume
(
4
);
buffer
.
Consume
(
4
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
3
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
3
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
3
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
3
),
buffer
.
Read
().
size
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
0
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
0
],
buffer
.
Read
().
data
);
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
&
data
[
3
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
3
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
Write
().
size
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
4
),
buffer
.
Write
().
size
);
...
@@ -146,12 +146,12 @@ public:
...
@@ -146,12 +146,12 @@ public:
special code to rewind/reset an empty buffer */
special code to rewind/reset an empty buffer */
/* [..X.....] */
/* [..X.....] */
buffer
.
Consume
(
3
);
buffer
.
Consume
(
3
);
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
IsFull
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
0
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
0
),
buffer
.
GetSize
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
size_t
(
7
),
buffer
.
GetSpace
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Read
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
true
,
buffer
.
Read
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
IsE
mpty
());
CPPUNIT_ASSERT_EQUAL
(
false
,
buffer
.
Write
().
e
mpty
());
CPPUNIT_ASSERT_EQUAL
(
&
data
[
3
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
&
data
[
3
],
buffer
.
Write
().
data
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
5
),
buffer
.
Write
().
size
);
CPPUNIT_ASSERT_EQUAL
(
size_t
(
5
),
buffer
.
Write
().
size
);
}
}
...
...
test/run_convert.cxx
View file @
49784513
...
@@ -62,7 +62,7 @@ try {
...
@@ -62,7 +62,7 @@ try {
while
(
true
)
{
while
(
true
)
{
{
{
const
auto
dest
=
buffer
.
Write
();
const
auto
dest
=
buffer
.
Write
();
assert
(
!
dest
.
IsE
mpty
());
assert
(
!
dest
.
e
mpty
());
ssize_t
nbytes
=
read
(
0
,
dest
.
data
,
dest
.
size
);
ssize_t
nbytes
=
read
(
0
,
dest
.
data
,
dest
.
size
);
if
(
nbytes
<=
0
)
if
(
nbytes
<=
0
)
...
@@ -72,10 +72,10 @@ try {
...
@@ -72,10 +72,10 @@ try {
}
}
auto
src
=
buffer
.
Read
();
auto
src
=
buffer
.
Read
();
assert
(
!
src
.
IsE
mpty
());
assert
(
!
src
.
e
mpty
());
src
.
size
-=
src
.
size
%
in_frame_size
;
src
.
size
-=
src
.
size
%
in_frame_size
;
if
(
src
.
IsE
mpty
())
if
(
src
.
e
mpty
())
continue
;
continue
;
buffer
.
Consume
(
src
.
size
);
buffer
.
Consume
(
src
.
size
);
...
...
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