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
763dd8c1
Commit
763dd8c1
authored
Jan 25, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mixer: return a mixer struct pointer
Don't use statically allocated mixer objects.
parent
ad8561bf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
15 deletions
+40
-15
mixer_api.c
src/mixer_api.c
+16
-0
mixer_api.h
src/mixer_api.h
+7
-0
alsa_plugin.c
src/output/alsa_plugin.c
+7
-7
oss_plugin.c
src/output/oss_plugin.c
+10
-8
No files found.
src/mixer_api.c
View file @
763dd8c1
...
...
@@ -37,6 +37,22 @@ void mixer_finish(struct mixer *mixer)
mixer
->
plugin
=
NULL
;
}
struct
mixer
*
mixer_new
(
const
struct
mixer_plugin
*
plugin
)
{
struct
mixer
*
mixer
=
g_new
(
struct
mixer
,
1
);
mixer_init
(
mixer
,
plugin
);
return
mixer
;
}
void
mixer_free
(
struct
mixer
*
mixer
)
{
mixer_finish
(
mixer
);
g_free
(
mixer
);
}
void
mixer_configure
(
struct
mixer
*
mixer
,
const
struct
config_param
*
param
)
{
assert
(
mixer
!=
NULL
&&
mixer
->
plugin
!=
NULL
);
...
...
src/mixer_api.h
View file @
763dd8c1
...
...
@@ -71,6 +71,13 @@ struct mixer {
void
mixer_init
(
struct
mixer
*
mixer
,
const
struct
mixer_plugin
*
plugin
);
void
mixer_finish
(
struct
mixer
*
mixer
);
struct
mixer
*
mixer_new
(
const
struct
mixer_plugin
*
plugin
);
void
mixer_free
(
struct
mixer
*
mixer
);
void
mixer_configure
(
struct
mixer
*
mixer
,
const
struct
config_param
*
param
);
bool
mixer_open
(
struct
mixer
*
mixer
);
bool
mixer_control
(
struct
mixer
*
mixer
,
int
cmd
,
void
*
arg
);
...
...
src/output/alsa_plugin.c
View file @
763dd8c1
...
...
@@ -71,7 +71,7 @@ struct alsa_data {
size_t
frame_size
;
/** the mixer object associated with this output */
struct
mixer
mixer
;
struct
mixer
*
mixer
;
};
static
const
char
*
...
...
@@ -90,7 +90,7 @@ alsa_data_new(void)
ret
->
writei
=
snd_pcm_writei
;
//use alsa mixer by default
mixer_init
(
&
ret
->
mixer
,
&
alsa_mixer
);
ret
->
mixer
=
mixer_new
(
&
alsa_mixer
);
return
ret
;
}
...
...
@@ -99,7 +99,7 @@ static void
alsa_data_free
(
struct
alsa_data
*
ad
)
{
g_free
(
ad
->
device
);
mixer_f
inish
(
&
ad
->
mixer
);
mixer_f
ree
(
ad
->
mixer
);
free
(
ad
);
}
...
...
@@ -148,7 +148,7 @@ alsa_init(G_GNUC_UNUSED struct audio_output *ao,
alsa_configure
(
ad
,
param
);
if
(
param
)
{
mixer_configure
(
&
ad
->
mixer
,
param
);
mixer_configure
(
ad
->
mixer
,
param
);
}
return
ad
;
...
...
@@ -208,7 +208,7 @@ alsa_open(void *data, struct audio_format *audio_format)
unsigned
int
period_time
,
period_time_ro
;
unsigned
int
buffer_time
;
mixer_open
(
&
ad
->
mixer
);
mixer_open
(
ad
->
mixer
);
if
((
bitformat
=
get_bitformat
(
audio_format
))
==
SND_PCM_FORMAT_UNKNOWN
)
g_warning
(
"ALSA device
\"
%s
\"
doesn't support %u bit audio
\n
"
,
...
...
@@ -436,7 +436,7 @@ alsa_close(void *data)
ad
->
pcm
=
NULL
;
}
mixer_close
(
&
ad
->
mixer
);
mixer_close
(
ad
->
mixer
);
}
static
bool
...
...
@@ -475,7 +475,7 @@ static bool
alsa_control
(
void
*
data
,
int
cmd
,
void
*
arg
)
{
struct
alsa_data
*
ad
=
data
;
return
mixer_control
(
&
ad
->
mixer
,
cmd
,
arg
);
return
mixer_control
(
ad
->
mixer
,
cmd
,
arg
);
}
const
struct
audio_output_plugin
alsaPlugin
=
{
...
...
src/output/oss_plugin.c
View file @
763dd8c1
...
...
@@ -55,7 +55,9 @@ typedef struct _OssData {
int
numSupported
[
3
];
int
*
unsupported
[
3
];
int
numUnsupported
[
3
];
struct
mixer
mixer
;
/** the mixer object associated with this output */
struct
mixer
*
mixer
;
}
OssData
;
enum
oss_support
{
...
...
@@ -276,7 +278,7 @@ static OssData *newOssData(void)
supportParam
(
ret
,
SNDCTL_DSP_CHANNELS
,
2
);
supportParam
(
ret
,
SNDCTL_DSP_SAMPLESIZE
,
16
);
mixer_init
(
&
ret
->
mixer
,
&
oss_mixer
);
ret
->
mixer
=
mixer_new
(
&
oss_mixer
);
return
ret
;
}
...
...
@@ -290,7 +292,7 @@ static void freeOssData(OssData * od)
g_free
(
od
->
unsupported
[
OSS_CHANNELS
]);
g_free
(
od
->
unsupported
[
OSS_BITS
]);
mixer_f
inish
(
&
od
->
mixer
);
mixer_f
ree
(
od
->
mixer
);
free
(
od
);
}
...
...
@@ -355,7 +357,7 @@ static void *oss_open_default(const struct config_param *param)
if
(
ret
[
i
]
==
0
)
{
OssData
*
od
=
newOssData
();
od
->
device
=
default_devices
[
i
];
mixer_configure
(
&
od
->
mixer
,
param
);
mixer_configure
(
od
->
mixer
,
param
);
return
od
;
}
}
...
...
@@ -396,7 +398,7 @@ oss_initDriver(G_GNUC_UNUSED struct audio_output *audioOutput,
if
(
device
!=
NULL
)
{
OssData
*
od
=
newOssData
();
od
->
device
=
device
;
mixer_configure
(
&
od
->
mixer
,
param
);
mixer_configure
(
od
->
mixer
,
param
);
return
od
;
}
...
...
@@ -522,7 +524,7 @@ oss_openDevice(void *data, struct audio_format *audioFormat)
od
->
audio_format
.
bits
,
od
->
audio_format
.
channels
,
od
->
audio_format
.
sample_rate
);
mixer_open
(
&
od
->
mixer
);
mixer_open
(
od
->
mixer
);
return
ret
;
}
...
...
@@ -532,7 +534,7 @@ static void oss_closeDevice(void *data)
OssData
*
od
=
data
;
oss_close
(
od
);
mixer_close
(
&
od
->
mixer
);
mixer_close
(
od
->
mixer
);
}
static
void
oss_dropBufferedAudio
(
void
*
data
)
...
...
@@ -575,7 +577,7 @@ static bool
oss_control
(
void
*
data
,
int
cmd
,
void
*
arg
)
{
OssData
*
od
=
data
;
return
mixer_control
(
&
od
->
mixer
,
cmd
,
arg
);
return
mixer_control
(
od
->
mixer
,
cmd
,
arg
);
}
const
struct
audio_output_plugin
ossPlugin
=
{
...
...
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