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
b9ff6383
Commit
b9ff6383
authored
6 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/LightSong: make Tag a reference
This enforces the "not nullptr" rule.
parent
ebc006ab
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
23 additions
and
26 deletions
+23
-26
DetachedSong.cxx
src/DetachedSong.cxx
+2
-3
SongFilter.cxx
src/SongFilter.cxx
+1
-1
SongPrint.cxx
src/SongPrint.cxx
+1
-1
Count.cxx
src/db/Count.cxx
+1
-3
DatabasePrint.cxx
src/db/DatabasePrint.cxx
+2
-2
Helpers.cxx
src/db/Helpers.cxx
+1
-1
LightSong.cxx
src/db/LightSong.cxx
+3
-3
LightSong.hxx
src/db/LightSong.hxx
+5
-2
UniqueTags.cxx
src/db/UniqueTags.cxx
+1
-2
ProxyDatabasePlugin.cxx
src/db/plugins/ProxyDatabasePlugin.cxx
+1
-1
Song.cxx
src/db/plugins/simple/Song.cxx
+1
-2
UpnpDatabasePlugin.cxx
src/db/plugins/upnp/UpnpDatabasePlugin.cxx
+3
-4
PlaylistUpdate.cxx
src/queue/PlaylistUpdate.cxx
+1
-1
No files found.
src/DetachedSong.cxx
View file @
b9ff6383
...
@@ -26,18 +26,17 @@
...
@@ -26,18 +26,17 @@
DetachedSong
::
DetachedSong
(
const
LightSong
&
other
)
DetachedSong
::
DetachedSong
(
const
LightSong
&
other
)
:
uri
(
other
.
GetURI
()),
:
uri
(
other
.
GetURI
()),
real_uri
(
other
.
real_uri
!=
nullptr
?
other
.
real_uri
:
""
),
real_uri
(
other
.
real_uri
!=
nullptr
?
other
.
real_uri
:
""
),
tag
(
*
other
.
tag
),
tag
(
other
.
tag
),
mtime
(
other
.
mtime
),
mtime
(
other
.
mtime
),
start_time
(
other
.
start_time
),
start_time
(
other
.
start_time
),
end_time
(
other
.
end_time
)
{}
end_time
(
other
.
end_time
)
{}
DetachedSong
::
operator
LightSong
()
const
noexcept
DetachedSong
::
operator
LightSong
()
const
noexcept
{
{
LightSong
result
;
LightSong
result
(
tag
)
;
result
.
directory
=
nullptr
;
result
.
directory
=
nullptr
;
result
.
uri
=
uri
.
c_str
();
result
.
uri
=
uri
.
c_str
();
result
.
real_uri
=
real_uri
.
empty
()
?
nullptr
:
real_uri
.
c_str
();
result
.
real_uri
=
real_uri
.
empty
()
?
nullptr
:
real_uri
.
c_str
();
result
.
tag
=
&
tag
;
result
.
mtime
=
mtime
;
result
.
mtime
=
mtime
;
result
.
start_time
=
start_time
;
result
.
start_time
=
start_time
;
result
.
end_time
=
end_time
;
result
.
end_time
=
end_time
;
...
...
This diff is collapsed.
Click to expand it.
src/SongFilter.cxx
View file @
b9ff6383
...
@@ -164,7 +164,7 @@ SongFilter::Item::Match(const LightSong &song) const noexcept
...
@@ -164,7 +164,7 @@ SongFilter::Item::Match(const LightSong &song) const noexcept
return
StringMatch
(
uri
.
c_str
());
return
StringMatch
(
uri
.
c_str
());
}
}
return
Match
(
*
song
.
tag
);
return
Match
(
song
.
tag
);
}
}
SongFilter
::
SongFilter
(
unsigned
tag
,
const
char
*
value
,
bool
fold_case
)
SongFilter
::
SongFilter
(
unsigned
tag
,
const
char
*
value
,
bool
fold_case
)
...
...
This diff is collapsed.
Click to expand it.
src/SongPrint.cxx
View file @
b9ff6383
...
@@ -92,7 +92,7 @@ song_print_info(Response &r, const LightSong &song, bool base) noexcept
...
@@ -92,7 +92,7 @@ song_print_info(Response &r, const LightSong &song, bool base) noexcept
if
(
!
IsNegative
(
song
.
mtime
))
if
(
!
IsNegative
(
song
.
mtime
))
time_print
(
r
,
"Last-Modified"
,
song
.
mtime
);
time_print
(
r
,
"Last-Modified"
,
song
.
mtime
);
tag_print
(
r
,
*
song
.
tag
);
tag_print
(
r
,
song
.
tag
);
}
}
void
void
...
...
This diff is collapsed.
Click to expand it.
src/db/Count.cxx
View file @
b9ff6383
...
@@ -97,9 +97,7 @@ static void
...
@@ -97,9 +97,7 @@ static void
GroupCountVisitor
(
TagCountMap
&
map
,
TagType
group
,
GroupCountVisitor
(
TagCountMap
&
map
,
TagType
group
,
const
LightSong
&
song
)
noexcept
const
LightSong
&
song
)
noexcept
{
{
assert
(
song
.
tag
!=
nullptr
);
const
Tag
&
tag
=
song
.
tag
;
const
Tag
&
tag
=
*
song
.
tag
;
if
(
!
CollectGroupCounts
(
map
,
group
,
tag
)
&&
group
==
TAG_ALBUM_ARTIST
)
if
(
!
CollectGroupCounts
(
map
,
group
,
tag
)
&&
group
==
TAG_ALBUM_ARTIST
)
/* fall back to "Artist" if no "AlbumArtist" was found */
/* fall back to "Artist" if no "AlbumArtist" was found */
CollectGroupCounts
(
map
,
TAG_ARTIST
,
tag
);
CollectGroupCounts
(
map
,
TAG_ARTIST
,
tag
);
...
...
This diff is collapsed.
Click to expand it.
src/db/DatabasePrint.cxx
View file @
b9ff6383
...
@@ -105,7 +105,7 @@ PrintSongBrief(Response &r, bool base, const LightSong &song) noexcept
...
@@ -105,7 +105,7 @@ PrintSongBrief(Response &r, bool base, const LightSong &song) noexcept
{
{
song_print_uri
(
r
,
song
,
base
);
song_print_uri
(
r
,
song
,
base
);
if
(
song
.
tag
->
has_playlist
)
if
(
song
.
tag
.
has_playlist
)
/* this song file has an embedded CUE sheet */
/* this song file has an embedded CUE sheet */
print_playlist_in_directory
(
r
,
base
,
print_playlist_in_directory
(
r
,
base
,
song
.
directory
,
song
.
uri
);
song
.
directory
,
song
.
uri
);
...
@@ -116,7 +116,7 @@ PrintSongFull(Response &r, bool base, const LightSong &song) noexcept
...
@@ -116,7 +116,7 @@ PrintSongFull(Response &r, bool base, const LightSong &song) noexcept
{
{
song_print_info
(
r
,
song
,
base
);
song_print_info
(
r
,
song
,
base
);
if
(
song
.
tag
->
has_playlist
)
if
(
song
.
tag
.
has_playlist
)
/* this song file has an embedded CUE sheet */
/* this song file has an embedded CUE sheet */
print_playlist_in_directory
(
r
,
base
,
print_playlist_in_directory
(
r
,
base
,
song
.
directory
,
song
.
uri
);
song
.
directory
,
song
.
uri
);
...
...
This diff is collapsed.
Click to expand it.
src/db/Helpers.cxx
View file @
b9ff6383
...
@@ -65,7 +65,7 @@ StatsVisitSong(DatabaseStats &stats, StringSet &artists, StringSet &albums,
...
@@ -65,7 +65,7 @@ StatsVisitSong(DatabaseStats &stats, StringSet &artists, StringSet &albums,
{
{
++
stats
.
song_count
;
++
stats
.
song_count
;
StatsVisitTag
(
stats
,
artists
,
albums
,
*
song
.
tag
);
StatsVisitTag
(
stats
,
artists
,
albums
,
song
.
tag
);
}
}
DatabaseStats
DatabaseStats
...
...
This diff is collapsed.
Click to expand it.
src/db/LightSong.cxx
View file @
b9ff6383
...
@@ -25,10 +25,10 @@ LightSong::GetDuration() const noexcept
...
@@ -25,10 +25,10 @@ LightSong::GetDuration() const noexcept
{
{
SongTime
a
=
start_time
,
b
=
end_time
;
SongTime
a
=
start_time
,
b
=
end_time
;
if
(
!
b
.
IsPositive
())
{
if
(
!
b
.
IsPositive
())
{
if
(
tag
->
duration
.
IsNegative
())
if
(
tag
.
duration
.
IsNegative
())
return
tag
->
duration
;
return
tag
.
duration
;
b
=
SongTime
(
tag
->
duration
);
b
=
SongTime
(
tag
.
duration
);
}
}
return
SignedSongTime
(
b
-
a
);
return
SignedSongTime
(
b
-
a
);
...
...
This diff is collapsed.
Click to expand it.
src/db/LightSong.hxx
View file @
b9ff6383
...
@@ -57,9 +57,9 @@ struct LightSong {
...
@@ -57,9 +57,9 @@ struct LightSong {
const
char
*
real_uri
;
const
char
*
real_uri
;
/**
/**
* M
ust not be nullptr
.
* M
etadata
.
*/
*/
const
Tag
*
tag
;
const
Tag
&
tag
;
/**
/**
* The time stamp of the last file modification. A negative
* The time stamp of the last file modification. A negative
...
@@ -78,6 +78,9 @@ struct LightSong {
...
@@ -78,6 +78,9 @@ struct LightSong {
*/
*/
SongTime
end_time
;
SongTime
end_time
;
explicit
LightSong
(
const
Tag
&
_tag
)
noexcept
:
tag
(
_tag
)
{}
gcc_pure
gcc_pure
std
::
string
GetURI
()
const
noexcept
{
std
::
string
GetURI
()
const
noexcept
{
if
(
directory
==
nullptr
)
if
(
directory
==
nullptr
)
...
...
This diff is collapsed.
Click to expand it.
src/db/UniqueTags.cxx
View file @
b9ff6383
...
@@ -31,8 +31,7 @@ static void
...
@@ -31,8 +31,7 @@ static void
CollectTags
(
TagSet
&
set
,
TagType
tag_type
,
TagMask
group_mask
,
CollectTags
(
TagSet
&
set
,
TagType
tag_type
,
TagMask
group_mask
,
const
LightSong
&
song
)
const
LightSong
&
song
)
{
{
assert
(
song
.
tag
!=
nullptr
);
const
Tag
&
tag
=
song
.
tag
;
const
Tag
&
tag
=
*
song
.
tag
;
set
.
InsertUnique
(
tag
,
tag_type
,
group_mask
);
set
.
InsertUnique
(
tag
,
tag_type
,
group_mask
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/db/plugins/ProxyDatabasePlugin.cxx
View file @
b9ff6383
...
@@ -203,11 +203,11 @@ Copy(TagBuilder &tag, TagType d_tag,
...
@@ -203,11 +203,11 @@ Copy(TagBuilder &tag, TagType d_tag,
}
}
ProxySong
::
ProxySong
(
const
mpd_song
*
song
)
ProxySong
::
ProxySong
(
const
mpd_song
*
song
)
:
LightSong
(
tag2
)
{
{
directory
=
nullptr
;
directory
=
nullptr
;
uri
=
mpd_song_get_uri
(
song
);
uri
=
mpd_song_get_uri
(
song
);
real_uri
=
nullptr
;
real_uri
=
nullptr
;
tag
=
&
tag2
;
const
auto
_mtime
=
mpd_song_get_last_modified
(
song
);
const
auto
_mtime
=
mpd_song_get_last_modified
(
song
);
mtime
=
_mtime
>
0
mtime
=
_mtime
>
0
...
...
This diff is collapsed.
Click to expand it.
src/db/plugins/simple/Song.cxx
View file @
b9ff6383
...
@@ -98,12 +98,11 @@ Song::GetURI() const noexcept
...
@@ -98,12 +98,11 @@ Song::GetURI() const noexcept
LightSong
LightSong
Song
::
Export
()
const
noexcept
Song
::
Export
()
const
noexcept
{
{
LightSong
dest
;
LightSong
dest
(
tag
)
;
dest
.
directory
=
parent
->
IsRoot
()
dest
.
directory
=
parent
->
IsRoot
()
?
nullptr
:
parent
->
GetPath
();
?
nullptr
:
parent
->
GetPath
();
dest
.
uri
=
uri
;
dest
.
uri
=
uri
;
dest
.
real_uri
=
nullptr
;
dest
.
real_uri
=
nullptr
;
dest
.
tag
=
&
tag
;
dest
.
mtime
=
mtime
;
dest
.
mtime
=
mtime
;
dest
.
start_time
=
start_time
;
dest
.
start_time
=
start_time
;
dest
.
end_time
=
end_time
;
dest
.
end_time
=
end_time
;
...
...
This diff is collapsed.
Click to expand it.
src/db/plugins/upnp/UpnpDatabasePlugin.cxx
View file @
b9ff6383
...
@@ -55,13 +55,13 @@ class UpnpSong : public LightSong {
...
@@ -55,13 +55,13 @@ class UpnpSong : public LightSong {
public
:
public
:
UpnpSong
(
UPnPDirObject
&&
object
,
std
::
string
&&
_uri
)
UpnpSong
(
UPnPDirObject
&&
object
,
std
::
string
&&
_uri
)
:
uri2
(
std
::
move
(
_uri
)),
:
LightSong
(
tag2
),
uri2
(
std
::
move
(
_uri
)),
real_uri2
(
std
::
move
(
object
.
url
)),
real_uri2
(
std
::
move
(
object
.
url
)),
tag2
(
std
::
move
(
object
.
tag
))
{
tag2
(
std
::
move
(
object
.
tag
))
{
directory
=
nullptr
;
directory
=
nullptr
;
uri
=
uri2
.
c_str
();
uri
=
uri2
.
c_str
();
real_uri
=
real_uri2
.
c_str
();
real_uri
=
real_uri2
.
c_str
();
tag
=
&
tag2
;
mtime
=
std
::
chrono
::
system_clock
::
time_point
::
min
();
mtime
=
std
::
chrono
::
system_clock
::
time_point
::
min
();
start_time
=
end_time
=
SongTime
::
zero
();
start_time
=
end_time
=
SongTime
::
zero
();
}
}
...
@@ -321,11 +321,10 @@ visitSong(const UPnPDirObject &meta, const char *path,
...
@@ -321,11 +321,10 @@ visitSong(const UPnPDirObject &meta, const char *path,
if
(
!
visit_song
)
if
(
!
visit_song
)
return
;
return
;
LightSong
song
;
LightSong
song
(
meta
.
tag
)
;
song
.
directory
=
nullptr
;
song
.
directory
=
nullptr
;
song
.
uri
=
path
;
song
.
uri
=
path
;
song
.
real_uri
=
meta
.
url
.
c_str
();
song
.
real_uri
=
meta
.
url
.
c_str
();
song
.
tag
=
&
meta
.
tag
;
song
.
mtime
=
std
::
chrono
::
system_clock
::
time_point
::
min
();
song
.
mtime
=
std
::
chrono
::
system_clock
::
time_point
::
min
();
song
.
start_time
=
song
.
end_time
=
SongTime
::
zero
();
song
.
start_time
=
song
.
end_time
=
SongTime
::
zero
();
...
...
This diff is collapsed.
Click to expand it.
src/queue/PlaylistUpdate.cxx
View file @
b9ff6383
...
@@ -50,7 +50,7 @@ UpdatePlaylistSong(const Database &db, DetachedSong &song)
...
@@ -50,7 +50,7 @@ UpdatePlaylistSong(const Database &db, DetachedSong &song)
}
}
song
.
SetLastModified
(
original
->
mtime
);
song
.
SetLastModified
(
original
->
mtime
);
song
.
SetTag
(
*
original
->
tag
);
song
.
SetTag
(
original
->
tag
);
db
.
ReturnSong
(
original
);
db
.
ReturnSong
(
original
);
return
true
;
return
true
;
...
...
This diff is collapsed.
Click to expand it.
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