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
be8ceae6
Commit
be8ceae6
authored
Oct 17, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Song: GetURI() returns std::string
parent
67ae033d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
62 additions
and
86 deletions
+62
-86
DecoderThread.cxx
src/DecoderThread.cxx
+5
-9
PlayerThread.cxx
src/PlayerThread.cxx
+6
-7
Playlist.cxx
src/Playlist.cxx
+10
-11
PlaylistSave.cxx
src/PlaylistSave.cxx
+2
-3
QueueSave.cxx
src/QueueSave.cxx
+2
-4
Song.cxx
src/Song.cxx
+17
-14
Song.hxx
src/Song.hxx
+4
-5
SongFilter.cxx
src/SongFilter.cxx
+2
-3
SongSticker.cxx
src/SongSticker.cxx
+10
-25
UpdateRemove.cxx
src/UpdateRemove.cxx
+4
-5
No files found.
src/DecoderThread.cxx
View file @
be8ceae6
...
...
@@ -422,16 +422,13 @@ decoder_run(struct decoder_control *dc)
dc
->
ClearError
();
const
Song
*
song
=
dc
->
song
;
char
*
uri
;
assert
(
song
!=
NULL
);
if
(
song
->
IsFile
())
uri
=
g_strdup
(
map_song_fs
(
song
).
c_str
());
else
uri
=
song
->
GetURI
();
const
std
::
string
uri
=
song
->
IsFile
()
?
std
::
string
(
map_song_fs
(
song
).
c_str
())
:
song
->
GetURI
();
if
(
uri
==
NULL
)
{
if
(
uri
.
empty
()
)
{
dc
->
state
=
DecoderState
::
ERROR
;
dc
->
error
.
Set
(
decoder_domain
,
"Failed to map song"
);
...
...
@@ -439,8 +436,7 @@ decoder_run(struct decoder_control *dc)
return
;
}
decoder_run_song
(
dc
,
song
,
uri
);
g_free
(
uri
);
decoder_run_song
(
dc
,
song
,
uri
.
c_str
());
}
...
...
src/PlayerThread.cxx
View file @
be8ceae6
...
...
@@ -461,12 +461,10 @@ Player::CheckDecoderStartup()
decoder_starting
=
false
;
if
(
!
paused
&&
!
OpenOutput
())
{
c
har
*
uri
=
dc
.
song
->
GetURI
();
c
onst
auto
uri
=
dc
.
song
->
GetURI
();
FormatError
(
player_domain
,
"problems opening audio device "
"while playing
\"
%s
\"
"
,
uri
);
g_free
(
uri
);
"while playing
\"
%s
\"
"
,
uri
.
c_str
());
return
true
;
}
...
...
@@ -878,9 +876,10 @@ Player::SongBorder()
{
xfade_state
=
CrossFadeState
::
UNKNOWN
;
char
*
uri
=
song
->
GetURI
();
FormatInfo
(
player_domain
,
"played
\"
%s
\"
"
,
uri
);
g_free
(
uri
);
{
const
auto
uri
=
song
->
GetURI
();
FormatInfo
(
player_domain
,
"played
\"
%s
\"
"
,
uri
.
c_str
());
}
ReplacePipe
(
dc
.
pipe
);
...
...
src/Playlist.cxx
View file @
be8ceae6
...
...
@@ -25,8 +25,6 @@
#include "Idle.hxx"
#include "Log.hxx"
#include <glib.h>
#include <assert.h>
void
...
...
@@ -55,18 +53,17 @@ static void
playlist_queue_song_order
(
struct
playlist
*
playlist
,
struct
player_control
*
pc
,
unsigned
order
)
{
char
*
uri
;
assert
(
playlist
->
queue
.
IsValidOrder
(
order
));
playlist
->
queued
=
order
;
Song
*
song
=
playlist
->
queue
.
GetOrder
(
order
)
->
DupDetached
();
uri
=
song
->
GetURI
();
FormatDebug
(
playlist_domain
,
"queue song %i:
\"
%s
\"
"
,
playlist
->
queued
,
uri
);
g_free
(
uri
);
{
const
auto
uri
=
song
->
GetURI
();
FormatDebug
(
playlist_domain
,
"queue song %i:
\"
%s
\"
"
,
playlist
->
queued
,
uri
.
c_str
());
}
pc
->
EnqueueSong
(
song
);
}
...
...
@@ -155,9 +152,11 @@ playlist::PlayOrder(player_control &pc, int order)
Song
*
song
=
queue
.
GetOrder
(
order
)
->
DupDetached
();
char
*
uri
=
song
->
GetURI
();
FormatDebug
(
playlist_domain
,
"play %i:
\"
%s
\"
"
,
order
,
uri
);
g_free
(
uri
);
{
const
auto
uri
=
song
->
GetURI
();
FormatDebug
(
playlist_domain
,
"play %i:
\"
%s
\"
"
,
order
,
uri
.
c_str
());
}
pc
.
Play
(
song
);
current
=
order
;
...
...
src/PlaylistSave.cxx
View file @
be8ceae6
...
...
@@ -43,9 +43,8 @@ playlist_print_song(FILE *file, const Song *song)
if
(
!
path
.
IsNull
())
fprintf
(
file
,
"%s
\n
"
,
path
.
c_str
());
}
else
{
char
*
uri
=
song
->
GetURI
();
const
Path
uri_fs
=
Path
::
FromUTF8
(
uri
);
g_free
(
uri
);
const
auto
uri_utf8
=
song
->
GetURI
();
const
Path
uri_fs
=
Path
::
FromUTF8
(
uri_utf8
.
c_str
());
if
(
!
uri_fs
.
IsNull
())
fprintf
(
file
,
"%s
\n
"
,
uri_fs
.
c_str
());
...
...
src/QueueSave.cxx
View file @
be8ceae6
...
...
@@ -40,10 +40,8 @@
static
void
queue_save_database_song
(
FILE
*
fp
,
int
idx
,
const
Song
*
song
)
{
char
*
uri
=
song
->
GetURI
();
fprintf
(
fp
,
"%i:%s
\n
"
,
idx
,
uri
);
g_free
(
uri
);
const
auto
uri
=
song
->
GetURI
();
fprintf
(
fp
,
"%i:%s
\n
"
,
idx
,
uri
.
c_str
());
}
static
void
...
...
src/Song.cxx
View file @
be8ceae6
...
...
@@ -89,9 +89,8 @@ Song::DupDetached() const
{
Song
*
song
;
if
(
IsInDatabase
())
{
char
*
new_uri
=
GetURI
();
song
=
NewDetached
(
new_uri
);
g_free
(
new_uri
);
const
auto
new_uri
=
GetURI
();
song
=
NewDetached
(
new_uri
.
c_str
());
}
else
song
=
song_alloc
(
uri
,
nullptr
);
...
...
@@ -138,28 +137,32 @@ song_equals(const Song *a, const Song *b)
(
a
->
parent
==
&
detached_root
||
b
->
parent
==
&
detached_root
))
{
/* must compare the full URI if one of the objects is
"detached" */
char
*
au
=
a
->
GetURI
();
char
*
bu
=
b
->
GetURI
();
const
bool
result
=
strcmp
(
au
,
bu
)
==
0
;
g_free
(
bu
);
g_free
(
au
);
return
result
;
const
auto
au
=
a
->
GetURI
();
const
auto
bu
=
b
->
GetURI
();
return
au
==
bu
;
}
return
directory_is_same
(
a
->
parent
,
b
->
parent
)
&&
strcmp
(
a
->
uri
,
b
->
uri
)
==
0
;
}
char
*
std
::
string
Song
::
GetURI
()
const
{
assert
(
*
uri
);
if
(
!
IsInDatabase
()
||
parent
->
IsRoot
())
return
g_strdup
(
uri
);
else
return
g_strconcat
(
parent
->
GetPath
(),
"/"
,
uri
,
nullptr
);
return
std
::
string
(
uri
);
else
{
const
char
*
path
=
parent
->
GetPath
();
std
::
string
result
;
result
.
reserve
(
strlen
(
path
)
+
1
+
strlen
(
uri
));
result
.
assign
(
path
);
result
.
push_back
(
'/'
);
result
.
append
(
uri
);
return
result
;
}
}
double
...
...
src/Song.hxx
View file @
be8ceae6
...
...
@@ -23,6 +23,8 @@
#include "util/list.h"
#include "Compiler.h"
#include <string>
#include <assert.h>
#include <sys/time.h>
...
...
@@ -126,12 +128,9 @@ struct Song {
/**
* Returns the URI of the song in UTF-8 encoding, including its
* location within the music directory.
*
* The return value is allocated on the heap, and must be freed by the
* caller.
*/
gcc_
malloc
char
*
GetURI
()
const
;
gcc_
pure
std
::
string
GetURI
()
const
;
gcc_pure
double
GetDuration
()
const
;
...
...
src/SongFilter.cxx
View file @
be8ceae6
...
...
@@ -123,9 +123,8 @@ bool
SongFilter
::
Item
::
Match
(
const
Song
&
song
)
const
{
if
(
tag
==
LOCATE_TAG_FILE_TYPE
||
tag
==
LOCATE_TAG_ANY_TYPE
)
{
char
*
uri
=
song
.
GetURI
();
const
bool
result
=
StringMatch
(
uri
);
g_free
(
uri
);
const
auto
uri
=
song
.
GetURI
();
const
bool
result
=
StringMatch
(
uri
.
c_str
());
if
(
result
||
tag
==
LOCATE_TAG_FILE_TYPE
)
return
result
;
...
...
src/SongSticker.cxx
View file @
be8ceae6
...
...
@@ -34,11 +34,8 @@ sticker_song_get_value(const Song *song, const char *name)
assert
(
song
!=
NULL
);
assert
(
song
->
IsInDatabase
());
char
*
uri
=
song
->
GetURI
();
char
*
value
=
sticker_load_value
(
"song"
,
uri
,
name
);
g_free
(
uri
);
return
value
;
const
auto
uri
=
song
->
GetURI
();
return
sticker_load_value
(
"song"
,
uri
.
c_str
(),
name
);
}
bool
...
...
@@ -48,11 +45,8 @@ sticker_song_set_value(const Song *song,
assert
(
song
!=
NULL
);
assert
(
song
->
IsInDatabase
());
char
*
uri
=
song
->
GetURI
();
bool
ret
=
sticker_store_value
(
"song"
,
uri
,
name
,
value
);
g_free
(
uri
);
return
ret
;
const
auto
uri
=
song
->
GetURI
();
return
sticker_store_value
(
"song"
,
uri
.
c_str
(),
name
,
value
);
}
bool
...
...
@@ -61,11 +55,8 @@ sticker_song_delete(const Song *song)
assert
(
song
!=
NULL
);
assert
(
song
->
IsInDatabase
());
char
*
uri
=
song
->
GetURI
();
bool
ret
=
sticker_delete
(
"song"
,
uri
);
g_free
(
uri
);
return
ret
;
const
auto
uri
=
song
->
GetURI
();
return
sticker_delete
(
"song"
,
uri
.
c_str
());
}
bool
...
...
@@ -74,11 +65,8 @@ sticker_song_delete_value(const Song *song, const char *name)
assert
(
song
!=
NULL
);
assert
(
song
->
IsInDatabase
());
char
*
uri
=
song
->
GetURI
();
bool
success
=
sticker_delete_value
(
"song"
,
uri
,
name
);
g_free
(
uri
);
return
success
;
const
auto
uri
=
song
->
GetURI
();
return
sticker_delete_value
(
"song"
,
uri
.
c_str
(),
name
);
}
struct
sticker
*
...
...
@@ -87,11 +75,8 @@ sticker_song_get(const Song *song)
assert
(
song
!=
NULL
);
assert
(
song
->
IsInDatabase
());
char
*
uri
=
song
->
GetURI
();
struct
sticker
*
sticker
=
sticker_load
(
"song"
,
uri
);
g_free
(
uri
);
return
sticker
;
const
auto
uri
=
song
->
GetURI
();
return
sticker_load
(
"song"
,
uri
.
c_str
());
}
struct
sticker_song_find_data
{
...
...
src/UpdateRemove.cxx
View file @
be8ceae6
...
...
@@ -50,13 +50,12 @@ static Cond remove_cond;
static
void
song_remove_event
(
void
)
{
char
*
uri
;
assert
(
removed_song
!=
NULL
);
uri
=
removed_song
->
GetURI
();
FormatInfo
(
update_domain
,
"removing %s"
,
uri
);
g_free
(
uri
);
{
const
auto
uri
=
removed_song
->
GetURI
();
FormatInfo
(
update_domain
,
"removing %s"
,
uri
.
c_str
());
}
#ifdef ENABLE_SQLITE
/* if the song has a sticker, remove 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