output/pulse: don't expose internal struct in public header

Provide _lock() and _unlock() to wrap all accesses from the mixer
plugin.
This commit is contained in:
Max Kellermann
2011-09-17 19:50:36 +02:00
parent 423ce9557a
commit 3934d2d30c
4 changed files with 66 additions and 36 deletions

View File

@@ -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.
*/
@@ -45,6 +76,18 @@ pulse_output_quark(void)
return g_quark_from_static_string("pulse_output");
}
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)
{