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
86e279f8
Commit
86e279f8
authored
Jul 05, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter/volume: don't use volume_level_get()
Added public methods to get and set the current volume.
parent
d4914fc9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
12 deletions
+68
-12
Makefile.am
Makefile.am
+1
-0
volume_filter_plugin.c
src/filter/volume_filter_plugin.c
+36
-6
volume_filter_plugin.h
src/filter/volume_filter_plugin.h
+31
-0
run_filter.c
test/run_filter.c
+0
-6
No files found.
Makefile.am
View file @
86e279f8
...
...
@@ -45,6 +45,7 @@ mpd_headers = \
src/filter_internal.h
\
src/filter_plugin.h
\
src/filter_registry.h
\
src/filter/volume_filter_plugin.h
\
src/buffer2array.h
\
src/command.h
\
src/idle.h
\
...
...
src/filter/volume_filter_plugin.c
View file @
86e279f8
...
...
@@ -17,13 +17,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "filter/volume_filter_plugin.h"
#include "filter_plugin.h"
#include "filter_internal.h"
#include "filter_registry.h"
#include "conf.h"
#include "pcm_buffer.h"
#include "pcm_volume.h"
#include "volume.h"
#include "audio_format.h"
#include <assert.h>
...
...
@@ -32,6 +32,11 @@
struct
volume_filter
{
struct
filter
filter
;
/**
* The current volume, from 0 to #PCM_VOLUME_1.
*/
unsigned
volume
;
struct
audio_format
audio_format
;
struct
pcm_buffer
buffer
;
...
...
@@ -50,6 +55,8 @@ volume_filter_init(G_GNUC_UNUSED const struct config_param *param,
struct
volume_filter
*
filter
=
g_new
(
struct
volume_filter
,
1
);
filter_init
(
&
filter
->
filter
,
&
volume_filter_plugin
);
filter
->
volume
=
PCM_VOLUME_1
;
return
&
filter
->
filter
;
}
...
...
@@ -92,12 +99,10 @@ volume_filter_filter(struct filter *_filter, const void *src, size_t src_size,
size_t
*
dest_size_r
,
GError
**
error_r
)
{
struct
volume_filter
*
filter
=
(
struct
volume_filter
*
)
_filter
;
int
volume
;
bool
success
;
void
*
dest
;
volume
=
volume_level_get
();
/* XXX don't use volume_level_get() */
if
(
volume
<
0
||
volume
>=
PCM_VOLUME_1
)
{
if
(
filter
->
volume
>=
PCM_VOLUME_1
)
{
/* optimized special case: 100% volume = no-op */
*
dest_size_r
=
src_size
;
return
src
;
...
...
@@ -106,7 +111,7 @@ volume_filter_filter(struct filter *_filter, const void *src, size_t src_size,
dest
=
pcm_buffer_get
(
&
filter
->
buffer
,
src_size
);
*
dest_size_r
=
src_size
;
if
(
volume
=
=
0
)
{
if
(
filter
->
volume
<
=
0
)
{
/* optimized special case: 0% volume = memset(0) */
/* XXX is this valid for all sample formats? What
about floating point? */
...
...
@@ -116,7 +121,8 @@ volume_filter_filter(struct filter *_filter, const void *src, size_t src_size,
memcpy
(
dest
,
src
,
src_size
);
success
=
pcm_volume
(
dest
,
src_size
,
&
filter
->
audio_format
,
volume
);
success
=
pcm_volume
(
dest
,
src_size
,
&
filter
->
audio_format
,
filter
->
volume
);
if
(
!
success
)
{
g_set_error
(
error_r
,
volume_quark
(),
0
,
"pcm_volume() has failed"
);
...
...
@@ -134,3 +140,27 @@ const struct filter_plugin volume_filter_plugin = {
.
close
=
volume_filter_close
,
.
filter
=
volume_filter_filter
,
};
unsigned
volume_filter_get
(
const
struct
filter
*
_filter
)
{
const
struct
volume_filter
*
filter
=
(
const
struct
volume_filter
*
)
_filter
;
assert
(
filter
->
filter
.
plugin
==
&
volume_filter_plugin
);
assert
(
filter
->
volume
<=
PCM_VOLUME_1
);
return
filter
->
volume
;
}
void
volume_filter_set
(
struct
filter
*
_filter
,
unsigned
volume
)
{
struct
volume_filter
*
filter
=
(
struct
volume_filter
*
)
_filter
;
assert
(
filter
->
filter
.
plugin
==
&
volume_filter_plugin
);
assert
(
volume
<=
PCM_VOLUME_1
);
filter
->
volume
=
volume
;
}
src/filter/volume_filter_plugin.h
0 → 100644
View file @
86e279f8
/*
* 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.
*/
#ifndef VOLUME_FILTER_PLUGIN_H
#define VOLUME_FILTER_PLUGIN_H
struct
filter
;
unsigned
volume_filter_get
(
const
struct
filter
*
filter
);
void
volume_filter_set
(
struct
filter
*
filter
,
unsigned
volume
);
#endif
test/run_filter.c
View file @
86e279f8
...
...
@@ -21,7 +21,6 @@
#include "audio_parser.h"
#include "audio_format.h"
#include "filter_plugin.h"
#include "volume.h"
#include "pcm_volume.h"
#include <glib.h>
...
...
@@ -31,11 +30,6 @@
#include <errno.h>
#include <unistd.h>
int
volume_level_get
(
void
)
{
return
PCM_VOLUME_1
;
}
static
const
struct
config_param
*
find_named_config_block
(
const
char
*
block
,
const
char
*
name
)
{
...
...
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