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
c729f16d
Commit
c729f16d
authored
Feb 18, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
song/DetachedSong: copy the AudioFormat from LightSong
Enables the "Format" row in "playlistinfo" responses.
https://github.com/MusicPlayerDaemon/MPD/issues/1094
parent
81d0c04e
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
37 additions
and
15 deletions
+37
-15
NEWS
NEWS
+1
-0
SongPrint.cxx
src/SongPrint.cxx
+3
-0
SongSave.cxx
src/SongSave.cxx
+3
-6
SongSave.hxx
src/SongSave.hxx
+1
-2
SongUpdate.cxx
src/SongUpdate.cxx
+7
-2
DirectorySave.cxx
src/db/plugins/simple/DirectorySave.cxx
+1
-4
Song.cxx
src/db/plugins/simple/Song.cxx
+1
-0
PlaylistSong.cxx
src/playlist/PlaylistSong.cxx
+3
-0
DetachedSong.cxx
src/song/DetachedSong.cxx
+2
-1
DetachedSong.hxx
src/song/DetachedSong.hxx
+15
-0
No files found.
NEWS
View file @
c729f16d
ver 0.23 (not yet released)
* protocol
- new command "getvol"
- show the audio format in "playlistinfo"
* output
- snapcast: new plugin
...
...
src/SongPrint.cxx
View file @
c729f16d
...
...
@@ -111,6 +111,9 @@ song_print_info(Response &r, const DetachedSong &song, bool base) noexcept
if
(
!
IsNegative
(
song
.
GetLastModified
()))
time_print
(
r
,
"Last-Modified"
,
song
.
GetLastModified
());
if
(
const
auto
&
f
=
song
.
GetAudioFormat
();
f
.
IsDefined
())
r
.
Format
(
"Format: %s
\n
"
,
ToString
(
f
).
c_str
());
tag_print_values
(
r
,
song
.
GetTag
());
const
auto
duration
=
song
.
GetDuration
();
...
...
src/SongSave.cxx
View file @
c729f16d
...
...
@@ -86,8 +86,7 @@ song_save(BufferedOutputStream &os, const DetachedSong &song)
DetachedSong
song_load
(
TextFile
&
file
,
const
char
*
uri
,
std
::
string
*
target_r
,
AudioFormat
*
audio_format_r
)
std
::
string
*
target_r
)
{
DetachedSong
song
(
uri
);
...
...
@@ -113,14 +112,12 @@ song_load(TextFile &file, const char *uri,
if
(
target_r
!=
nullptr
)
*
target_r
=
value
;
}
else
if
(
StringIsEqual
(
line
,
"Format"
))
{
if
(
audio_format_r
!=
nullptr
)
{
try
{
*
audio_format_r
=
ParseAudioFormat
(
value
,
false
);
song
.
SetAudioFormat
(
ParseAudioFormat
(
value
,
false
)
);
}
catch
(...)
{
/* ignore parser errors */
}
}
}
else
if
(
StringIsEqual
(
line
,
"Playlist"
))
{
tag
.
SetHasPlaylist
(
StringIsEqual
(
value
,
"yes"
));
}
else
if
(
StringIsEqual
(
line
,
SONG_MTIME
))
{
...
...
src/SongSave.hxx
View file @
c729f16d
...
...
@@ -44,7 +44,6 @@ song_save(BufferedOutputStream &os, const DetachedSong &song);
*/
DetachedSong
song_load
(
TextFile
&
file
,
const
char
*
uri
,
std
::
string
*
target_r
=
nullptr
,
AudioFormat
*
audio_format_r
=
nullptr
);
std
::
string
*
target_r
=
nullptr
);
#endif
src/SongUpdate.cxx
View file @
c729f16d
...
...
@@ -153,9 +153,10 @@ DetachedSong::LoadFile(Path path)
return
false
;
TagBuilder
tag_builder
;
auto
new_audio_format
=
AudioFormat
::
Undefined
();
try
{
if
(
!
ScanFileTagsWithGeneric
(
path
,
tag_builder
))
if
(
!
ScanFileTagsWithGeneric
(
path
,
tag_builder
,
&
new_audio_format
))
return
false
;
}
catch
(...)
{
// TODO: log or propagate I/O errors?
...
...
@@ -163,6 +164,7 @@ DetachedSong::LoadFile(Path path)
}
mtime
=
fi
.
GetModificationTime
();
audio_format
=
new_audio_format
;
tag_builder
.
Commit
(
tag
);
return
true
;
}
...
...
@@ -177,9 +179,11 @@ DetachedSong::Update()
return
LoadFile
(
path_fs
);
}
else
if
(
IsRemote
())
{
TagBuilder
tag_builder
;
auto
new_audio_format
=
AudioFormat
::
Undefined
();
try
{
if
(
!
tag_stream_scan
(
uri
.
c_str
(),
tag_builder
))
if
(
!
tag_stream_scan
(
uri
.
c_str
(),
tag_builder
,
&
new_audio_format
))
return
false
;
}
catch
(...)
{
// TODO: log or propagate I/O errors?
...
...
@@ -187,6 +191,7 @@ DetachedSong::Update()
}
mtime
=
std
::
chrono
::
system_clock
::
time_point
::
min
();
audio_format
=
new_audio_format
;
tag_builder
.
Commit
(
tag
);
return
true
;
}
else
...
...
src/db/plugins/simple/DirectorySave.cxx
View file @
c729f16d
...
...
@@ -168,15 +168,12 @@ directory_load(TextFile &file, Directory &directory)
throw
FormatRuntimeError
(
"Duplicate song '%s'"
,
name
);
std
::
string
target
;
auto
audio_format
=
AudioFormat
::
Undefined
();
auto
detached_song
=
song_load
(
file
,
name
,
&
target
,
&
audio_format
);
&
target
);
auto
song
=
std
::
make_unique
<
Song
>
(
std
::
move
(
detached_song
),
directory
);
song
->
target
=
std
::
move
(
target
);
song
->
audio_format
=
audio_format
;
directory
.
AddSong
(
std
::
move
(
song
));
}
else
if
((
p
=
StringAfterPrefix
(
line
,
PLAYLIST_META_BEGIN
)))
{
...
...
src/db/plugins/simple/Song.cxx
View file @
c729f16d
...
...
@@ -34,6 +34,7 @@ Song::Song(DetachedSong &&other, Directory &_parent) noexcept
mtime
(
other
.
GetLastModified
()),
start_time
(
other
.
GetStartTime
()),
end_time
(
other
.
GetEndTime
()),
audio_format
(
other
.
GetAudioFormat
()),
filename
(
other
.
GetURI
())
{
}
...
...
src/playlist/PlaylistSong.cxx
View file @
c729f16d
...
...
@@ -47,6 +47,9 @@ merge_song_metadata(DetachedSong &add, const DetachedSong &base) noexcept
if
(
add
.
GetEndTime
().
IsZero
())
{
add
.
SetEndTime
(
base
.
GetEndTime
());
}
if
(
!
add
.
GetAudioFormat
().
IsDefined
())
add
.
SetAudioFormat
(
base
.
GetAudioFormat
());
}
static
bool
...
...
src/song/DetachedSong.cxx
View file @
c729f16d
...
...
@@ -28,7 +28,8 @@ DetachedSong::DetachedSong(const LightSong &other) noexcept
tag
(
other
.
tag
),
mtime
(
other
.
mtime
),
start_time
(
other
.
start_time
),
end_time
(
other
.
end_time
)
{}
end_time
(
other
.
end_time
),
audio_format
(
other
.
audio_format
)
{}
DetachedSong
::
operator
LightSong
()
const
noexcept
{
...
...
src/song/DetachedSong.hxx
View file @
c729f16d
...
...
@@ -21,6 +21,7 @@
#define MPD_DETACHED_SONG_HXX
#include "tag/Tag.hxx"
#include "pcm/AudioFormat.hxx"
#include "Chrono.hxx"
#include "util/Compiler.h"
...
...
@@ -79,6 +80,12 @@ class DetachedSong {
*/
SongTime
end_time
=
SongTime
::
zero
();
/**
* The audio format of the song, if given by the decoder
* plugin. May be undefined if unknown.
*/
AudioFormat
audio_format
=
AudioFormat
::
Undefined
();
public
:
explicit
DetachedSong
(
const
char
*
_uri
)
noexcept
:
uri
(
_uri
)
{}
...
...
@@ -231,6 +238,14 @@ public:
gcc_pure
SignedSongTime
GetDuration
()
const
noexcept
;
const
AudioFormat
&
GetAudioFormat
()
const
noexcept
{
return
audio_format
;
}
void
SetAudioFormat
(
const
AudioFormat
&
src
)
noexcept
{
audio_format
=
src
;
}
/**
* Update the #tag and #mtime.
*
...
...
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