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
c486c5bf
Commit
c486c5bf
authored
Dec 09, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DespotifyUtils: fix coding style
parent
fc0b6d14
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
22 deletions
+34
-22
DespotifyUtils.cxx
src/lib/despotify/DespotifyUtils.cxx
+23
-16
DespotifyUtils.hxx
src/lib/despotify/DespotifyUtils.hxx
+11
-6
No files found.
src/lib/despotify/DespotifyUtils.cxx
View file @
c486c5bf
...
@@ -47,13 +47,15 @@ callback(struct despotify_session* ds, int sig,
...
@@ -47,13 +47,15 @@ callback(struct despotify_session* ds, int sig,
void
(
*
cb
)(
struct
despotify_session
*
,
int
,
void
*
,
void
*
)
=
registered_callbacks
[
i
];
void
(
*
cb
)(
struct
despotify_session
*
,
int
,
void
*
,
void
*
)
=
registered_callbacks
[
i
];
void
*
cb_data
=
registered_callback_data
[
i
];
void
*
cb_data
=
registered_callback_data
[
i
];
if
(
cb
)
if
(
cb
!=
nullptr
)
cb
(
ds
,
sig
,
data
,
cb_data
);
cb
(
ds
,
sig
,
data
,
cb_data
);
}
}
}
}
bool
mpd_despotify_register_callback
(
void
(
*
cb
)(
struct
despotify_session
*
,
int
,
void
*
,
void
*
),
bool
void
*
cb_data
)
mpd_despotify_register_callback
(
void
(
*
cb
)(
struct
despotify_session
*
,
int
,
void
*
,
void
*
),
void
*
cb_data
)
{
{
for
(
size_t
i
=
0
;
i
<
ARRAY_SIZE
(
registered_callbacks
);
++
i
)
{
for
(
size_t
i
=
0
;
i
<
ARRAY_SIZE
(
registered_callbacks
);
++
i
)
{
if
(
!
registered_callbacks
[
i
])
{
if
(
!
registered_callbacks
[
i
])
{
...
@@ -67,7 +69,9 @@ bool mpd_despotify_register_callback(void (*cb)(struct despotify_session *, int,
...
@@ -67,7 +69,9 @@ bool mpd_despotify_register_callback(void (*cb)(struct despotify_session *, int,
return
false
;
return
false
;
}
}
void
mpd_despotify_unregister_callback
(
void
(
*
cb
)(
struct
despotify_session
*
,
int
,
void
*
,
void
*
))
void
mpd_despotify_unregister_callback
(
void
(
*
cb
)(
struct
despotify_session
*
,
int
,
void
*
,
void
*
))
{
{
for
(
size_t
i
=
0
;
i
<
ARRAY_SIZE
(
registered_callbacks
);
++
i
)
{
for
(
size_t
i
=
0
;
i
<
ARRAY_SIZE
(
registered_callbacks
);
++
i
)
{
if
(
registered_callbacks
[
i
]
==
cb
)
{
if
(
registered_callbacks
[
i
]
==
cb
)
{
...
@@ -79,19 +83,22 @@ void mpd_despotify_unregister_callback(void (*cb)(struct despotify_session *, in
...
@@ -79,19 +83,22 @@ void mpd_despotify_unregister_callback(void (*cb)(struct despotify_session *, in
Tag
Tag
mpd_despotify_tag_from_track
(
const
ds_track
&
track
)
mpd_despotify_tag_from_track
(
const
ds_track
&
track
)
{
{
char
tracknum
[
20
];
char
comment
[
80
];
char
date
[
20
];
if
(
!
track
.
has_meta_data
)
if
(
!
track
.
has_meta_data
)
return
Tag
();
return
Tag
();
TagBuilder
tag
;
TagBuilder
tag
;
char
tracknum
[
20
];
snprintf
(
tracknum
,
sizeof
(
tracknum
),
"%d"
,
track
.
tracknumber
);
snprintf
(
tracknum
,
sizeof
(
tracknum
),
"%d"
,
track
.
tracknumber
);
char
date
[
20
];
snprintf
(
date
,
sizeof
(
date
),
"%d"
,
track
.
year
);
snprintf
(
date
,
sizeof
(
date
),
"%d"
,
track
.
year
);
char
comment
[
80
];
snprintf
(
comment
,
sizeof
(
comment
),
"Bitrate %d Kbps, %sgeo restricted"
,
snprintf
(
comment
,
sizeof
(
comment
),
"Bitrate %d Kbps, %sgeo restricted"
,
track
.
file_bitrate
/
1000
,
track
.
file_bitrate
/
1000
,
track
.
geo_restricted
?
""
:
"not "
);
track
.
geo_restricted
?
""
:
"not "
);
tag
.
AddItem
(
TAG_TITLE
,
track
.
title
);
tag
.
AddItem
(
TAG_TITLE
,
track
.
title
);
tag
.
AddItem
(
TAG_ARTIST
,
track
.
artist
->
name
);
tag
.
AddItem
(
TAG_ARTIST
,
track
.
artist
->
name
);
tag
.
AddItem
(
TAG_TRACK
,
tracknum
);
tag
.
AddItem
(
TAG_TRACK
,
tracknum
);
...
@@ -103,18 +110,16 @@ mpd_despotify_tag_from_track(const ds_track &track)
...
@@ -103,18 +110,16 @@ mpd_despotify_tag_from_track(const ds_track &track)
return
tag
.
Commit
();
return
tag
.
Commit
();
}
}
struct
despotify_session
*
mpd_despotify_get_session
(
void
)
struct
despotify_session
*
mpd_despotify_get_session
()
{
{
const
char
*
user
;
const
char
*
passwd
;
bool
high_bitrate
;
if
(
g_session
)
if
(
g_session
)
return
g_session
;
return
g_session
;
user
=
config_get_string
(
CONF_DESPOTIFY_USER
,
nullptr
);
const
char
*
const
user
=
passwd
=
config_get_string
(
CONF_DESPOTIFY_PASSWORD
,
nullptr
);
config_get_string
(
CONF_DESPOTIFY_USER
,
nullptr
);
high_bitrate
=
config_get_bool
(
CONF_DESPOTIFY_HIGH_BITRATE
,
true
);
const
char
*
const
passwd
=
config_get_string
(
CONF_DESPOTIFY_PASSWORD
,
nullptr
);
if
(
user
==
nullptr
||
passwd
==
nullptr
)
{
if
(
user
==
nullptr
||
passwd
==
nullptr
)
{
LogDebug
(
despotify_domain
,
LogDebug
(
despotify_domain
,
...
@@ -127,6 +132,8 @@ struct despotify_session *mpd_despotify_get_session(void)
...
@@ -127,6 +132,8 @@ struct despotify_session *mpd_despotify_get_session(void)
return
nullptr
;
return
nullptr
;
}
}
const
bool
high_bitrate
=
config_get_bool
(
CONF_DESPOTIFY_HIGH_BITRATE
,
true
);
g_session
=
despotify_init_client
(
callback
,
nullptr
,
g_session
=
despotify_init_client
(
callback
,
nullptr
,
high_bitrate
,
true
);
high_bitrate
,
true
);
if
(
!
g_session
)
{
if
(
!
g_session
)
{
...
...
src/lib/despotify/DespotifyUtils.hxx
View file @
c486c5bf
...
@@ -17,8 +17,8 @@
...
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
*/
#ifndef MPD_DESPOTIFY_
H
#ifndef MPD_DESPOTIFY_
UTILS_HXX
#define MPD_DESPOTIFY_
H
#define MPD_DESPOTIFY_
UTILS_HXX
struct
Tag
;
struct
Tag
;
struct
despotify_session
;
struct
despotify_session
;
...
@@ -35,7 +35,8 @@ extern const class Domain despotify_domain;
...
@@ -35,7 +35,8 @@ extern const class Domain despotify_domain;
* @return a pointer to the despotify session, or nullptr if it can't
* @return a pointer to the despotify session, or nullptr if it can't
* be initialized (e.g., if the configuration isn't supplied)
* be initialized (e.g., if the configuration isn't supplied)
*/
*/
struct
despotify_session
*
mpd_despotify_get_session
(
void
);
struct
despotify_session
*
mpd_despotify_get_session
();
/**
/**
* Create a MPD tags structure from a spotify track
* Create a MPD tags structure from a spotify track
...
@@ -57,15 +58,19 @@ mpd_despotify_tag_from_track(const ds_track &track);
...
@@ -57,15 +58,19 @@ mpd_despotify_tag_from_track(const ds_track &track);
*
*
* @return true if the callback could be registered
* @return true if the callback could be registered
*/
*/
bool
mpd_despotify_register_callback
(
void
(
*
cb
)(
struct
despotify_session
*
,
int
,
void
*
,
void
*
),
bool
void
*
cb_data
);
mpd_despotify_register_callback
(
void
(
*
cb
)(
struct
despotify_session
*
,
int
,
void
*
,
void
*
),
void
*
cb_data
);
/**
/**
* Unregister a despotify callback.
* Unregister a despotify callback.
*
*
* @param cb the callback to unregister.
* @param cb the callback to unregister.
*/
*/
void
mpd_despotify_unregister_callback
(
void
(
*
cb
)(
struct
despotify_session
*
,
int
,
void
*
,
void
*
));
void
mpd_despotify_unregister_callback
(
void
(
*
cb
)(
struct
despotify_session
*
,
int
,
void
*
,
void
*
));
#endif
#endif
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