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
ac395429
Commit
ac395429
authored
Apr 26, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/proxy: implement the group_mask parameter in VisitUniqueTags()
Closes #258
parent
388768b3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
10 deletions
+54
-10
NEWS
NEWS
+1
-0
ProxyDatabasePlugin.cxx
src/db/plugins/ProxyDatabasePlugin.cxx
+53
-10
No files found.
NEWS
View file @
ac395429
...
...
@@ -3,6 +3,7 @@ ver 0.20.19 (not yet released)
- validate absolute seek time, reject negative values
* database
- proxy: fix "search already in progress" errors
- proxy: implement "list ... group"
* input
- mms: fix lockup bug and a crash bug
* decoder
...
...
src/db/plugins/ProxyDatabasePlugin.cxx
View file @
ac395429
...
...
@@ -325,6 +325,34 @@ SendConstraints(mpd_connection *connection, const DatabaseSelection &selection)
return
true
;
}
static
bool
SendGroupMask
(
mpd_connection
*
connection
,
tag_mask_t
mask
)
{
#if LIBMPDCLIENT_CHECK_VERSION(2,12,0)
for
(
unsigned
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
++
i
)
{
if
((
mask
&
(
tag_mask_t
(
1
)
<<
i
))
==
0
)
continue
;
const
auto
tag
=
Convert
(
TagType
(
i
));
if
(
tag
==
MPD_TAG_COUNT
)
throw
std
::
runtime_error
(
"Unsupported tag"
);
if
(
!
mpd_search_add_group_tag
(
connection
,
tag
))
return
false
;
}
return
true
;
#else
(
void
)
connection
;
(
void
)
mask
;
if
(
mask
!=
0
)
throw
std
::
runtime_error
(
"Grouping requires libmpdclient 2.12"
);
return
true
;
#endif
}
ProxyDatabase
::
ProxyDatabase
(
EventLoop
&
_loop
,
DatabaseListener
&
_listener
,
const
ConfigBlock
&
block
)
:
Database
(
proxy_db_plugin
),
...
...
@@ -761,7 +789,7 @@ ProxyDatabase::Visit(const DatabaseSelection &selection,
void
ProxyDatabase
::
VisitUniqueTags
(
const
DatabaseSelection
&
selection
,
TagType
tag_type
,
gcc_unused
tag_mask_t
group_mask
,
tag_mask_t
group_mask
,
VisitTag
visit_tag
)
const
try
{
// TODO: eliminate the const_cast
...
...
@@ -772,32 +800,47 @@ try {
throw
std
::
runtime_error
(
"Unsupported tag"
);
if
(
!
mpd_search_db_tags
(
connection
,
tag_type2
)
||
!
SendConstraints
(
connection
,
selection
))
!
SendConstraints
(
connection
,
selection
)
||
!
SendGroupMask
(
connection
,
group_mask
))
ThrowError
(
connection
);
// TODO: use group_mask
if
(
!
mpd_search_commit
(
connection
))
ThrowError
(
connection
);
while
(
auto
*
pair
=
mpd_recv_pair_tag
(
connection
,
tag_type2
))
{
TagBuilder
builder
;
while
(
auto
*
pair
=
mpd_recv_pair
(
connection
))
{
AtScopeExit
(
this
,
pair
)
{
mpd_return_pair
(
connection
,
pair
);
};
TagBuilder
tag
;
tag
.
AddItem
(
tag_type
,
pair
->
value
);
const
auto
current_type
=
tag_name_parse_i
(
pair
->
name
);
if
(
current_type
==
TAG_NUM_OF_ITEM_TYPES
)
continue
;
if
(
current_type
==
tag_type
&&
!
builder
.
IsEmpty
())
{
try
{
visit_tag
(
builder
.
Commit
());
}
catch
(...)
{
mpd_response_finish
(
connection
);
throw
;
}
}
builder
.
AddItem
(
current_type
,
pair
->
value
);
if
(
tag
.
IsEmpty
(
))
if
(
!
builder
.
HasType
(
current_type
))
/* if no tag item has been added, then the
given value was not acceptable
(e.g. empty); forcefully insert an empty
tag in this case, as the caller expects the
given tag type to be present */
tag
.
AddEmptyItem
(
tag_type
);
builder
.
AddEmptyItem
(
current_type
);
}
if
(
!
builder
.
IsEmpty
())
{
try
{
visit_tag
(
tag
.
Commit
());
visit_tag
(
builder
.
Commit
());
}
catch
(...)
{
mpd_response_finish
(
connection
);
throw
;
...
...
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