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
7873b5e7
Commit
7873b5e7
authored
Jan 05, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mixer/alsa: move code to alsa_mixer_setup()
Better error handling.
parent
1b889c52
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
25 deletions
+34
-25
alsa_mixer_plugin.c
src/mixer/alsa_mixer_plugin.c
+34
-25
No files found.
src/mixer/alsa_mixer_plugin.c
View file @
7873b5e7
...
...
@@ -81,16 +81,6 @@ alsa_mixer_finish(struct mixer *data)
snd_config_update_free_global
();
}
static
void
alsa_mixer_close
(
struct
mixer
*
data
)
{
struct
alsa_mixer
*
am
=
(
struct
alsa_mixer
*
)
data
;
assert
(
am
->
handle
!=
NULL
);
snd_mixer_close
(
am
->
handle
);
}
G_GNUC_PURE
static
snd_mixer_elem_t
*
alsa_mixer_lookup_elem
(
snd_mixer_t
*
handle
,
const
char
*
name
,
unsigned
idx
)
...
...
@@ -109,22 +99,11 @@ alsa_mixer_lookup_elem(snd_mixer_t *handle, const char *name, unsigned idx)
}
static
bool
alsa_mixer_
open
(
struct
mixer
*
data
,
GError
**
error_r
)
alsa_mixer_
setup
(
struct
alsa_mixer
*
am
,
GError
**
error_r
)
{
struct
alsa_mixer
*
am
=
(
struct
alsa_mixer
*
)
data
;
int
err
;
am
->
volume_set
=
-
1
;
err
=
snd_mixer_open
(
&
am
->
handle
,
0
);
if
(
err
<
0
)
{
g_set_error
(
error_r
,
alsa_mixer_quark
(),
err
,
"snd_mixer_open() failed: %s"
,
snd_strerror
(
err
));
return
false
;
}
if
((
err
=
snd_mixer_attach
(
am
->
handle
,
am
->
device
))
<
0
)
{
alsa_mixer_close
(
data
);
g_set_error
(
error_r
,
alsa_mixer_quark
(),
err
,
"failed to attach to %s: %s"
,
am
->
device
,
snd_strerror
(
err
));
...
...
@@ -133,7 +112,6 @@ alsa_mixer_open(struct mixer *data, GError **error_r)
if
((
err
=
snd_mixer_selem_register
(
am
->
handle
,
NULL
,
NULL
))
<
0
)
{
alsa_mixer_close
(
data
);
g_set_error
(
error_r
,
alsa_mixer_quark
(),
err
,
"snd_mixer_selem_register() failed: %s"
,
snd_strerror
(
err
));
...
...
@@ -141,7 +119,6 @@ alsa_mixer_open(struct mixer *data, GError **error_r)
}
if
((
err
=
snd_mixer_load
(
am
->
handle
))
<
0
)
{
alsa_mixer_close
(
data
);
g_set_error
(
error_r
,
alsa_mixer_quark
(),
err
,
"snd_mixer_load() failed: %s
\n
"
,
snd_strerror
(
err
));
...
...
@@ -150,7 +127,6 @@ alsa_mixer_open(struct mixer *data, GError **error_r)
am
->
elem
=
alsa_mixer_lookup_elem
(
am
->
handle
,
am
->
control
,
am
->
index
);
if
(
am
->
elem
==
NULL
)
{
alsa_mixer_close
(
data
);
g_set_error
(
error_r
,
alsa_mixer_quark
(),
0
,
"no such mixer control: %s"
,
am
->
control
);
return
false
;
...
...
@@ -162,6 +138,39 @@ alsa_mixer_open(struct mixer *data, GError **error_r)
return
true
;
}
static
bool
alsa_mixer_open
(
struct
mixer
*
data
,
GError
**
error_r
)
{
struct
alsa_mixer
*
am
=
(
struct
alsa_mixer
*
)
data
;
int
err
;
am
->
volume_set
=
-
1
;
err
=
snd_mixer_open
(
&
am
->
handle
,
0
);
if
(
err
<
0
)
{
g_set_error
(
error_r
,
alsa_mixer_quark
(),
err
,
"snd_mixer_open() failed: %s"
,
snd_strerror
(
err
));
return
false
;
}
if
(
!
alsa_mixer_setup
(
am
,
error_r
))
{
snd_mixer_close
(
am
->
handle
);
return
false
;
}
return
true
;
}
static
void
alsa_mixer_close
(
struct
mixer
*
data
)
{
struct
alsa_mixer
*
am
=
(
struct
alsa_mixer
*
)
data
;
assert
(
am
->
handle
!=
NULL
);
snd_mixer_close
(
am
->
handle
);
}
static
int
alsa_mixer_get_volume
(
struct
mixer
*
mixer
,
GError
**
error_r
)
{
...
...
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