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
89d4f438
Commit
89d4f438
authored
Jul 06, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mixer_type: moved volume_mixer_type from volume.c
parent
8bd7b5b6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
109 additions
and
25 deletions
+109
-25
Makefile.am
Makefile.am
+2
-0
mixer_type.c
src/mixer_type.c
+38
-0
mixer_type.h
src/mixer_type.h
+47
-0
volume.c
src/volume.c
+22
-21
volume.h
src/volume.h
+0
-4
No files found.
Makefile.am
View file @
89d4f438
...
...
@@ -94,6 +94,7 @@ mpd_headers = \
src/mixer_list.h
\
src/event_pipe.h
\
src/mixer_plugin.h
\
src/mixer_type.h
\
src/daemon.h
\
src/normalize.h
\
src/compress.h
\
...
...
@@ -515,6 +516,7 @@ OUTPUT_SRC = \
MIXER_API_SRC
=
\
src/mixer_control.c
\
src/mixer_type.c
\
src/mixer_all.c
\
src/mixer_api.c
...
...
src/mixer_type.c
0 → 100644
View file @
89d4f438
/*
* 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_type.h"
#include <assert.h>
#include <string.h>
enum
mixer_type
mixer_type_parse
(
const
char
*
input
)
{
assert
(
input
!=
NULL
);
if
(
strcmp
(
input
,
"none"
)
==
0
||
strcmp
(
input
,
"disabled"
)
==
0
)
return
MIXER_TYPE_NONE
;
else
if
(
strcmp
(
input
,
"hardware"
)
==
0
)
return
MIXER_TYPE_HARDWARE
;
else
if
(
strcmp
(
input
,
"software"
)
==
0
)
return
MIXER_TYPE_SOFTWARE
;
else
return
MIXER_TYPE_UNKNOWN
;
}
src/mixer_type.h
0 → 100644
View file @
89d4f438
/*
* 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 MPD_MIXER_TYPE_H
#define MPD_MIXER_TYPE_H
enum
mixer_type
{
/** parser error */
MIXER_TYPE_UNKNOWN
,
/** mixer disabled */
MIXER_TYPE_NONE
,
/** software mixer with pcm_volume() */
MIXER_TYPE_SOFTWARE
,
/** hardware mixer (output's plugin) */
MIXER_TYPE_HARDWARE
,
};
/**
* Parses a "mixer_type" setting from the configuration file.
*
* @param input the configured string value; must not be NULL
* @return a #mixer_type value; MIXER_TYPE_UNKNOWN means #input could
* not be parsed
*/
enum
mixer_type
mixer_type_parse
(
const
char
*
input
);
#endif
src/volume.c
View file @
89d4f438
...
...
@@ -26,6 +26,7 @@
#include "output_all.h"
#include "mixer_control.h"
#include "mixer_all.h"
#include "mixer_type.h"
#include <glib.h>
...
...
@@ -39,11 +40,7 @@
#define SW_VOLUME_STATE "sw_volume: "
static
enum
{
VOLUME_MIXER_TYPE_SOFTWARE
,
VOLUME_MIXER_TYPE_HARDWARE
,
VOLUME_MIXER_TYPE_DISABLED
,
}
volume_mixer_type
=
VOLUME_MIXER_TYPE_HARDWARE
;
static
enum
mixer_type
volume_mixer_type
=
MIXER_TYPE_HARDWARE
;
static
int
volume_software_set
=
100
;
...
...
@@ -54,7 +51,7 @@ static GTimer *hardware_volume_timer;
void
volume_finish
(
void
)
{
if
(
volume_mixer_type
==
VOLUME_
MIXER_TYPE_HARDWARE
)
if
(
volume_mixer_type
==
MIXER_TYPE_HARDWARE
)
g_timer_destroy
(
hardware_volume_timer
);
}
...
...
@@ -63,21 +60,24 @@ void volume_init(void)
const
struct
config_param
*
param
=
config_get_param
(
CONF_MIXER_TYPE
);
//hw mixing is by default
if
(
param
)
{
if
(
strcmp
(
param
->
value
,
VOLUME_MIXER_SOFTWARE
)
==
0
)
{
volume_mixer_type
=
VOLUME_MIXER_TYPE_SOFTWARE
;
volume_mixer_type
=
mixer_type_parse
(
param
->
value
);
switch
(
volume_mixer_type
)
{
case
MIXER_TYPE_NONE
:
case
MIXER_TYPE_SOFTWARE
:
mixer_disable_all
();
}
else
if
(
strcmp
(
param
->
value
,
VOLUME_MIXER_DISABLED
)
==
0
)
{
volume_mixer_type
=
VOLUME_MIXER_TYPE_DISABLED
;
mixer_disable_all
();
}
else
if
(
strcmp
(
param
->
value
,
VOLUME_MIXER_HARDWARE
)
==
0
)
{
break
;
case
MIXER_TYPE_HARDWARE
:
//nothing to do
}
else
{
break
;
case
MIXER_TYPE_UNKNOWN
:
g_error
(
"unknown mixer type %s at line %i
\n
"
,
param
->
value
,
param
->
line
);
}
}
if
(
volume_mixer_type
==
VOLUME_
MIXER_TYPE_HARDWARE
)
if
(
volume_mixer_type
==
MIXER_TYPE_HARDWARE
)
hardware_volume_timer
=
g_timer_new
();
}
...
...
@@ -103,11 +103,12 @@ static int software_volume_get(void)
int
volume_level_get
(
void
)
{
switch
(
volume_mixer_type
)
{
case
VOLUME_
MIXER_TYPE_SOFTWARE
:
case
MIXER_TYPE_SOFTWARE
:
return
software_volume_get
();
case
VOLUME_
MIXER_TYPE_HARDWARE
:
case
MIXER_TYPE_HARDWARE
:
return
hardware_volume_get
();
case
VOLUME_MIXER_TYPE_DISABLED
:
case
MIXER_TYPE_NONE
:
case
MIXER_TYPE_UNKNOWN
:
return
-
1
;
}
...
...
@@ -157,9 +158,9 @@ bool volume_level_change(int change, bool rel)
idle_add
(
IDLE_MIXER
);
switch
(
volume_mixer_type
)
{
case
VOLUME_
MIXER_TYPE_HARDWARE
:
case
MIXER_TYPE_HARDWARE
:
return
hardware_volume_change
(
change
,
rel
);
case
VOLUME_
MIXER_TYPE_SOFTWARE
:
case
MIXER_TYPE_SOFTWARE
:
return
software_volume_change
(
change
,
rel
);
default:
return
true
;
...
...
@@ -172,7 +173,7 @@ void read_sw_volume_state(FILE *fp)
char
*
end
=
NULL
;
long
int
sv
;
if
(
volume_mixer_type
!=
VOLUME_
MIXER_TYPE_SOFTWARE
)
if
(
volume_mixer_type
!=
MIXER_TYPE_SOFTWARE
)
return
;
while
(
fgets
(
buf
,
sizeof
(
buf
),
fp
))
{
if
(
!
g_str_has_prefix
(
buf
,
SW_VOLUME_STATE
))
...
...
@@ -190,6 +191,6 @@ void read_sw_volume_state(FILE *fp)
void
save_sw_volume_state
(
FILE
*
fp
)
{
if
(
volume_mixer_type
==
VOLUME_
MIXER_TYPE_SOFTWARE
)
if
(
volume_mixer_type
==
MIXER_TYPE_SOFTWARE
)
fprintf
(
fp
,
SW_VOLUME_STATE
"%d
\n
"
,
volume_software_set
);
}
src/volume.h
View file @
89d4f438
...
...
@@ -23,10 +23,6 @@
#include <stdbool.h>
#include <stdio.h>
#define VOLUME_MIXER_SOFTWARE "software"
#define VOLUME_MIXER_HARDWARE "hardware"
#define VOLUME_MIXER_DISABLED "disabled"
void
volume_init
(
void
);
void
volume_finish
(
void
);
...
...
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