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
f298fcf3
Commit
f298fcf3
authored
Mar 01, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output_init: return GError on error
Do error handling with GError instead of aborting with g_error().
parent
cb942eeb
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
32 deletions
+28
-32
output_all.c
src/output_all.c
+3
-12
output_control.h
src/output_control.h
+10
-1
output_init.c
src/output_init.c
+15
-19
No files found.
src/output_all.c
View file @
f298fcf3
...
...
@@ -77,6 +77,7 @@ audio_output_all_init(void)
{
const
struct
config_param
*
param
=
NULL
;
unsigned
int
i
;
GError
*
error
=
NULL
;
notify_init
(
&
audio_output_client_notify
);
...
...
@@ -93,18 +94,8 @@ audio_output_all_init(void)
/* only allow param to be NULL if there just one audioOutput */
assert
(
param
||
(
num_audio_outputs
==
1
));
if
(
!
audio_output_init
(
output
,
param
))
{
if
(
param
)
{
g_error
(
"problems configuring output device "
"defined at line %i
\n
"
,
param
->
line
);
}
else
{
g_error
(
"No audio_output specified and unable to "
"detect a default audio output device
\n
"
);
}
}
if
(
!
audio_output_init
(
output
,
param
,
&
error
))
g_error
(
"line %i: %s"
,
param
->
line
,
error
->
message
);
/* require output names to be unique: */
for
(
j
=
0
;
j
<
i
;
j
++
)
{
...
...
src/output_control.h
View file @
f298fcf3
...
...
@@ -19,6 +19,8 @@
#ifndef MPD_OUTPUT_CONTROL_H
#define MPD_OUTPUT_CONTROL_H
#include <glib.h>
#include <stddef.h>
#include <stdbool.h>
...
...
@@ -27,8 +29,15 @@ struct audio_format;
struct
tag
;
struct
config_param
;
static
inline
GQuark
audio_output_quark
(
void
)
{
return
g_quark_from_static_string
(
"audio_output"
);
}
bool
audio_output_init
(
struct
audio_output
*
ao
,
const
struct
config_param
*
param
);
audio_output_init
(
struct
audio_output
*
ao
,
const
struct
config_param
*
param
,
GError
**
error
);
bool
audio_output_open
(
struct
audio_output
*
ao
,
...
...
src/output_init.c
View file @
f298fcf3
...
...
@@ -42,7 +42,7 @@
}
static
const
struct
audio_output_plugin
*
audio_output_detect
(
void
)
audio_output_detect
(
GError
**
error
)
{
const
struct
audio_output_plugin
*
plugin
;
unsigned
i
;
...
...
@@ -59,17 +59,19 @@ audio_output_detect(void)
return
plugin
;
}
g_set_error
(
error
,
audio_output_quark
(),
0
,
"Unable to detect an audio device"
);
return
NULL
;
}
bool
audio_output_init
(
struct
audio_output
*
ao
,
const
struct
config_param
*
param
)
audio_output_init
(
struct
audio_output
*
ao
,
const
struct
config_param
*
param
,
GError
**
error
)
{
const
char
*
name
=
NULL
;
char
*
format
=
NULL
;
struct
block_param
*
bp
=
NULL
;
const
struct
audio_output_plugin
*
plugin
=
NULL
;
GError
*
error
=
NULL
;
if
(
param
)
{
const
char
*
type
=
NULL
;
...
...
@@ -80,18 +82,18 @@ audio_output_init(struct audio_output *ao, const struct config_param *param)
plugin
=
audio_output_plugin_get
(
type
);
if
(
plugin
==
NULL
)
{
g_error
(
"couldn't find audio output plugin for type "
"
\"
%s
\"
at line %i
\n
"
,
type
,
param
->
line
);
g_set_error
(
error
,
audio_output_quark
(),
0
,
"No such audio output plugin: %s"
,
type
);
return
false
;
}
}
else
{
g_warning
(
"No
\"
%s
\"
defined in config file
\n
"
,
CONF_AUDIO_OUTPUT
);
plugin
=
audio_output_detect
();
if
(
plugin
==
NULL
)
{
g_warning
(
"Unable to detect an audio device"
);
plugin
=
audio_output_detect
(
error
);
if
(
plugin
==
NULL
)
return
false
;
}
g_message
(
"Successfully detected a %s audio device"
,
plugin
->
name
);
...
...
@@ -111,10 +113,9 @@ audio_output_init(struct audio_output *ao, const struct config_param *param)
bool
ret
;
ret
=
audio_format_parse
(
&
ao
->
config_audio_format
,
format
,
&
error
);
error
);
if
(
!
ret
)
g_error
(
"error parsing format at line %i: %s"
,
bp
->
line
,
error
->
message
);
return
false
;
}
else
audio_format_clear
(
&
ao
->
config_audio_format
);
...
...
@@ -124,14 +125,9 @@ audio_output_init(struct audio_output *ao, const struct config_param *param)
ao
->
data
=
ao_plugin_init
(
plugin
,
format
?
&
ao
->
config_audio_format
:
NULL
,
param
,
&
error
);
if
(
ao
->
data
==
NULL
)
{
g_warning
(
"Failed to initialize
\"
%s
\"
[%s]: %s"
,
ao
->
name
,
ao
->
plugin
->
name
,
error
->
message
);
g_error_free
(
error
);
param
,
error
);
if
(
ao
->
data
==
NULL
)
return
false
;
}
return
true
;
}
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