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
3934d2d3
Commit
3934d2d3
authored
Sep 17, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/pulse: don't expose internal struct in public header
Provide _lock() and _unlock() to wrap all accesses from the mixer plugin.
parent
423ce955
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
36 deletions
+66
-36
pulse_mixer_plugin.c
src/mixer/pulse_mixer_plugin.c
+7
-5
pulse_output_plugin.c
src/output/pulse_output_plugin.c
+43
-0
pulse_output_plugin.h
src/output/pulse_output_plugin.h
+6
-31
read_mixer.c
test/read_mixer.c
+10
-0
No files found.
src/mixer/pulse_mixer_plugin.c
View file @
3934d2d3
...
...
@@ -191,13 +191,13 @@ pulse_mixer_get_volume(struct mixer *mixer, G_GNUC_UNUSED GError **error_r)
struct
pulse_mixer
*
pm
=
(
struct
pulse_mixer
*
)
mixer
;
int
ret
;
p
a_threaded_mainloop_lock
(
pm
->
output
->
mainloop
);
p
ulse_output_lock
(
pm
->
output
);
ret
=
pm
->
online
?
(
int
)((
100
*
(
pa_cvolume_avg
(
&
pm
->
volume
)
+
1
))
/
PA_VOLUME_NORM
)
:
-
1
;
p
a_threaded_mainloop_unlock
(
pm
->
output
->
mainloop
);
p
ulse_output_unlock
(
pm
->
output
);
return
ret
;
}
...
...
@@ -209,9 +209,10 @@ pulse_mixer_set_volume(struct mixer *mixer, unsigned volume, GError **error_r)
struct
pa_cvolume
cvolume
;
bool
success
;
pa_threaded_mainloop_lock
(
pm
->
output
->
mainloop
);
pulse_output_lock
(
pm
->
output
);
if
(
!
pm
->
online
)
{
p
a_threaded_mainloop_unlock
(
pm
->
output
->
mainloop
);
p
ulse_output_unlock
(
pm
->
output
);
g_set_error
(
error_r
,
pulse_mixer_quark
(),
0
,
"disconnected"
);
return
false
;
}
...
...
@@ -221,7 +222,8 @@ pulse_mixer_set_volume(struct mixer *mixer, unsigned volume, GError **error_r)
success
=
pulse_output_set_volume
(
pm
->
output
,
&
cvolume
,
error_r
);
if
(
success
)
pm
->
volume
=
cvolume
;
pa_threaded_mainloop_unlock
(
pm
->
output
->
mainloop
);
pulse_output_unlock
(
pm
->
output
);
return
success
;
}
...
...
src/output/pulse_output_plugin.c
View file @
3934d2d3
...
...
@@ -31,11 +31,42 @@
#include <pulse/introspect.h>
#include <pulse/subscribe.h>
#include <pulse/error.h>
#include <pulse/version.h>
#include <assert.h>
#include <stddef.h>
#define MPD_PULSE_NAME "Music Player Daemon"
#if !defined(PA_CHECK_VERSION)
/**
* This macro was implemented in libpulse 0.9.16.
*/
#define PA_CHECK_VERSION(a,b,c) false
#endif
struct
pulse_output
{
const
char
*
name
;
const
char
*
server
;
const
char
*
sink
;
struct
pulse_mixer
*
mixer
;
struct
pa_threaded_mainloop
*
mainloop
;
struct
pa_context
*
context
;
struct
pa_stream
*
stream
;
size_t
writable
;
#if !PA_CHECK_VERSION(0,9,11)
/**
* We need this variable because pa_stream_is_corked() wasn't
* added before 0.9.11.
*/
bool
pause
;
#endif
};
/**
* The quark used for GError.domain.
*/
...
...
@@ -46,6 +77,18 @@ pulse_output_quark(void)
}
void
pulse_output_lock
(
struct
pulse_output
*
po
)
{
pa_threaded_mainloop_lock
(
po
->
mainloop
);
}
void
pulse_output_unlock
(
struct
pulse_output
*
po
)
{
pa_threaded_mainloop_unlock
(
po
->
mainloop
);
}
void
pulse_output_set_mixer
(
struct
pulse_output
*
po
,
struct
pulse_mixer
*
pm
)
{
assert
(
po
!=
NULL
);
...
...
src/output/pulse_output_plugin.h
View file @
3934d2d3
...
...
@@ -21,43 +21,18 @@
#define MPD_PULSE_OUTPUT_PLUGIN_H
#include <stdbool.h>
#include <stddef.h>
#include <glib.h>
#include <pulse/version.h>
#if !defined(PA_CHECK_VERSION)
/**
* This macro was implemented in libpulse 0.9.16.
*/
#define PA_CHECK_VERSION(a,b,c) false
#endif
struct
pa_operation
;
struct
pulse_output
;
struct
pulse_mixer
;
struct
pa_cvolume
;
struct
pulse_output
{
const
char
*
name
;
const
char
*
server
;
const
char
*
sink
;
struct
pulse_mixer
*
mixer
;
struct
pa_threaded_mainloop
*
mainloop
;
struct
pa_context
*
context
;
struct
pa_stream
*
stream
;
size_t
writable
;
void
pulse_output_lock
(
struct
pulse_output
*
po
);
#if !PA_CHECK_VERSION(0,9,11)
/**
* We need this variable because pa_stream_is_corked() wasn't
* added before 0.9.11.
*/
bool
pause
;
#endif
};
void
pulse_output_unlock
(
struct
pulse_output
*
po
);
void
pulse_output_set_mixer
(
struct
pulse_output
*
po
,
struct
pulse_mixer
*
pm
);
...
...
test/read_mixer.c
View file @
3934d2d3
...
...
@@ -34,6 +34,16 @@
#include "output/pulse_output_plugin.h"
void
pulse_output_lock
(
G_GNUC_UNUSED
struct
pulse_output
*
po
)
{
}
void
pulse_output_unlock
(
G_GNUC_UNUSED
struct
pulse_output
*
po
)
{
}
void
pulse_output_set_mixer
(
G_GNUC_UNUSED
struct
pulse_output
*
po
,
G_GNUC_UNUSED
struct
pulse_mixer
*
pm
)
{
...
...
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