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
88102662
Commit
88102662
authored
Mar 26, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oss_mixer: removed superfluous checks
The MPD core guarantees that methods are always invoked in a consistent state. This means we can remove lots of checks from the volume methods.
parent
dd8c6d67
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
oss_mixer.c
src/mixer/oss_mixer.c
+8
-8
No files found.
src/mixer/oss_mixer.c
View file @
88102662
...
...
@@ -21,6 +21,8 @@
#include "../mixer_api.h"
#include <glib.h>
#include <assert.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
...
...
@@ -58,7 +60,6 @@ oss_mixer_init(const struct config_param *param)
VOLUME_MIXER_OSS_DEFAULT
);
om
->
control
=
config_get_block_string
(
param
,
"mixer_control"
,
NULL
);
om
->
device_fd
=
-
1
;
om
->
volume_control
=
SOUND_MIXER_PCM
;
return
&
om
->
base
;
...
...
@@ -76,9 +77,10 @@ static void
oss_mixer_close
(
struct
mixer
*
data
)
{
struct
oss_mixer
*
om
=
(
struct
oss_mixer
*
)
data
;
if
(
om
->
device_fd
!=
-
1
)
while
(
close
(
om
->
device_fd
)
&&
errno
==
EINTR
)
;
om
->
device_fd
=
-
1
;
assert
(
om
->
device_fd
>=
0
);
close
(
om
->
device_fd
);
}
static
int
...
...
@@ -141,8 +143,7 @@ oss_mixer_get_volume(struct mixer *mixer)
int
left
,
right
,
level
;
int
ret
;
if
(
om
->
device_fd
<
0
&&
!
oss_mixer_open
(
mixer
))
return
false
;
assert
(
om
->
device_fd
>=
0
);
ret
=
ioctl
(
om
->
device_fd
,
MIXER_READ
(
om
->
volume_control
),
&
level
);
if
(
ret
<
0
)
{
...
...
@@ -168,8 +169,7 @@ oss_mixer_set_volume(struct mixer *mixer, unsigned volume)
int
level
;
int
ret
;
if
(
om
->
device_fd
<
0
&&
!
oss_mixer_open
(
mixer
))
return
false
;
assert
(
om
->
device_fd
>=
0
);
if
(
volume
>
100
)
volume
=
100
;
...
...
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