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
37bc31d1
Commit
37bc31d1
authored
Feb 16, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output_plugin: replaced method "control()" with "mixer()"
The output plugin shouldn't know any specifics of the mixer API. Make it return the mixer object, and let the caller deal with it.
parent
79b50b7d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
28 deletions
+45
-28
audio.c
src/audio.c
+10
-6
alsa_plugin.c
src/output/alsa_plugin.c
+9
-8
oss_plugin.c
src/output/oss_plugin.c
+9
-8
output_plugin.h
src/output_plugin.h
+17
-6
No files found.
src/audio.c
View file @
37bc31d1
...
...
@@ -62,15 +62,17 @@ void finishAudioConfig(void)
bool
mixer_control_setvol
(
unsigned
int
device
,
int
volume
,
int
rel
)
{
struct
audio_output
*
output
;
struct
mixer
*
mixer
;
if
(
device
>=
audio_output_count
())
return
false
;
output
=
audio_output_get
(
device
);
if
(
output
->
plugin
&&
output
->
plugin
->
control
)
{
mixer
=
ao_plugin_get_mixer
(
output
->
plugin
,
output
->
data
);
if
(
mixer
!=
NULL
)
{
if
(
rel
)
{
int
cur_volume
;
if
(
!
output
->
plugin
->
control
(
output
->
data
,
AC_MIXER_GETVOL
,
&
cur_volume
))
{
if
(
!
mixer_control
(
mixer
,
AC_MIXER_GETVOL
,
&
cur_volume
))
{
return
false
;
}
volume
=
volume
+
cur_volume
;
...
...
@@ -80,7 +82,7 @@ bool mixer_control_setvol(unsigned int device, int volume, int rel)
else
if
(
volume
<
0
)
volume
=
0
;
return
output
->
plugin
->
control
(
output
->
data
,
AC_MIXER_SETVOL
,
&
volume
);
return
mixer_control
(
mixer
,
AC_MIXER_SETVOL
,
&
volume
);
}
return
false
;
}
...
...
@@ -88,13 +90,15 @@ bool mixer_control_setvol(unsigned int device, int volume, int rel)
bool
mixer_control_getvol
(
unsigned
int
device
,
int
*
volume
)
{
struct
audio_output
*
output
;
struct
mixer
*
mixer
;
if
(
device
>=
audio_output_count
())
return
false
;
output
=
audio_output_get
(
device
);
if
(
output
->
plugin
&&
output
->
plugin
->
control
)
{
return
output
->
plugin
->
control
(
output
->
data
,
AC_MIXER_GETVOL
,
volume
);
}
mixer
=
ao_plugin_get_mixer
(
output
->
plugin
,
output
->
data
);
if
(
mixer
!=
NULL
)
return
mixer_control
(
mixer
,
AC_MIXER_GETVOL
,
volume
);
return
false
;
}
src/output/alsa_plugin.c
View file @
37bc31d1
...
...
@@ -156,6 +156,14 @@ alsa_finish(void *data)
alsa_data_free
(
ad
);
}
static
struct
mixer
*
alsa_get_mixer
(
void
*
data
)
{
struct
alsa_data
*
ad
=
data
;
return
ad
->
mixer
;
}
static
bool
alsa_test_default_device
(
void
)
{
...
...
@@ -465,21 +473,14 @@ alsa_play(void *data, const char *chunk, size_t size)
return
true
;
}
static
bool
alsa_control
(
void
*
data
,
int
cmd
,
void
*
arg
)
{
struct
alsa_data
*
ad
=
data
;
return
mixer_control
(
ad
->
mixer
,
cmd
,
arg
);
}
const
struct
audio_output_plugin
alsaPlugin
=
{
.
name
=
"alsa"
,
.
test_default_device
=
alsa_test_default_device
,
.
init
=
alsa_init
,
.
finish
=
alsa_finish
,
.
get_mixer
=
alsa_get_mixer
,
.
open
=
alsa_open
,
.
play
=
alsa_play
,
.
cancel
=
alsa_cancel
,
.
close
=
alsa_close
,
.
control
=
alsa_control
};
src/output/oss_plugin.c
View file @
37bc31d1
...
...
@@ -410,6 +410,14 @@ static void oss_finishDriver(void *data)
freeOssData
(
od
);
}
static
struct
mixer
*
oss_get_mixer
(
void
*
data
)
{
OssData
*
od
=
data
;
return
od
->
mixer
;
}
static
int
setParam
(
OssData
*
od
,
unsigned
param
,
int
*
value
)
{
int
val
=
*
value
;
...
...
@@ -571,21 +579,14 @@ oss_playAudio(void *data, const char *playChunk, size_t size)
return
true
;
}
static
bool
oss_control
(
void
*
data
,
int
cmd
,
void
*
arg
)
{
OssData
*
od
=
data
;
return
mixer_control
(
od
->
mixer
,
cmd
,
arg
);
}
const
struct
audio_output_plugin
ossPlugin
=
{
.
name
=
"oss"
,
.
test_default_device
=
oss_testDefault
,
.
init
=
oss_initDriver
,
.
finish
=
oss_finishDriver
,
.
get_mixer
=
oss_get_mixer
,
.
open
=
oss_openDevice
,
.
play
=
oss_playAudio
,
.
cancel
=
oss_dropBufferedAudio
,
.
close
=
oss_closeDevice
,
.
control
=
oss_control
,
};
src/output_plugin.h
View file @
37bc31d1
...
...
@@ -64,6 +64,15 @@ struct audio_output_plugin {
void
(
*
finish
)(
void
*
data
);
/**
* Returns the mixer device associated with this audio output.
* This does not actually open the mixer device yet.
*
* @return the mixer object, or NULL if there is no mixer
* attached to this audio output
*/
struct
mixer
*
(
*
get_mixer
)(
void
*
data
);
/**
* Really open the device.
* @param audio_format the audio format in which data is going
* to be delivered; may be modified by the plugin
...
...
@@ -104,12 +113,6 @@ struct audio_output_plugin {
* for continue to pause
*/
bool
(
*
pause
)(
void
*
data
);
/**
* Control the device. Usualy used for implementing
* set and get mixer levels
*/
bool
(
*
control
)(
void
*
data
,
int
cmd
,
void
*
arg
);
};
static
inline
bool
...
...
@@ -135,6 +138,14 @@ ao_plugin_finish(const struct audio_output_plugin *plugin, void *data)
plugin
->
finish
(
data
);
}
static
inline
struct
mixer
*
ao_plugin_get_mixer
(
const
struct
audio_output_plugin
*
plugin
,
void
*
data
)
{
return
plugin
->
get_mixer
!=
NULL
?
plugin
->
get_mixer
(
data
)
:
NULL
;
}
static
inline
bool
ao_plugin_open
(
const
struct
audio_output_plugin
*
plugin
,
void
*
data
,
struct
audio_format
*
audio_format
)
...
...
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