Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jean-Francois Dockes
upmpdcli
Commits
5aa0eaf9
Commit
5aa0eaf9
authored
Feb 18, 2017
by
Jean-Francois Dockes
Browse files
Copy audio params fields into UpSong. Avoid erasing value with empty string
parent
2273716d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/mediaserver/cdplugins/plgwithslave.cxx
View file @
5aa0eaf9
...
...
@@ -286,6 +286,18 @@ PlgWithSlave::~PlgWithSlave()
delete
m
;
}
static
void
catstring
(
string
&
dest
,
const
string
&
s2
)
{
if
(
s2
.
empty
())
{
return
;
}
if
(
dest
.
empty
())
{
dest
=
s2
;
}
else
{
dest
+=
string
(
" "
)
+
s2
;
}
}
static
int
resultToEntries
(
const
string
&
encoded
,
int
stidx
,
int
cnt
,
vector
<
UpSong
>&
entries
)
{
...
...
@@ -297,7 +309,8 @@ static int resultToEntries(const string& encoded, int stidx, int cnt,
bool
dolimit
=
cnt
>
0
;
for
(
unsigned
int
i
=
stidx
;
i
<
decoded
.
size
();
i
++
)
{
#define JSONTOUPS(fld, nm) {song.fld = decoded[i].get(#nm, "").asString();}
#define JSONTOUPS(fld, nm) {catstring(song.fld, \
decoded[i].get(#nm, "").asString());}
if
(
dolimit
&&
--
cnt
<
0
)
{
break
;
}
...
...
@@ -324,13 +337,26 @@ static int resultToEntries(const string& encoded, int stidx, int cnt,
JSONTOUPS
(
album
,
upnp
:
album
);
JSONTOUPS
(
tracknum
,
upnp
:
originalTrackNumber
);
JSONTOUPS
(
mime
,
res
:
mime
);
string
srate
=
decoded
[
i
].
get
(
"res:samplefreq"
,
""
).
asString
();
if
(
!
srate
.
empty
())
{
song
.
samplefreq
=
atoi
(
srate
.
c_str
());
string
ss
=
decoded
[
i
].
get
(
"duration"
,
""
).
asString
();
if
(
!
ss
.
empty
())
{
song
.
duration_secs
=
atoi
(
ss
.
c_str
());
}
ss
=
decoded
[
i
].
get
(
"res:size"
,
""
).
asString
();
if
(
!
ss
.
empty
())
{
song
.
size
=
atoll
(
ss
.
c_str
());
}
ss
=
decoded
[
i
].
get
(
"res:bitrate"
,
""
).
asString
();
if
(
!
ss
.
empty
())
{
song
.
bitrate
=
atoi
(
ss
.
c_str
());
}
ss
=
decoded
[
i
].
get
(
"res:samplefreq"
,
""
).
asString
();
if
(
!
ss
.
empty
())
{
song
.
samplefreq
=
atoi
(
ss
.
c_str
());
}
s
tring
sdur
=
decoded
[
i
].
get
(
"
duration
"
,
""
).
asString
();
if
(
!
s
dur
.
empty
())
{
song
.
duration_sec
s
=
atoi
(
s
dur
.
c_str
());
s
s
=
decoded
[
i
].
get
(
"
res:channels
"
,
""
).
asString
();
if
(
!
s
s
.
empty
())
{
song
.
channel
s
=
atoi
(
s
s
.
c_str
());
}
}
else
{
LOGERR
(
"PlgWithSlave::result: bad type in entry: "
<<
stp
<<
...
...
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