Documentation work
[platform/upstream/pulseaudio.git] / polyp / polyplib-def.h
1 #ifndef foopolyplibdefhfoo
2 #define foopolyplibdefhfoo
3
4 /* $Id$ */
5
6 /***
7   This file is part of polypaudio.
8  
9   polypaudio is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published
11   by the Free Software Foundation; either version 2 of the License,
12   or (at your option) any later version.
13  
14   polypaudio is distributed in the hope that it will be useful, but
15   WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   General Public License for more details.
18  
19   You should have received a copy of the GNU General Public License
20   along with polypaudio; if not, write to the Free Software
21   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22   USA.
23 ***/
24
25 #include <inttypes.h>
26 #include "cdecl.h"
27
28 /** \file
29  * Global definitions */
30
31 PA_C_DECL_BEGIN
32
33 /** The state of a connection context */
34 enum pa_context_state {
35     PA_CONTEXT_UNCONNECTED,    /**< The context hasn't been connected yet */
36     PA_CONTEXT_CONNECTING,     /**< A connection is being established */
37     PA_CONTEXT_AUTHORIZING,    /**< The client is authorizing itself to the daemon */
38     PA_CONTEXT_SETTING_NAME,   /**< The client is passing its application name to the daemon */
39     PA_CONTEXT_READY,          /**< The connection is established, the context is ready to execute operations */
40     PA_CONTEXT_FAILED,         /**< The connection failed or was disconnected */
41     PA_CONTEXT_TERMINATED      /**< The connection was terminated cleanly */
42 };
43
44 /** The state of a stream */
45 enum pa_stream_state {
46     PA_STREAM_DISCONNECTED, /**< The stream is not yet connected to any sink or source */
47     PA_STREAM_CREATING,     /**< The stream is being created */
48     PA_STREAM_READY,        /**< The stream is established, you may pass audio data to it now */
49     PA_STREAM_FAILED,       /**< An error occured that made the stream invalid */
50     PA_STREAM_TERMINATED,   /**< The stream has been terminated cleanly */
51 };
52
53 /** The state of an operation */
54 enum pa_operation_state {
55     PA_OPERATION_RUNNING,      /**< The operation is still running */
56     PA_OPERATION_DONE,         /**< The operation has been completed */
57     PA_OPERATION_CANCELED,     /**< The operation has been canceled */
58 };
59
60 /** An invalid index */
61 #define PA_INVALID_INDEX ((uint32_t) -1)
62
63 /** The direction of a pa_stream object */ 
64 enum pa_stream_direction {
65     PA_STREAM_NODIRECTION,   /**< Invalid direction */
66     PA_STREAM_PLAYBACK,      /**< Playback stream */
67     PA_STREAM_RECORD,        /**< Record stream */
68     PA_STREAM_UPLOAD         /**< Sample upload stream */
69 };
70
71 /** Playback and record buffer metrics */
72 struct pa_buffer_attr{
73     uint32_t maxlength;      /**< Maximum length of the buffer */
74     uint32_t tlength;        /**< Playback only: target length of the buffer. The server tries to assure that at least tlength bytes are always available in the buffer */
75     uint32_t prebuf;         /**< Playback only: pre-buffering. The server does not start with playback before at least prebug bytes are available in the buffer */
76     uint32_t minreq;         /**< Playback only: minimum request. The server does not request less than minreq bytes from the client, instead waints until the buffer is free enough to request more bytes at once */
77     uint32_t fragsize;       /**< Recording only: fragment size. The server sends data in blocks of fragsize bytes size. Large values deminish interactivity with other operations on the connection context but decrease control overhead. */
78 };
79
80 /** Error values as used by pa_context_errno(). Use pa_strerror() to convert these values to human readable strings */
81 enum {
82     PA_ERROR_OK,                     /**< No error */
83     PA_ERROR_ACCESS,                 /**< Access failure */
84     PA_ERROR_COMMAND,                /**< Unknown command */
85     PA_ERROR_INVALID,                /**< Invalid argument */
86     PA_ERROR_EXIST,                  /**< Entity exists */
87     PA_ERROR_NOENTITY,               /**< No such entity */
88     PA_ERROR_CONNECTIONREFUSED,      /**< Connection refused */
89     PA_ERROR_PROTOCOL,               /**< Protocol error */ 
90     PA_ERROR_TIMEOUT,                /**< Timeout */
91     PA_ERROR_AUTHKEY,                /**< No authorization key */
92     PA_ERROR_INTERNAL,               /**< Internal error */
93     PA_ERROR_CONNECTIONTERMINATED,   /**< Connection terminated */
94     PA_ERROR_KILLED,                 /**< Entity killed */
95     PA_ERROR_INVALIDSERVER,          /**< Invalid server */
96     PA_ERROR_MAX                     /**< Not really an error but the first invalid error code */
97 };
98
99 /** Subscription event mask, as used by pa_context_subscribe() */
100 enum pa_subscription_mask {
101     PA_SUBSCRIPTION_MASK_NULL = 0,               /**< No events */
102     PA_SUBSCRIPTION_MASK_SINK = 1,               /**< Sink events */
103     PA_SUBSCRIPTION_MASK_SOURCE = 2,             /**< Source events */
104     PA_SUBSCRIPTION_MASK_SINK_INPUT = 4,         /**< Sink input events */
105     PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT = 8,      /**< Source output events */
106     PA_SUBSCRIPTION_MASK_MODULE = 16,            /**< Module events */
107     PA_SUBSCRIPTION_MASK_CLIENT = 32,            /**< Client events */
108     PA_SUBSCRIPTION_MASK_SAMPLE_CACHE = 64,      /**< Sample cache events */
109 };
110
111 /** Subscription event types, as used by pa_context_subscribe() */
112 enum pa_subscription_event_type {
113     PA_SUBSCRIPTION_EVENT_SINK = 0,           /**< Event type: Sink */
114     PA_SUBSCRIPTION_EVENT_SOURCE = 1,         /**< Event type: Source */
115     PA_SUBSCRIPTION_EVENT_SINK_INPUT = 2,     /**< Event type: Sink input */
116     PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT = 3,  /**< Event type: Source output */
117     PA_SUBSCRIPTION_EVENT_MODULE = 4,         /**< Event type: Module */
118     PA_SUBSCRIPTION_EVENT_CLIENT = 5,         /**< Event type: Client */
119     PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE = 6,   /**< Event type: Sample cache item */
120     PA_SUBSCRIPTION_EVENT_FACILITY_MASK = 7,  /**< A mask to extract the event type from an event value */
121
122     PA_SUBSCRIPTION_EVENT_NEW = 0,            /**< A new object was created */
123     PA_SUBSCRIPTION_EVENT_CHANGE = 16,        /**< A property of the object was modified */
124     PA_SUBSCRIPTION_EVENT_REMOVE = 32,        /**< An object was removed */
125     PA_SUBSCRIPTION_EVENT_TYPE_MASK = 16+32,  /**< A mask to extract the event operation from an event value */
126 };
127
128 /** Return one if an event type t matches an event mask bitfield */
129 #define pa_subscription_match_flags(m, t) (!!((m) & (1 << ((t) & PA_SUBSCRIPTION_EVENT_FACILITY_MASK))))
130
131 PA_C_DECL_END
132
133 #endif