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
88af35c0
Commit
88af35c0
authored
Mar 14, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
volume: moved code to mixer_all.c
parent
e7c3f469
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
113 additions
and
30 deletions
+113
-30
Makefile.am
Makefile.am
+2
-0
mixer_all.c
src/mixer_all.c
+59
-0
mixer_all.h
src/mixer_all.h
+47
-0
volume.c
src/volume.c
+5
-30
No files found.
Makefile.am
View file @
88af35c0
...
...
@@ -79,6 +79,7 @@ mpd_headers = \
src/log.h
\
src/ls.h
\
src/main.h
\
src/mixer_all.h
\
src/mixer_api.h
\
src/mixer_control.h
\
src/event_pipe.h
\
...
...
@@ -457,6 +458,7 @@ OUTPUT_SRC = \
MIXER_API_SRC
=
\
src/mixer_control.c
\
src/mixer_all.c
\
src/mixer_api.c
MIXER_SRC
=
...
...
src/mixer_all.c
0 → 100644
View file @
88af35c0
/*
* Copyright (C) 2003-2009 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "mixer_all.h"
#include "mixer_control.h"
#include "output_all.h"
#include <glib.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "mixer"
int
mixer_all_get_volume
(
void
)
{
unsigned
count
=
audio_output_count
(),
ok
=
0
;
int
volume
,
total
=
0
;
for
(
unsigned
i
=
0
;
i
<
count
;
i
++
)
{
if
(
mixer_control_getvol
(
i
,
&
volume
))
{
g_debug
(
"device %d: volume=%d"
,
i
,
volume
);
total
+=
volume
;
++
ok
;
}
}
if
(
ok
==
0
)
return
-
1
;
return
total
/
ok
;
}
bool
mixer_all_set_volume
(
int
volume
,
bool
relative
)
{
bool
success
=
false
;
unsigned
count
=
audio_output_count
();
for
(
unsigned
i
=
0
;
i
<
count
;
i
++
)
success
=
mixer_control_setvol
(
i
,
volume
,
relative
)
||
success
;
return
success
;
}
src/mixer_all.h
0 → 100644
View file @
88af35c0
/*
* Copyright (C) 2003-2009 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/** \file
*
* Functions which affect the mixers of all audio outputs.
*/
#ifndef MPD_MIXER_ALL_H
#define MPD_MIXER_ALL_H
#include <stdbool.h>
/**
* Returns the average volume of all available mixers (range 0..100).
* Returns -1 if no mixer can be queried.
*/
int
mixer_all_get_volume
(
void
);
/**
* Sets the volume on all available mixers.
*
* @param volume the volume (range 0..100 or -100..100 if #relative)
* @param relative if true, then the #volume is added to the current value
* @return true on success, false on failure
*/
bool
mixer_all_set_volume
(
int
volume
,
bool
relative
);
#endif
src/volume.c
View file @
88af35c0
...
...
@@ -23,9 +23,9 @@
#include "idle.h"
#include "pcm_volume.h"
#include "config.h"
#include "mixer_control.h"
#include "output_all.h"
#include "mixer_api.h"
#include "mixer_all.h"
#include <glib.h>
...
...
@@ -166,9 +166,6 @@ void volume_init(void)
static
int
hardware_volume_get
(
void
)
{
int
device
,
count
;
int
volume
,
volume_total
,
volume_ok
;
assert
(
hardware_volume_timer
!=
NULL
);
if
(
last_hardware_volume
>=
0
&&
...
...
@@ -176,25 +173,9 @@ static int hardware_volume_get(void)
/* throttle access to hardware mixers */
return
last_hardware_volume
;
volume_total
=
0
;
volume_ok
=
0
;
count
=
audio_output_count
();
for
(
device
=
0
;
device
<
count
;
device
++
)
{
if
(
mixer_control_getvol
(
device
,
&
volume
))
{
g_debug
(
"device %d: volume: %d
\n
"
,
device
,
volume
);
volume_total
+=
volume
;
volume_ok
++
;
}
}
if
(
volume_ok
>
0
)
{
//return average
last_hardware_volume
=
volume_total
/
volume_ok
;
g_timer_start
(
hardware_volume_timer
);
return
last_hardware_volume
;
}
else
{
return
-
1
;
}
last_hardware_volume
=
mixer_all_get_volume
();
g_timer_start
(
hardware_volume_timer
);
return
last_hardware_volume
;
}
static
int
software_volume_get
(
void
)
...
...
@@ -245,16 +226,10 @@ static bool software_volume_change(int change, bool rel)
static
bool
hardware_volume_change
(
int
change
,
bool
rel
)
{
int
device
,
count
;
/* reset the cache */
last_hardware_volume
=
-
1
;
count
=
audio_output_count
();
for
(
device
=
0
;
device
<
count
;
device
++
)
{
mixer_control_setvol
(
device
,
change
,
rel
);
}
return
true
;
return
mixer_all_set_volume
(
change
,
rel
);
}
bool
volume_level_change
(
int
change
,
bool
rel
)
...
...
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