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
90472526
Commit
90472526
authored
Jul 06, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
volume, mixer: removed the "relative" parameter
Since the "volume" command has been removed, nobody uses relative volumes anymore.
parent
206392ad
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
41 deletions
+26
-41
command.c
src/command.c
+1
-1
mixer_all.c
src/mixer_all.c
+3
-11
mixer_all.h
src/mixer_all.h
+2
-3
volume.c
src/volume.c
+19
-25
volume.h
src/volume.h
+1
-1
No files found.
src/command.c
View file @
90472526
...
@@ -1061,7 +1061,7 @@ handle_setvol(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -1061,7 +1061,7 @@ handle_setvol(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
if
(
!
check_int
(
client
,
&
level
,
argv
[
1
],
need_integer
))
if
(
!
check_int
(
client
,
&
level
,
argv
[
1
],
need_integer
))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
success
=
volume_level_change
(
level
,
0
);
success
=
volume_level_change
(
level
);
if
(
!
success
)
{
if
(
!
success
)
{
command_error
(
client
,
ACK_ERROR_SYSTEM
,
command_error
(
client
,
ACK_ERROR_SYSTEM
,
"problems setting volume"
);
"problems setting volume"
);
...
...
src/mixer_all.c
View file @
90472526
...
@@ -70,7 +70,7 @@ mixer_all_get_volume(void)
...
@@ -70,7 +70,7 @@ mixer_all_get_volume(void)
}
}
static
bool
static
bool
output_mixer_set_volume
(
unsigned
i
,
int
volume
,
bool
relative
)
output_mixer_set_volume
(
unsigned
i
,
int
volume
)
{
{
struct
audio_output
*
output
;
struct
audio_output
*
output
;
struct
mixer
*
mixer
;
struct
mixer
*
mixer
;
...
@@ -85,14 +85,6 @@ output_mixer_set_volume(unsigned i, int volume, bool relative)
...
@@ -85,14 +85,6 @@ output_mixer_set_volume(unsigned i, int volume, bool relative)
if
(
mixer
==
NULL
)
if
(
mixer
==
NULL
)
return
false
;
return
false
;
if
(
relative
)
{
int
prev
=
mixer_get_volume
(
mixer
);
if
(
prev
<
0
)
return
false
;
volume
+=
prev
;
}
if
(
volume
>
100
)
if
(
volume
>
100
)
volume
=
100
;
volume
=
100
;
else
if
(
volume
<
0
)
else
if
(
volume
<
0
)
...
@@ -102,13 +94,13 @@ output_mixer_set_volume(unsigned i, int volume, bool relative)
...
@@ -102,13 +94,13 @@ output_mixer_set_volume(unsigned i, int volume, bool relative)
}
}
bool
bool
mixer_all_set_volume
(
int
volume
,
bool
relative
)
mixer_all_set_volume
(
int
volume
)
{
{
bool
success
=
false
;
bool
success
=
false
;
unsigned
count
=
audio_output_count
();
unsigned
count
=
audio_output_count
();
for
(
unsigned
i
=
0
;
i
<
count
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
count
;
i
++
)
success
=
output_mixer_set_volume
(
i
,
volume
,
relative
)
success
=
output_mixer_set_volume
(
i
,
volume
)
||
success
;
||
success
;
return
success
;
return
success
;
...
...
src/mixer_all.h
View file @
90472526
...
@@ -37,11 +37,10 @@ mixer_all_get_volume(void);
...
@@ -37,11 +37,10 @@ mixer_all_get_volume(void);
/**
/**
* Sets the volume on all available mixers.
* Sets the volume on all available mixers.
*
*
* @param volume the volume (range 0..100 or -100..100 if #relative)
* @param volume the volume (range 0..100)
* @param relative if true, then the #volume is added to the current value
* @return true on success, false on failure
* @return true on success, false on failure
*/
*/
bool
bool
mixer_all_set_volume
(
int
volume
,
bool
relative
);
mixer_all_set_volume
(
int
volume
);
#endif
#endif
src/volume.c
View file @
90472526
...
@@ -117,51 +117,45 @@ int volume_level_get(void)
...
@@ -117,51 +117,45 @@ int volume_level_get(void)
return
-
1
;
return
-
1
;
}
}
static
bool
software_volume_change
(
int
change
,
bool
rel
)
static
bool
software_volume_change
(
int
volume
)
{
{
int
new
=
change
;
if
(
volume
>
100
)
volume
=
100
;
else
if
(
volume
<
0
)
volume
=
0
;
if
(
rel
)
volume_software_set
=
volume
;
new
+=
volume_software_set
;
if
(
new
>
100
)
if
(
volume
>=
100
)
new
=
100
;
volume
=
PCM_VOLUME_1
;
else
if
(
new
<
0
)
else
if
(
volume
<=
0
)
new
=
0
;
volume
=
0
;
volume_software_set
=
new
;
/*new = 100.0*(exp(new/50.0)-1)/(M_E*M_E-1)+0.5; */
if
(
new
>=
100
)
new
=
PCM_VOLUME_1
;
else
if
(
new
<=
0
)
new
=
0
;
else
else
new
=
pcm_float_to_volume
((
exp
(
new
/
25
.
0
)
-
1
)
/
volume
=
pcm_float_to_volume
((
exp
(
volume
/
25
.
0
)
-
1
)
/
(
54
.
5981500331
F
-
1
));
(
54
.
5981500331
F
-
1
));
setPlayerSoftwareVolume
(
new
);
setPlayerSoftwareVolume
(
volume
);
return
true
;
return
true
;
}
}
static
bool
hardware_volume_change
(
int
change
,
bool
rel
)
static
bool
hardware_volume_change
(
int
volume
)
{
{
/* reset the cache */
/* reset the cache */
last_hardware_volume
=
-
1
;
last_hardware_volume
=
-
1
;
return
mixer_all_set_volume
(
change
,
rel
);
return
mixer_all_set_volume
(
volume
);
}
}
bool
volume_level_change
(
int
change
,
bool
rel
)
bool
volume_level_change
(
int
volume
)
{
{
idle_add
(
IDLE_MIXER
);
idle_add
(
IDLE_MIXER
);
switch
(
volume_mixer_type
)
{
switch
(
volume_mixer_type
)
{
case
MIXER_TYPE_HARDWARE
:
case
MIXER_TYPE_HARDWARE
:
return
hardware_volume_change
(
change
,
rel
);
return
hardware_volume_change
(
volume
);
case
MIXER_TYPE_SOFTWARE
:
case
MIXER_TYPE_SOFTWARE
:
return
software_volume_change
(
change
,
rel
);
return
software_volume_change
(
volume
);
default:
default:
return
true
;
return
true
;
}
}
...
@@ -182,7 +176,7 @@ void read_sw_volume_state(FILE *fp)
...
@@ -182,7 +176,7 @@ void read_sw_volume_state(FILE *fp)
g_strchomp
(
buf
);
g_strchomp
(
buf
);
sv
=
strtol
(
buf
+
strlen
(
SW_VOLUME_STATE
),
&
end
,
10
);
sv
=
strtol
(
buf
+
strlen
(
SW_VOLUME_STATE
),
&
end
,
10
);
if
(
G_LIKELY
(
!*
end
))
if
(
G_LIKELY
(
!*
end
))
software_volume_change
(
sv
,
0
);
software_volume_change
(
sv
);
else
else
g_warning
(
"Can't parse software volume: %s
\n
"
,
buf
);
g_warning
(
"Can't parse software volume: %s
\n
"
,
buf
);
return
;
return
;
...
...
src/volume.h
View file @
90472526
...
@@ -29,7 +29,7 @@ void volume_finish(void);
...
@@ -29,7 +29,7 @@ void volume_finish(void);
int
volume_level_get
(
void
);
int
volume_level_get
(
void
);
bool
volume_level_change
(
int
change
,
bool
rel
);
bool
volume_level_change
(
int
volume
);
void
read_sw_volume_state
(
FILE
*
fp
);
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