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
128a5fa4
Commit
128a5fa4
authored
Oct 08, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player_control: allocate getPlayerErrorStr() result
This lets us eliminate the static fixed-size buffer.
parent
a5960c20
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
21 deletions
+23
-21
command.c
src/command.c
+5
-2
player_control.c
src/player_control.c
+13
-19
player_control.h
src/player_control.h
+5
-0
No files found.
src/command.c
View file @
128a5fa4
...
...
@@ -454,6 +454,7 @@ handle_status(struct client *client,
{
const
char
*
state
=
NULL
;
int
updateJobId
;
char
*
error
;
int
song
;
switch
(
getPlayerState
())
{
...
...
@@ -515,10 +516,12 @@ handle_status(struct client *client,
updateJobId
);
}
if
(
getPlayerError
()
!=
PLAYER_ERROR_NOERROR
)
{
error
=
getPlayerErrorStr
();
if
(
error
!=
NULL
)
{
client_printf
(
client
,
COMMAND_STATUS_ERROR
": %s
\n
"
,
getPlayerErrorStr
());
error
);
g_free
(
error
);
}
song
=
playlist_get_next_song
(
&
g_playlist
);
...
...
src/player_control.c
View file @
128a5fa4
...
...
@@ -167,46 +167,40 @@ pc_errored_song_uri(void)
char
*
getPlayerErrorStr
(
void
)
{
/* static OK here, only one user in main task */
static
char
error
[
MPD_PATH_MAX
+
64
];
/* still too much */
static
const
size_t
errorlen
=
sizeof
(
error
);
char
*
error
;
char
*
uri
;
*
error
=
'\0'
;
/* likely */
switch
(
pc
.
error
)
{
case
PLAYER_ERROR_NOERROR
:
break
;
return
NULL
;
case
PLAYER_ERROR_FILENOTFOUND
:
uri
=
pc_errored_song_uri
();
snprintf
(
error
,
errorlen
,
"file
\"
%s
\"
does not exist or is inaccessible"
,
uri
);
error
=
g_strdup_printf
(
"file
\"
%s
\"
does not exist or is inaccessible"
,
uri
);
g_free
(
uri
);
break
;
return
error
;
case
PLAYER_ERROR_FILE
:
uri
=
pc_errored_song_uri
();
snprintf
(
error
,
errorlen
,
"problems decoding
\"
%s
\"
"
,
uri
);
error
=
g_strdup_printf
(
"problems decoding
\"
%s
\"
"
,
uri
);
g_free
(
uri
);
break
;
return
error
;
case
PLAYER_ERROR_AUDIO
:
strcpy
(
error
,
"problems opening audio device"
);
break
;
return
g_strdup
(
"problems opening audio device"
);
case
PLAYER_ERROR_SYSTEM
:
strcpy
(
error
,
"system error occured"
);
break
;
return
g_strdup
(
"system error occured"
);
case
PLAYER_ERROR_UNKTYPE
:
uri
=
pc_errored_song_uri
();
snprintf
(
error
,
errorlen
,
"file type of
\"
%s
\"
is unknown"
,
uri
);
error
=
g_strdup_printf
(
"file type of
\"
%s
\"
is unknown"
,
uri
);
g_free
(
uri
);
break
;
return
error
;
}
return
*
error
?
error
:
NULL
;
assert
(
false
);
return
NULL
;
}
void
...
...
src/player_control.h
View file @
128a5fa4
...
...
@@ -122,6 +122,11 @@ enum player_state getPlayerState(void);
void
clearPlayerError
(
void
);
/**
* Returns the human-readable message describing the last error during
* playback, NULL if no error occurred. The caller has to free the
* returned string.
*/
char
*
getPlayerErrorStr
(
void
);
enum
player_error
getPlayerError
(
void
);
...
...
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