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