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
a1cb1d78
Commit
a1cb1d78
authored
Oct 24, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist/SoundCloud: don't use GLib for string allocation
parent
1178f2c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
33 deletions
+31
-33
configure.ac
configure.ac
+0
-2
SoundCloudPlaylistPlugin.cxx
src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
+31
-31
No files found.
configure.ac
View file @
a1cb1d78
...
@@ -454,8 +454,6 @@ AC_ARG_ENABLE(soundcloud,
...
@@ -454,8 +454,6 @@ AC_ARG_ENABLE(soundcloud,
AS_HELP_STRING([--enable-soundcloud],
AS_HELP_STRING([--enable-soundcloud],
[enable support for soundcloud.com]),,
[enable support for soundcloud.com]),,
[enable_soundcloud=auto])
[enable_soundcloud=auto])
MPD_DEPENDS([enable_soundcloud], [enable_glib],
[Cannot use --enable-soundcloud with --disable-glib])
AC_ARG_ENABLE(lame-encoder,
AC_ARG_ENABLE(lame-encoder,
AS_HELP_STRING([--enable-lame-encoder],
AS_HELP_STRING([--enable-lame-encoder],
...
...
src/playlist/plugins/SoundCloudPlaylistPlugin.cxx
View file @
a1cb1d78
...
@@ -25,11 +25,11 @@
...
@@ -25,11 +25,11 @@
#include "input/InputStream.hxx"
#include "input/InputStream.hxx"
#include "tag/TagBuilder.hxx"
#include "tag/TagBuilder.hxx"
#include "util/StringUtil.hxx"
#include "util/StringUtil.hxx"
#include "util/Alloc.hxx"
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
#include "Log.hxx"
#include <glib.h>
#include <yajl/yajl_parse.h>
#include <yajl/yajl_parse.h>
#include <string>
#include <string>
...
@@ -60,7 +60,7 @@ soundcloud_init(const config_param ¶m)
...
@@ -60,7 +60,7 @@ soundcloud_init(const config_param ¶m)
/**
/**
* Construct a full soundcloud resolver URL from the given fragment.
* Construct a full soundcloud resolver URL from the given fragment.
* @param uri uri of a soundcloud page (or just the path)
* @param uri uri of a soundcloud page (or just the path)
* @return Constructed URL. Must be freed with
g_free
.
* @return Constructed URL. Must be freed with
free()
.
*/
*/
static
char
*
static
char
*
soundcloud_resolve
(
const
char
*
uri
)
soundcloud_resolve
(
const
char
*
uri
)
...
@@ -68,18 +68,18 @@ soundcloud_resolve(const char* uri)
...
@@ -68,18 +68,18 @@ soundcloud_resolve(const char* uri)
char
*
u
,
*
ru
;
char
*
u
,
*
ru
;
if
(
StringStartsWith
(
uri
,
"https://"
))
{
if
(
StringStartsWith
(
uri
,
"https://"
))
{
u
=
g_
strdup
(
uri
);
u
=
x
strdup
(
uri
);
}
else
if
(
StringStartsWith
(
uri
,
"soundcloud.com"
))
{
}
else
if
(
StringStartsWith
(
uri
,
"soundcloud.com"
))
{
u
=
g_strconcat
(
"https://"
,
uri
,
nullptr
);
u
=
xstrcatdup
(
"https://"
,
uri
);
}
else
{
}
else
{
/* assume it's just a path on soundcloud.com */
/* assume it's just a path on soundcloud.com */
u
=
g_strconcat
(
"https://soundcloud.com/"
,
uri
,
nullptr
);
u
=
xstrcatdup
(
"https://soundcloud.com/"
,
uri
);
}
}
ru
=
g_strconcat
(
"https://api.soundcloud.com/resolve.json?url="
,
ru
=
xstrcatdup
(
"https://api.soundcloud.com/resolve.json?url="
,
u
,
"&client_id="
,
u
,
"&client_id="
,
soundcloud_config
.
apikey
.
c_str
(),
nullptr
);
soundcloud_config
.
apikey
.
c_str
()
);
g_
free
(
u
);
free
(
u
);
return
ru
;
return
ru
;
}
}
...
@@ -145,12 +145,12 @@ handle_string(void *ctx, const unsigned char* stringval,
...
@@ -145,12 +145,12 @@ handle_string(void *ctx, const unsigned char* stringval,
switch
(
data
->
key
)
{
switch
(
data
->
key
)
{
case
Title
:
case
Title
:
g_
free
(
data
->
title
);
free
(
data
->
title
);
data
->
title
=
g_
strndup
(
s
,
stringlen
);
data
->
title
=
x
strndup
(
s
,
stringlen
);
break
;
break
;
case
Stream_URL
:
case
Stream_URL
:
g_
free
(
data
->
stream_url
);
free
(
data
->
stream_url
);
data
->
stream_url
=
g_
strndup
(
s
,
stringlen
);
data
->
stream_url
=
x
strndup
(
s
,
stringlen
);
data
->
got_url
=
1
;
data
->
got_url
=
1
;
break
;
break
;
default:
default:
...
@@ -211,8 +211,8 @@ handle_end_map(void *ctx)
...
@@ -211,8 +211,8 @@ handle_end_map(void *ctx)
/* got_url == 1, track finished, make it into a song */
/* got_url == 1, track finished, make it into a song */
data
->
got_url
=
0
;
data
->
got_url
=
0
;
char
*
u
=
g_strconcat
(
data
->
stream_url
,
"?client_id="
,
char
*
u
=
xstrcatdup
(
data
->
stream_url
,
"?client_id="
,
soundcloud_config
.
apikey
.
c_str
(),
nullptr
);
soundcloud_config
.
apikey
.
c_str
()
);
TagBuilder
tag
;
TagBuilder
tag
;
tag
.
SetDuration
(
SignedSongTime
::
FromMS
(
data
->
duration
));
tag
.
SetDuration
(
SignedSongTime
::
FromMS
(
data
->
duration
));
...
@@ -220,7 +220,7 @@ handle_end_map(void *ctx)
...
@@ -220,7 +220,7 @@ handle_end_map(void *ctx)
tag
.
AddItem
(
TAG_NAME
,
data
->
title
);
tag
.
AddItem
(
TAG_NAME
,
data
->
title
);
data
->
songs
.
emplace_front
(
u
,
tag
.
Commit
());
data
->
songs
.
emplace_front
(
u
,
tag
.
Commit
());
g_
free
(
u
);
free
(
u
);
return
1
;
return
1
;
}
}
...
@@ -325,24 +325,24 @@ soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond)
...
@@ -325,24 +325,24 @@ soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond)
char
*
u
=
nullptr
;
char
*
u
=
nullptr
;
if
(
memcmp
(
uri
,
"track/"
,
6
)
==
0
)
{
if
(
memcmp
(
uri
,
"track/"
,
6
)
==
0
)
{
const
char
*
rest
=
uri
+
6
;
const
char
*
rest
=
uri
+
6
;
u
=
g_strconcat
(
"https://api.soundcloud.com/tracks/"
,
u
=
xstrcatdup
(
"https://api.soundcloud.com/tracks/"
,
rest
,
".json?client_id="
,
rest
,
".json?client_id="
,
soundcloud_config
.
apikey
.
c_str
(),
nullptr
);
soundcloud_config
.
apikey
.
c_str
()
);
}
else
if
(
memcmp
(
uri
,
"playlist/"
,
9
)
==
0
)
{
}
else
if
(
memcmp
(
uri
,
"playlist/"
,
9
)
==
0
)
{
const
char
*
rest
=
uri
+
9
;
const
char
*
rest
=
uri
+
9
;
u
=
g_strconcat
(
"https://api.soundcloud.com/playlists/"
,
u
=
xstrcatdup
(
"https://api.soundcloud.com/playlists/"
,
rest
,
".json?client_id="
,
rest
,
".json?client_id="
,
soundcloud_config
.
apikey
.
c_str
(),
nullptr
);
soundcloud_config
.
apikey
.
c_str
()
);
}
else
if
(
memcmp
(
uri
,
"user/"
,
5
)
==
0
)
{
}
else
if
(
memcmp
(
uri
,
"user/"
,
5
)
==
0
)
{
const
char
*
rest
=
uri
+
5
;
const
char
*
rest
=
uri
+
5
;
u
=
g_strconcat
(
"https://api.soundcloud.com/users/"
,
u
=
xstrcatdup
(
"https://api.soundcloud.com/users/"
,
rest
,
"/tracks.json?client_id="
,
rest
,
"/tracks.json?client_id="
,
soundcloud_config
.
apikey
.
c_str
(),
nullptr
);
soundcloud_config
.
apikey
.
c_str
()
);
}
else
if
(
memcmp
(
uri
,
"search/"
,
7
)
==
0
)
{
}
else
if
(
memcmp
(
uri
,
"search/"
,
7
)
==
0
)
{
const
char
*
rest
=
uri
+
7
;
const
char
*
rest
=
uri
+
7
;
u
=
g_strconcat
(
"https://api.soundcloud.com/tracks.json?q="
,
u
=
xstrcatdup
(
"https://api.soundcloud.com/tracks.json?q="
,
rest
,
"&client_id="
,
rest
,
"&client_id="
,
soundcloud_config
.
apikey
.
c_str
(),
nullptr
);
soundcloud_config
.
apikey
.
c_str
()
);
}
else
if
(
memcmp
(
uri
,
"url/"
,
4
)
==
0
)
{
}
else
if
(
memcmp
(
uri
,
"url/"
,
4
)
==
0
)
{
const
char
*
rest
=
uri
+
4
;
const
char
*
rest
=
uri
+
4
;
/* Translate to soundcloud resolver call. libcurl will automatically
/* Translate to soundcloud resolver call. libcurl will automatically
...
@@ -368,10 +368,10 @@ soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond)
...
@@ -368,10 +368,10 @@ soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond)
int
ret
=
soundcloud_parse_json
(
u
,
hand
,
mutex
,
cond
);
int
ret
=
soundcloud_parse_json
(
u
,
hand
,
mutex
,
cond
);
g_
free
(
u
);
free
(
u
);
yajl_free
(
hand
);
yajl_free
(
hand
);
g_
free
(
data
.
title
);
free
(
data
.
title
);
g_
free
(
data
.
stream_url
);
free
(
data
.
stream_url
);
if
(
ret
==
-
1
)
if
(
ret
==
-
1
)
return
nullptr
;
return
nullptr
;
...
...
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