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
f15d879e
Commit
f15d879e
authored
Mar 14, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
volume: use bool instead of int
Return true/false on success/failure, instead of 0/-1. Pass true/false instead of 1/0 for the "rel" boolean parameter.
parent
f31c371f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
15 deletions
+22
-15
command.c
src/command.c
+14
-8
volume.c
src/volume.c
+6
-6
volume.h
src/volume.h
+2
-1
No files found.
src/command.c
View file @
f15d879e
...
...
@@ -1039,33 +1039,39 @@ handle_listall(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
static
enum
command_return
handle_volume
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
char
*
argv
[])
{
int
change
,
ret
;
int
change
;
bool
success
;
if
(
!
check_int
(
client
,
&
change
,
argv
[
1
],
need_integer
))
return
COMMAND_RETURN_ERROR
;
ret
=
volume_level_change
(
change
,
1
);
if
(
ret
==
-
1
)
success
=
volume_level_change
(
change
,
true
);
if
(
!
success
)
{
command_error
(
client
,
ACK_ERROR_SYSTEM
,
"problems setting volume"
);
return
COMMAND_RETURN_ERROR
;
}
return
ret
;
return
COMMAND_RETURN_OK
;
}
static
enum
command_return
handle_setvol
(
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
char
*
argv
[])
{
int
level
,
ret
;
int
level
;
bool
success
;
if
(
!
check_int
(
client
,
&
level
,
argv
[
1
],
need_integer
))
return
COMMAND_RETURN_ERROR
;
ret
=
volume_level_change
(
level
,
0
);
if
(
ret
==
-
1
)
success
=
volume_level_change
(
level
,
0
);
if
(
!
success
)
{
command_error
(
client
,
ACK_ERROR_SYSTEM
,
"problems setting volume"
);
return
COMMAND_RETURN_ERROR
;
}
return
ret
;
return
COMMAND_RETURN_OK
;
}
static
enum
command_return
...
...
src/volume.c
View file @
f15d879e
...
...
@@ -215,7 +215,7 @@ int volume_level_get(void)
return
-
1
;
}
static
int
software_volume_change
(
int
change
,
int
rel
)
static
bool
software_volume_change
(
int
change
,
bool
rel
)
{
int
new
=
change
;
...
...
@@ -240,10 +240,10 @@ static int software_volume_change(int change, int rel)
setPlayerSoftwareVolume
(
new
);
return
0
;
return
true
;
}
static
int
hardware_volume_change
(
int
change
,
int
rel
)
static
bool
hardware_volume_change
(
int
change
,
bool
rel
)
{
int
device
,
count
;
...
...
@@ -254,10 +254,10 @@ static int hardware_volume_change(int change, int rel)
for
(
device
=
0
;
device
<
count
;
device
++
)
{
mixer_control_setvol
(
device
,
change
,
rel
);
}
return
0
;
return
true
;
}
int
volume_level_change
(
int
change
,
int
rel
)
bool
volume_level_change
(
int
change
,
bool
rel
)
{
idle_add
(
IDLE_MIXER
);
...
...
@@ -267,7 +267,7 @@ int volume_level_change(int change, int rel)
case
VOLUME_MIXER_TYPE_SOFTWARE
:
return
software_volume_change
(
change
,
rel
);
default:
return
0
;
return
true
;
}
}
...
...
src/volume.h
View file @
f15d879e
...
...
@@ -20,6 +20,7 @@
#ifndef MPD_VOLUME_H
#define MPD_VOLUME_H
#include <stdbool.h>
#include <stdio.h>
#define VOLUME_MIXER_OSS "oss"
...
...
@@ -34,7 +35,7 @@ void volume_finish(void);
int
volume_level_get
(
void
);
int
volume_level_change
(
int
change
,
int
rel
);
bool
volume_level_change
(
int
change
,
bool
rel
);
void
read_sw_volume_state
(
FILE
*
fp
);
...
...
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