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
9a715267
Commit
9a715267
authored
Oct 02, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/shout: move code to my_shout_configure()
Eliminate the evil goto.
parent
eafa432c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
31 deletions
+40
-31
shout_output_plugin.c
src/output/shout_output_plugin.c
+40
-31
No files found.
src/output/shout_output_plugin.c
View file @
9a715267
...
...
@@ -105,15 +105,10 @@ static void free_shout_data(struct shout_data *sd)
} \
}
static
struct
audio_output
*
my_shout_
init_driver
(
const
struct
config_param
*
param
,
GError
**
error
)
static
bool
my_shout_
configure
(
struct
shout_data
*
sd
,
const
struct
config_param
*
param
,
GError
**
error
)
{
struct
shout_data
*
sd
=
new_shout_data
();
if
(
!
ao_base_init
(
&
sd
->
base
,
&
shout_output_plugin
,
param
,
error
))
{
free_shout_data
(
sd
);
return
NULL
;
}
const
struct
audio_format
*
audio_format
=
&
sd
->
base
.
config_audio_format
;
...
...
@@ -125,11 +120,6 @@ my_shout_init_driver(const struct config_param *param,
return
NULL
;
}
if
(
shout_init_count
==
0
)
shout_init
();
shout_init_count
++
;
const
struct
block_param
*
block_param
;
check_block_param
(
"host"
);
char
*
host
=
block_param
->
value
;
...
...
@@ -141,7 +131,7 @@ my_shout_init_driver(const struct config_param *param,
if
(
port
==
0
)
{
g_set_error
(
error
,
shout_output_quark
(),
0
,
"shout port must be configured"
);
goto
failur
e
;
return
fals
e
;
}
check_block_param
(
"password"
);
...
...
@@ -164,21 +154,21 @@ my_shout_init_driver(const struct config_param *param,
"shout quality
\"
%s
\"
is not a number in the "
"range -1 to 10, line %i"
,
value
,
param
->
line
);
goto
failur
e
;
return
fals
e
;
}
if
(
config_get_block_string
(
param
,
"bitrate"
,
NULL
)
!=
NULL
)
{
g_set_error
(
error
,
shout_output_quark
(),
0
,
"quality and bitrate are "
"both defined"
);
goto
failur
e
;
return
fals
e
;
}
}
else
{
value
=
config_get_block_string
(
param
,
"bitrate"
,
NULL
);
if
(
value
==
NULL
)
{
g_set_error
(
error
,
shout_output_quark
(),
0
,
"neither bitrate nor quality defined"
);
goto
failur
e
;
return
fals
e
;
}
char
*
test
;
...
...
@@ -187,7 +177,7 @@ my_shout_init_driver(const struct config_param *param,
if
(
*
test
!=
'\0'
||
sd
->
bitrate
<=
0
)
{
g_set_error
(
error
,
shout_output_quark
(),
0
,
"bitrate must be a positive integer"
);
goto
failur
e
;
return
fals
e
;
}
}
...
...
@@ -199,12 +189,12 @@ my_shout_init_driver(const struct config_param *param,
g_set_error
(
error
,
shout_output_quark
(),
0
,
"couldn't find shout encoder plugin
\"
%s
\"
"
,
encoding
);
goto
failur
e
;
return
fals
e
;
}
sd
->
encoder
=
encoder_init
(
encoder_plugin
,
param
,
error
);
if
(
sd
->
encoder
==
NULL
)
goto
failur
e
;
return
fals
e
;
unsigned
shout_format
;
if
(
strcmp
(
encoding
,
"mp3"
)
==
0
||
strcmp
(
encoding
,
"lame"
)
==
0
)
...
...
@@ -220,7 +210,7 @@ my_shout_init_driver(const struct config_param *param,
g_set_error
(
error
,
shout_output_quark
(),
0
,
"you cannot stream
\"
%s
\"
to shoutcast, use mp3"
,
encoding
);
goto
failur
e
;
return
fals
e
;
}
else
if
(
0
==
strcmp
(
value
,
"shoutcast"
))
protocol
=
SHOUT_PROTOCOL_ICY
;
else
if
(
0
==
strcmp
(
value
,
"icecast1"
))
...
...
@@ -232,7 +222,7 @@ my_shout_init_driver(const struct config_param *param,
"shout protocol
\"
%s
\"
is not
\"
shoutcast
\"
or "
"
\"
icecast1
\"
or
\"
icecast2
\"
"
,
value
);
goto
failur
e
;
return
fals
e
;
}
}
else
{
protocol
=
SHOUT_PROTOCOL_HTTP
;
...
...
@@ -251,7 +241,7 @@ my_shout_init_driver(const struct config_param *param,
shout_set_agent
(
sd
->
shout_conn
,
"MPD"
)
!=
SHOUTERR_SUCCESS
)
{
g_set_error
(
error
,
shout_output_quark
(),
0
,
"%s"
,
shout_get_error
(
sd
->
shout_conn
));
goto
failur
e
;
return
fals
e
;
}
/* optional paramters */
...
...
@@ -262,21 +252,21 @@ my_shout_init_driver(const struct config_param *param,
if
(
value
!=
NULL
&&
shout_set_genre
(
sd
->
shout_conn
,
value
))
{
g_set_error
(
error
,
shout_output_quark
(),
0
,
"%s"
,
shout_get_error
(
sd
->
shout_conn
));
goto
failur
e
;
return
fals
e
;
}
value
=
config_get_block_string
(
param
,
"description"
,
NULL
);
if
(
value
!=
NULL
&&
shout_set_description
(
sd
->
shout_conn
,
value
))
{
g_set_error
(
error
,
shout_output_quark
(),
0
,
"%s"
,
shout_get_error
(
sd
->
shout_conn
));
goto
failur
e
;
return
fals
e
;
}
value
=
config_get_block_string
(
param
,
"url"
,
NULL
);
if
(
value
!=
NULL
&&
shout_set_url
(
sd
->
shout_conn
,
value
))
{
g_set_error
(
error
,
shout_output_quark
(),
0
,
"%s"
,
shout_get_error
(
sd
->
shout_conn
));
goto
failur
e
;
return
fals
e
;
}
{
...
...
@@ -301,12 +291,31 @@ my_shout_init_driver(const struct config_param *param,
}
}
return
&
sd
->
base
;
return
true
;
}
failure:
ao_base_finish
(
&
sd
->
base
);
free_shout_data
(
sd
);
return
NULL
;
static
struct
audio_output
*
my_shout_init_driver
(
const
struct
config_param
*
param
,
GError
**
error
)
{
struct
shout_data
*
sd
=
new_shout_data
();
if
(
!
ao_base_init
(
&
sd
->
base
,
&
shout_output_plugin
,
param
,
error
))
{
free_shout_data
(
sd
);
return
NULL
;
}
if
(
!
my_shout_configure
(
sd
,
param
,
error
))
{
ao_base_finish
(
&
sd
->
base
);
free_shout_data
(
sd
);
return
NULL
;
}
if
(
shout_init_count
==
0
)
shout_init
();
shout_init_count
++
;
return
&
sd
->
base
;
}
static
bool
...
...
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