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
65f2386b
Commit
65f2386b
authored
Jan 18, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: added config_get_block_unsigned()
Eliminate some more getBlockParam() invocations.
parent
a531a1e6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
39 deletions
+33
-39
conf.c
src/conf.c
+22
-0
conf.h
src/conf.h
+4
-0
alsa_plugin.c
src/output/alsa_plugin.c
+2
-6
ao_plugin.c
src/output/ao_plugin.c
+1
-10
jack_plugin.c
src/output/jack_plugin.c
+2
-15
shout_plugin.c
src/output/shout_plugin.c
+2
-8
No files found.
src/conf.c
View file @
65f2386b
...
...
@@ -25,6 +25,7 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define MAX_STRING_SIZE MPD_PATH_MAX+80
...
...
@@ -457,6 +458,27 @@ config_get_block_string(struct config_param *param, const char *name,
return
bp
->
value
;
}
unsigned
config_get_block_unsigned
(
struct
config_param
*
param
,
const
char
*
name
,
unsigned
default_value
)
{
struct
block_param
*
bp
=
getBlockParam
(
param
,
name
);
long
value
;
char
*
endptr
;
if
(
bp
==
NULL
)
return
default_value
;
value
=
strtol
(
bp
->
value
,
&
endptr
,
0
);
if
(
*
endptr
!=
0
)
g_error
(
"Not a valid number in line %i"
,
bp
->
line
);
if
(
value
<
0
)
g_error
(
"Not a positive number in line %i"
,
bp
->
line
);
return
(
unsigned
)
value
;
}
bool
config_get_block_bool
(
struct
config_param
*
param
,
const
char
*
name
,
bool
default_value
)
...
...
src/conf.h
View file @
65f2386b
...
...
@@ -125,6 +125,10 @@ config_dup_block_string(struct config_param *param, const char *name,
return
g_strdup
(
config_get_block_string
(
param
,
name
,
default_value
));
}
unsigned
config_get_block_unsigned
(
struct
config_param
*
param
,
const
char
*
name
,
unsigned
default_value
);
bool
config_get_block_bool
(
struct
config_param
*
param
,
const
char
*
name
,
bool
default_value
);
...
...
src/output/alsa_plugin.c
View file @
65f2386b
...
...
@@ -90,16 +90,12 @@ static void freeAlsaData(AlsaData * ad)
static
void
alsa_configure
(
AlsaData
*
ad
,
struct
config_param
*
param
)
{
struct
block_param
*
bp
;
ad
->
device
=
config_dup_block_string
(
param
,
"device"
,
NULL
);
ad
->
useMmap
=
config_get_block_bool
(
param
,
"use_mmap"
,
false
);
if
((
bp
=
getBlockParam
(
param
,
"buffer_time"
)))
ad
->
buffer_time
=
atoi
(
bp
->
value
);
if
((
bp
=
getBlockParam
(
param
,
"period_time"
)))
ad
->
period_time
=
atoi
(
bp
->
value
);
ad
->
buffer_time
=
config_get_block_unsigned
(
param
,
"buffer_time"
,
0
);
ad
->
period_time
=
config_get_block_unsigned
(
param
,
"period_time"
,
0
);
#ifdef SND_PCM_NO_AUTO_RESAMPLE
if
(
!
config_get_block_bool
(
param
,
"auto_resample"
,
true
))
...
...
src/output/ao_plugin.c
View file @
65f2386b
...
...
@@ -80,19 +80,10 @@ audioOutputAo_initDriver(struct audio_output *ao,
struct
config_param
*
param
)
{
ao_info
*
ai
;
char
*
test
;
AoData
*
ad
=
newAoData
();
struct
block_param
*
blockParam
;
const
char
*
value
;
if
((
blockParam
=
getBlockParam
(
param
,
"write_size"
)))
{
ad
->
writeSize
=
strtol
(
blockParam
->
value
,
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
g_error
(
"
\"
%s
\"
is not a valid write size at line %i
\n
"
,
blockParam
->
value
,
blockParam
->
line
);
}
}
else
ad
->
writeSize
=
1024
;
ad
->
writeSize
=
config_get_block_unsigned
(
param
,
"write_size"
,
1024
);
if
(
driverInitCount
==
0
)
{
ao_initialize
();
...
...
src/output/jack_plugin.c
View file @
65f2386b
...
...
@@ -187,9 +187,6 @@ mpd_jack_init(struct audio_output *ao,
{
struct
jack_data
*
jd
;
const
char
*
value
;
struct
block_param
*
bp
;
char
*
endptr
;
int
val
;
jd
=
mpd_jack_new
();
jd
->
ao
=
ao
;
...
...
@@ -212,18 +209,8 @@ mpd_jack_init(struct audio_output *ao,
g_free
(
ports
);
}
if
(
(
bp
=
getBlockParam
(
param
,
"ringbuffer_size"
))
)
{
errno
=
0
;
val
=
strtol
(
bp
->
value
,
&
endptr
,
10
);
if
(
errno
==
0
&&
endptr
!=
bp
->
value
)
{
jd
->
ringbuffer_size
=
val
<
32768
?
32768
:
val
;
g_debug
(
"ringbuffer_size=%d"
,
jd
->
ringbuffer_size
);
}
else
{
g_error
(
"%s is not a number; ringbuf_size=%d"
,
bp
->
value
,
jd
->
ringbuffer_size
);
}
}
jd
->
ringbuffer_size
=
config_get_block_unsigned
(
param
,
"ringbuffer_size"
,
32768
);
return
jd
;
}
...
...
src/output/shout_plugin.c
View file @
65f2386b
...
...
@@ -221,14 +221,8 @@ static void *my_shout_init_driver(struct audio_output *audio_output,
}
/* optional paramters */
block_param
=
getBlockParam
(
param
,
"timeout"
);
if
(
block_param
)
{
sd
->
timeout
=
(
int
)
strtol
(
block_param
->
value
,
&
test
,
10
);
if
(
*
test
!=
'\0'
||
sd
->
timeout
<=
0
)
{
g_error
(
"shout timeout is not a positive integer, "
"line %i
\n
"
,
block_param
->
line
);
}
}
sd
->
timeout
=
config_get_block_unsigned
(
param
,
"timeout"
,
DEFAULT_CONN_TIMEOUT
);
value
=
config_get_block_string
(
param
,
"genre"
,
NULL
);
if
(
value
!=
NULL
&&
shout_set_genre
(
sd
->
shout_conn
,
value
))
{
...
...
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