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
b4c517c5
Commit
b4c517c5
authored
Aug 02, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
song/AudioFormatFilter: add mask support
parent
b39bc85e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
8 deletions
+21
-8
protocol.xml
doc/protocol.xml
+8
-0
AudioFormatSongFilter.cxx
src/song/AudioFormatSongFilter.cxx
+5
-4
Filter.cxx
src/song/Filter.cxx
+8
-4
No files found.
doc/protocol.xml
View file @
b4c517c5
...
...
@@ -278,6 +278,14 @@
<listitem>
<para>
"
<code>
(AudioFormat =~ 'SAMPLERATE:BITS:CHANNELS')
</code>
":
matches the audio format with the given mask (i.e. one
or more attributes may be "
<code>
*
</code>
").
</para>
</listitem>
<listitem>
<para>
"
<code>
(!EXPRESSION)
</code>
": negate an expression.
</para>
</listitem>
...
...
src/song/AudioFormatSongFilter.cxx
View file @
b4c517c5
...
...
@@ -24,13 +24,14 @@
std
::
string
AudioFormatSongFilter
::
ToExpression
()
const
noexcept
{
// TODO: support mask
return
std
::
string
(
"(AudioFormat ==
\"
"
)
+
ToString
(
value
).
c_str
()
+
"
\"
)"
;
return
std
::
string
(
"(AudioFormat "
)
+
(
value
.
IsFullyDefined
()
?
"=="
:
"=~"
)
+
"
\"
"
+
ToString
(
value
).
c_str
()
+
"
\"
)"
;
}
bool
AudioFormatSongFilter
::
Match
(
const
LightSong
&
song
)
const
noexcept
{
// TODO: support mask
return
song
.
audio_format
==
value
;
return
song
.
audio_format
.
IsDefined
()
&&
song
.
audio_format
.
MatchMask
(
value
)
;
}
src/song/Filter.cxx
View file @
b4c517c5
...
...
@@ -245,14 +245,18 @@ SongFilter::ParseExpression(const char *&s, bool fold_case)
return
std
::
make_unique
<
BaseSongFilter
>
(
std
::
move
(
value
));
}
else
if
(
type
==
LOCATE_TAG_AUDIO_FORMAT
)
{
if
(
s
[
0
]
!=
'='
||
s
[
1
]
!=
'='
)
throw
std
::
runtime_error
(
"'==' expected"
);
bool
mask
;
if
(
s
[
0
]
==
'='
&&
s
[
1
]
==
'='
)
mask
=
false
;
else
if
(
s
[
0
]
==
'='
&&
s
[
1
]
==
'~'
)
mask
=
true
;
else
throw
std
::
runtime_error
(
"'==' or '=~' expected"
);
s
=
StripLeft
(
s
+
2
);
// TODO: support mask
const
auto
value
=
ParseAudioFormat
(
ExpectQuoted
(
s
).
c_str
(),
false
);
mask
);
if
(
*
s
!=
')'
)
throw
std
::
runtime_error
(
"')' expected"
);
...
...
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