1
From: siretart@tauware.de
2
Subject: sync libao2/ao_pulse.c with svn r30062
5
diff --git a/libao2/ao_pulse.c b/libao2/ao_pulse.c
6
index 30a2380..a07bf31 100644
7
--- a/libao2/ao_pulse.c
8
+++ b/libao2/ao_pulse.c
9
@@ -49,9 +49,6 @@ static struct pa_context *context;
10
/** Main event loop object */
11
static struct pa_threaded_mainloop *mainloop;
13
-/** A temporary variable to store the current volume */
14
-static pa_cvolume volume;
16
static int broken_pause;
19
@@ -102,7 +99,10 @@ static void success_cb(pa_stream *s, int success, void *userdata) {
21
static int waitop(pa_operation *op) {
22
pa_operation_state_t state;
25
+ pa_threaded_mainloop_unlock(mainloop);
28
state = pa_operation_get_state(op);
29
while (state == PA_OPERATION_RUNNING) {
30
pa_threaded_mainloop_wait(mainloop);
31
@@ -140,7 +140,7 @@ static int init(int rate_hz, int channels, int format, int flags) {
35
- char *version = pa_get_library_version();
36
+ const char *version = pa_get_library_version();
39
devarg = strdup(ao_subdevice);
40
@@ -150,11 +150,11 @@ static int init(int rate_hz, int channels, int format, int flags) {
44
- // not sure which versions are affected, assume 0.9.1*
45
+ // not sure which versions are affected, assume 0.9.11* to 0.9.14*
46
// known bad: 0.9.14, 0.9.13
47
- // known good: 0.9.9, 0.9.10
48
+ // known good: 0.9.9, 0.9.10, 0.9.15
49
// to test: pause, wait ca. 5 seconds framestep and see if MPlayer hangs somewhen
50
- if (strncmp(version, "0.9.1", 5) == 0 && strncmp(version, "0.9.10", 6) != 0) {
51
+ if (strncmp(version, "0.9.1", 5) == 0 && version[5] >= '1' && version[5] <= '4') {
52
mp_msg(MSGT_AO, MSGL_WARN, "[pulse] working around probably broken pause functionality,\n"
53
" see http://www.pulseaudio.org/ticket/440\n");
55
@@ -345,13 +345,14 @@ static float get_delay(void) {
56
* pa_context_get_sink_input_info() operation completes. Saves the
57
* volume field of the specified structure to the global variable volume. */
58
static void info_func(struct pa_context *c, const struct pa_sink_input_info *i, int is_last, void *userdata) {
59
+ struct pa_cvolume *volume = userdata;
61
GENERIC_ERR_MSG(context, "Failed to get sink input info");
67
+ *volume = i->volume;
68
pa_threaded_mainloop_signal(mainloop, 0);
71
@@ -360,8 +361,9 @@ static int control(int cmd, void *arg) {
72
case AOCONTROL_GET_VOLUME: {
73
ao_control_vol_t *vol = arg;
74
uint32_t devidx = pa_stream_get_index(stream);
75
+ struct pa_cvolume volume;
76
pa_threaded_mainloop_lock(mainloop);
77
- if (!waitop(pa_context_get_sink_input_info(context, devidx, info_func, NULL))) {
78
+ if (!waitop(pa_context_get_sink_input_info(context, devidx, info_func, &volume))) {
79
GENERIC_ERR_MSG(context, "pa_stream_get_sink_input_info() failed");
82
@@ -379,7 +381,9 @@ static int control(int cmd, void *arg) {
83
case AOCONTROL_SET_VOLUME: {
84
const ao_control_vol_t *vol = arg;
86
+ struct pa_cvolume volume;
88
+ pa_cvolume_reset(&volume, ao_data.channels);
89
if (volume.channels != 2)
90
pa_cvolume_set(&volume, volume.channels, (pa_volume_t)vol->left*PA_VOLUME_NORM/100);
92
@@ -387,12 +391,16 @@ static int control(int cmd, void *arg) {
93
volume.values[1] = (pa_volume_t)vol->right*PA_VOLUME_NORM/100;
96
- if (!(o = pa_context_set_sink_input_volume(context, pa_stream_get_index(stream), &volume, NULL, NULL))) {
97
+ pa_threaded_mainloop_lock(mainloop);
98
+ o = pa_context_set_sink_input_volume(context, pa_stream_get_index(stream), &volume, NULL, NULL);
100
+ pa_threaded_mainloop_unlock(mainloop);
101
GENERIC_ERR_MSG(context, "pa_context_set_sink_input_volume() failed");
102
return CONTROL_ERROR;
104
/* We don't wait for completion here */
105
pa_operation_unref(o);
106
+ pa_threaded_mainloop_unlock(mainloop);