summaryrefslogtreecommitdiffstats
path: root/polyp/polyplib-context.h
diff options
context:
space:
mode:
Diffstat (limited to 'polyp/polyplib-context.h')
-rw-r--r--polyp/polyplib-context.h182
1 files changed, 48 insertions, 134 deletions
diff --git a/polyp/polyplib-context.h b/polyp/polyplib-context.h
index a0dd9f9c..6a1cc8bd 100644
--- a/polyp/polyplib-context.h
+++ b/polyp/polyplib-context.h
@@ -1,5 +1,5 @@
-#ifndef foopolyplibhfoo
-#define foopolyplibhfoo
+#ifndef foopolyplibcontexthfoo
+#define foopolyplibcontexthfoo
/* $Id$ */
@@ -22,157 +22,71 @@
USA.
***/
-#include <sys/types.h>
-
#include "sample.h"
#include "polyplib-def.h"
#include "mainloop-api.h"
+#include "cdecl.h"
+#include "polyplib-operation.h"
+
+/** \file
+ * Connection contexts */
+
+PA_C_DECL_BEGIN
+
+/** The state of a connection context */
+enum pa_context_state {
+ PA_CONTEXT_UNCONNECTED, /**< The context hasn't been connected yet */
+ PA_CONTEXT_CONNECTING, /**< A connection is being established */
+ PA_CONTEXT_AUTHORIZING, /**< The client is authorizing itself to the daemon */
+ PA_CONTEXT_SETTING_NAME, /**< The client is passing its application name to the daemon */
+ PA_CONTEXT_READY, /**< The connection is established, the context is ready to execute operations */
+ PA_CONTEXT_FAILED, /**< The connection failed or was disconnected */
+ PA_CONTEXT_TERMINATED /**< The connect was terminated cleanly */
+};
-#ifdef __cplusplus
-//extern "C" {
-#endif
-
+/** \struct pa_context
+ * A connection context to a daemon */
struct pa_context;
-struct pa_stream;
+/** Instantiate a new connection context with an abstract mainloop API
+ * and an application name */
struct pa_context *pa_context_new(struct pa_mainloop_api *mainloop, const char *name);
+
+/** Decrease the reference counter of the context by one */
void pa_context_unref(struct pa_context *c);
+
+/** Increase the reference counter of the context by one */
struct pa_context* pa_context_ref(struct pa_context *c);
-int pa_context_connect(struct pa_context *c, const char *server, void (*complete) (struct pa_context*c, int success, void *userdata), void *userdata);
-int pa_context_drain(struct pa_context *c, void (*complete) (struct pa_context*c, void *userdata), void *userdata);
-void pa_context_set_die_callback(struct pa_context *c, void (*cb)(struct pa_context *c, void *userdata), void *userdata);
+/** Set a callback function that is called whenever the context status changes */
+void pa_context_set_state_callback(struct pa_context *c, void (*cb)(struct pa_context *c, void *userdata), void *userdata);
-int pa_context_is_dead(struct pa_context *c);
-int pa_context_is_ready(struct pa_context *c);
+/** Return the error number of the last failed operation */
int pa_context_errno(struct pa_context *c);
+/** Return non-zero if some data is pending to be written to the connection */
int pa_context_is_pending(struct pa_context *c);
-struct pa_stream* pa_stream_new(struct pa_context *c, enum pa_stream_direction dir, const char *dev, const char *name, const struct pa_sample_spec *ss, const struct pa_buffer_attr *attr, void (*complete) (struct pa_stream*s, int success, void *userdata), void *userdata);
-void pa_stream_unref(struct pa_stream *s);
-struct pa_stream *pa_stream_ref(struct pa_stream *s);
-
-void pa_stream_drain(struct pa_stream *s, void (*complete) (struct pa_stream*s, void *userdata), void *userdata);
-
-void pa_stream_set_die_callback(struct pa_stream *s, void (*cb)(struct pa_stream *s, void *userdata), void *userdata);
-
-void pa_stream_set_write_callback(struct pa_stream *p, void (*cb)(struct pa_stream *p, size_t length, void *userdata), void *userdata);
-void pa_stream_write(struct pa_stream *p, const void *data, size_t length);
-size_t pa_stream_writable_size(struct pa_stream *p);
+/** Return the current context status */
+enum pa_context_state pa_context_get_state(struct pa_context *c);
-void pa_stream_set_read_callback(struct pa_stream *p, void (*cb)(struct pa_stream *p, const void*data, size_t length, void *userdata), void *userdata);
+/** Connect the context to the specified server. If server is NULL,
+connect to the default server. This routine may but will not always
+return synchronously on error. Use pa_context_set_state_callback() to
+be notified when the connection is established */
+int pa_context_connect(struct pa_context *c, const char *server);
-int pa_stream_is_dead(struct pa_stream *p);
-int pa_stream_is_ready(struct pa_stream*p);
+/** Terminate the context connection immediately */
+void pa_context_disconnect(struct pa_context *c);
-void pa_stream_get_latency(struct pa_stream *p, void (*cb)(struct pa_stream *p, uint32_t latency, void *userdata), void *userdata);
+/** Drain the context. If there is nothing to drain, the function returns NULL */
+struct pa_operation* pa_context_drain(struct pa_context *c, void (*cb) (struct pa_context*c, void *userdata), void *userdata);
-struct pa_context* pa_stream_get_context(struct pa_stream *p);
+/** Tell the daemon to exit. No operation object is returned as the
+ * connection is terminated when the daemon quits, thus this operation
+ * would never complete. */
+void pa_context_exit_daemon(struct pa_context *c);
-uint32_t pa_stream_get_index(struct pa_stream *s);
-
-struct pa_stream* pa_context_upload_sample(struct pa_context *c, const char *name, const struct pa_sample_spec *ss, size_t length, void (*cb) (struct pa_stream*s, int success, void *userdata), void *userdata);
-void pa_stream_finish_sample(struct pa_stream *p, void (*cb)(struct pa_stream*s, int success, void *userdata), void *userdata);
-
-void pa_context_play_sample(struct pa_context *c, const char *name, const char *dev, uint32_t volume, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata);
-void pa_context_remove_sample(struct pa_context *c, const char *name, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata);
-
-struct pa_sink_info {
- const char *name;
- uint32_t index;
- const char *description;
- struct pa_sample_spec sample_spec;
- uint32_t owner_module;
- uint32_t volume;
- uint32_t monitor_source;
- const char *monitor_source_name;
- uint32_t latency;
-};
-
-void pa_context_get_sink_info_by_name(struct pa_context *c, const char *name, void (*cb)(struct pa_context *c, const struct pa_sink_info *i, int is_last, void *userdata), void *userdata);
-void pa_context_get_sink_info_by_index(struct pa_context *c, uint32_t id, void (*cb)(struct pa_context *c, const struct pa_sink_info *i, int is_last, void *userdata), void *userdata);
-void pa_context_get_sink_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_sink_info *i, int is_last, void *userdata), void *userdata);
-
-struct pa_source_info {
- const char *name;
- uint32_t index;
- const char *description;
- struct pa_sample_spec sample_spec;
- uint32_t owner_module;
- uint32_t monitor_of_sink;
- const char *monitor_of_sink_name;
-};
-
-void pa_context_get_source_info_by_name(struct pa_context *c, const char *name, void (*cb)(struct pa_context *c, const struct pa_source_info *i, int is_last, void *userdata), void *userdata);
-void pa_context_get_source_info_by_index(struct pa_context *c, uint32_t id, void (*cb)(struct pa_context *c, const struct pa_source_info *i, int is_last, void *userdata), void *userdata);
-void pa_context_get_source_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_source_info *i, int is_last, void *userdata), void *userdata);
-
-struct pa_server_info {
- const char *user_name;
- const char *host_name;
- const char *server_version;
- const char *server_name;
- struct pa_sample_spec sample_spec;
-};
-
-void pa_context_get_server_info(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_server_info*i, void *userdata), void *userdata);
-
-struct pa_module_info {
- uint32_t index;
- const char*name, *argument;
- uint32_t n_used, auto_unload;
-};
-
-void pa_context_get_module_info(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_module_info*i, int is_last, void *userdata), void *userdata);
-void pa_context_get_module_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_module_info*i, int is_last, void *userdata), void *userdata);
-
-struct pa_client_info {
- uint32_t index;
- const char *name;
- uint32_t owner_module;
- const char *protocol_name;
-};
-
-void pa_context_get_client_info(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_client_info*i, int is_last, void *userdata), void *userdata);
-void pa_context_get_client_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_client_info*i, int is_last, void *userdata), void *userdata);
-
-struct pa_sink_input_info {
- uint32_t index;
- const char *name;
- uint32_t owner_module;
- uint32_t owner_client;
- uint32_t sink;
- struct pa_sample_spec sample_spec;
- uint32_t volume;
- uint32_t latency;
-};
-
-void pa_context_get_sink_input_info(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_sink_input_info*i, int is_last, void *userdata), void *userdata);
-void pa_context_get_sink_input_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_sink_input_info*i, int is_last, void *userdata), void *userdata);
-
-struct pa_source_output_info {
- uint32_t index;
- const char *name;
- uint32_t owner_module;
- uint32_t owner_client;
- uint32_t source;
- struct pa_sample_spec sample_spec;
-};
-
-void pa_context_get_source_output_info(struct pa_context *c, uint32_t index, void (*cb)(struct pa_context *c, const struct pa_source_output_info*i, int is_last, void *userdata), void *userdata);
-void pa_context_get_source_output_info_list(struct pa_context *c, void (*cb)(struct pa_context *c, const struct pa_source_output_info*i, int is_last, void *userdata), void *userdata);
-
-void pa_context_set_sink_volume(struct pa_context *c, uint32_t index, uint32_t volume, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata);
-void pa_context_set_sink_input_volume(struct pa_context *c, uint32_t index, uint32_t volume, void (*cb)(struct pa_context *c, int success, void *userdata), void *userdata);
-
-void pa_context_exit(struct pa_context *c);
-void pa_context_stat(struct pa_context *c, void (*cb)(struct pa_context *c, uint32_t count, uint32_t total, void *userdata), void *userdata);
-
-void pa_context_subscribe(struct pa_context *c, enum pa_subscription_mask m, void (*cb)(struct pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata), void *userdata);
-
-#ifdef __cplusplus
-}
-#endif
+PA_C_DECL_END
#endif