2006-02-16 23:11:28 +00:00
|
|
|
#ifndef foocontexthfoo
|
|
|
|
|
#define foocontexthfoo
|
2004-08-13 13:22:44 +00:00
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
This file is part of polypaudio.
|
|
|
|
|
|
|
|
|
|
polypaudio is free software; you can redistribute it and/or modify
|
2004-11-14 14:58:54 +00:00
|
|
|
it under the terms of the GNU Lesser General Public License as published
|
2004-08-13 13:22:44 +00:00
|
|
|
by the Free Software Foundation; either version 2 of the License,
|
|
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
polypaudio is distributed in the hope that it will be useful, but
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
2004-11-14 14:58:54 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2004-08-13 13:22:44 +00:00
|
|
|
along with polypaudio; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
|
USA.
|
|
|
|
|
***/
|
|
|
|
|
|
2004-12-12 22:58:53 +00:00
|
|
|
#include <polyp/sample.h>
|
2006-02-16 22:43:59 +00:00
|
|
|
#include <polyp/def.h>
|
2004-12-12 22:58:53 +00:00
|
|
|
#include <polyp/mainloop-api.h>
|
|
|
|
|
#include <polyp/cdecl.h>
|
2006-02-16 22:43:59 +00:00
|
|
|
#include <polyp/operation.h>
|
2004-08-14 20:25:32 +00:00
|
|
|
|
|
|
|
|
/** \file
|
2004-08-17 17:17:22 +00:00
|
|
|
* Connection contexts for asynchrononous communication with a
|
|
|
|
|
* server. A pa_context object wraps a connection to a polypaudio
|
|
|
|
|
* server using its native protocol. A context may be used to issue
|
|
|
|
|
* commands on the server or to create playback or recording
|
|
|
|
|
* streams. Multiple playback streams may be piped through a single
|
|
|
|
|
* connection context. Operations on the contect involving
|
|
|
|
|
* communication with the server are executed asynchronously: i.e. the
|
|
|
|
|
* client function do not implicitely wait for completion of the
|
|
|
|
|
* operation on the server. Instead the caller specifies a call back
|
|
|
|
|
* function that is called when the operation is completed. Currently
|
|
|
|
|
* running operations may be canceled using pa_operation_cancel(). */
|
2004-08-14 20:25:32 +00:00
|
|
|
|
2004-08-17 17:17:22 +00:00
|
|
|
/** \example pacat.c
|
|
|
|
|
* A playback and recording tool using the asynchronous API */
|
2004-08-14 20:25:32 +00:00
|
|
|
|
2004-09-26 22:27:04 +00:00
|
|
|
/** \example paplay.c
|
|
|
|
|
* A sound file playback tool using the asynchronous API, based on libsndfile */
|
|
|
|
|
|
2004-08-17 17:17:22 +00:00
|
|
|
PA_C_DECL_BEGIN
|
2004-08-13 13:22:44 +00:00
|
|
|
|
2006-02-17 00:11:54 +00:00
|
|
|
/** \struct pa_context
|
2004-08-17 17:17:22 +00:00
|
|
|
* An opaque connection context to a daemon */
|
2006-01-11 01:17:39 +00:00
|
|
|
typedef struct pa_context pa_context;
|
2004-08-13 13:22:44 +00:00
|
|
|
|
2006-02-20 16:01:53 +00:00
|
|
|
/** Generic notification callback prototype */
|
|
|
|
|
typedef void (*pa_context_notify_cb_t)(pa_context *c, void *userdata);
|
|
|
|
|
|
|
|
|
|
/** A generic callback for operation completion */
|
|
|
|
|
typedef void (*pa_context_success_cb_t) (pa_context *c, int success, void *userdata);
|
|
|
|
|
|
2004-08-14 20:25:32 +00:00
|
|
|
/** Instantiate a new connection context with an abstract mainloop API
|
|
|
|
|
* and an application name */
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_context *pa_context_new(pa_mainloop_api *mainloop, const char *name);
|
2004-08-14 20:25:32 +00:00
|
|
|
|
|
|
|
|
/** Decrease the reference counter of the context by one */
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_context_unref(pa_context *c);
|
2004-08-14 20:25:32 +00:00
|
|
|
|
|
|
|
|
/** Increase the reference counter of the context by one */
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_context* pa_context_ref(pa_context *c);
|
|
|
|
|
|
2004-08-14 20:25:32 +00:00
|
|
|
/** Set a callback function that is called whenever the context status changes */
|
2006-02-20 16:01:53 +00:00
|
|
|
void pa_context_set_state_callback(pa_context *c, pa_context_notify_cb_t cb, void *userdata);
|
2004-08-13 13:22:44 +00:00
|
|
|
|
2004-08-14 20:25:32 +00:00
|
|
|
/** Return the error number of the last failed operation */
|
2006-01-11 01:17:39 +00:00
|
|
|
int pa_context_errno(pa_context *c);
|
2004-08-13 13:22:44 +00:00
|
|
|
|
2004-08-14 20:25:32 +00:00
|
|
|
/** Return non-zero if some data is pending to be written to the connection */
|
2006-01-11 01:17:39 +00:00
|
|
|
int pa_context_is_pending(pa_context *c);
|
2004-08-13 13:22:44 +00:00
|
|
|
|
2004-08-14 20:25:32 +00:00
|
|
|
/** Return the current context status */
|
2006-01-27 16:25:31 +00:00
|
|
|
pa_context_state_t pa_context_get_state(pa_context *c);
|
2004-08-13 13:22:44 +00:00
|
|
|
|
2004-08-14 20:25:32 +00:00
|
|
|
/** 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
|
2006-02-20 16:10:20 +00:00
|
|
|
be notified when the connection is established. If flags doesn't have
|
|
|
|
|
PA_NOAUTOSPAWN set and no specific server is specified or accessible a
|
|
|
|
|
new daemon is spawned. If api is non-NULL, the functions specified in
|
|
|
|
|
the structure are used when forking a new child process. */
|
|
|
|
|
int pa_context_connect(pa_context *c, const char *server, pa_context_flags_t flags, const pa_spawn_api *api);
|
2004-09-01 21:12:27 +00:00
|
|
|
|
2004-08-14 20:25:32 +00:00
|
|
|
/** Terminate the context connection immediately */
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_context_disconnect(pa_context *c);
|
2004-08-13 13:22:44 +00:00
|
|
|
|
2004-08-14 20:25:32 +00:00
|
|
|
/** Drain the context. If there is nothing to drain, the function returns NULL */
|
2006-02-20 16:01:53 +00:00
|
|
|
pa_operation* pa_context_drain(pa_context *c, pa_context_notify_cb_t cb, void *userdata);
|
2004-08-13 13:22:44 +00:00
|
|
|
|
2004-08-14 20:25:32 +00:00
|
|
|
/** 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. */
|
2006-01-11 01:17:39 +00:00
|
|
|
void pa_context_exit_daemon(pa_context *c);
|
2004-08-13 13:22:44 +00:00
|
|
|
|
2004-09-06 21:55:09 +00:00
|
|
|
/** Set the name of the default sink. \since 0.4 */
|
2006-02-20 16:01:53 +00:00
|
|
|
pa_operation* pa_context_set_default_sink(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata);
|
2004-09-06 21:55:09 +00:00
|
|
|
|
|
|
|
|
/** Set the name of the default source. \since 0.4 */
|
2006-02-20 16:01:53 +00:00
|
|
|
pa_operation* pa_context_set_default_source(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata);
|
2004-09-06 21:55:09 +00:00
|
|
|
|
2004-09-15 19:16:57 +00:00
|
|
|
/** Returns 1 when the connection is to a local daemon. Returns negative when no connection has been made yet. \since 0.5 */
|
2006-01-11 01:17:39 +00:00
|
|
|
int pa_context_is_local(pa_context *c);
|
2004-09-15 19:16:57 +00:00
|
|
|
|
|
|
|
|
/** Set a different application name for context on the server. \since 0.5 */
|
2006-02-20 16:01:53 +00:00
|
|
|
pa_operation* pa_context_set_name(pa_context *c, const char *name, pa_context_success_cb_t cb, void *userdata);
|
2004-09-15 19:16:57 +00:00
|
|
|
|
2004-11-17 00:05:25 +00:00
|
|
|
/** Return the server name this context is connected to. \since 0.7 */
|
2006-01-11 01:17:39 +00:00
|
|
|
const char* pa_context_get_server(pa_context *c);
|
2004-11-17 00:05:25 +00:00
|
|
|
|
2004-08-14 20:25:32 +00:00
|
|
|
PA_C_DECL_END
|
2004-08-13 13:22:44 +00:00
|
|
|
|
|
|
|
|
#endif
|