source: roaraudio/libroarpulse/operation.c @ 3452:3e3d7b1124c2

Last change on this file since 3452:3e3d7b1124c2 was 3400:e2e4250da752, checked in by phi, 14 years ago

support pa_operations

File size: 2.7 KB
Line 
1//operation.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010
5 *  The code (may) include prototypes and comments (and maybe
6 *  other code fragements) from libpulse*. They are mostly copyrighted by:
7 *  Lennart Poettering <poettering@users.sourceforge.net> and
8 *  Pierre Ossman <drzeus@drzeus.cx>
9 *
10 *  This file is part of libroarpulse a part of RoarAudio,
11 *  a cross-platform sound system for both, home and professional use.
12 *  See README for details.
13 *
14 *  This file is free software; you can redistribute it and/or modify
15 *  it under the terms of the GNU General Public License version 3
16 *  as published by the Free Software Foundation.
17 *
18 *  RoarAudio is distributed in the hope that it will be useful,
19 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 *  GNU General Public License for more details.
22 *
23 *  You should have received a copy of the GNU General Public License
24 *  along with this software; see the file COPYING.  If not, write to
25 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 *  NOTE for everyone want's to change something and send patches:
28 *  read README and HACKING! There a addition information on
29 *  the license of this document you need to read before you send
30 *  any patches.
31 *
32 *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
33 *  or libpulse*:
34 *  The libs libroaresd, libroararts and libroarpulse link this libroar
35 *  and are therefore GPL. Because of this it may be illigal to use
36 *  them with any software that uses libesd, libartsc or libpulse*.
37 */
38
39#include <libroarpulse/libroarpulse.h>
40
41/** An asynchronous operation object */
42struct pa_operation {
43 size_t refc;
44 pa_operation_state_t state;
45};
46
47pa_operation *roar_pa_operation_new(pa_operation_state_t initstate) {
48 pa_operation * o = roar_mm_malloc(sizeof(pa_operation));
49
50 if ( o == NULL )
51  return NULL;
52
53 memset(o, 0, sizeof(pa_operation));
54
55 o->refc = 1;
56
57 o->state = initstate;
58
59 return o;
60}
61
62static void _operation_free(pa_operation *o) {
63 roar_mm_free(o);
64}
65
66/** Increase the reference count by one */
67pa_operation *pa_operation_ref(pa_operation *o) {
68 if ( o == NULL )
69  return NULL;
70
71 o->refc++;
72
73 return o;
74}
75
76/** Decrease the reference count by one */
77void pa_operation_unref(pa_operation *o) {
78 if ( o == NULL )
79  return;
80
81 o->refc--;
82
83 if ( o->refc < 1 )
84  _operation_free(o);
85}
86
87/** Cancel the operation. Beware! This will not necessarily cancel the execution of the operation on the server side. */
88void pa_operation_cancel(pa_operation *o) {
89 // we ignore this
90}
91
92/** Return the current status of the operation */
93pa_operation_state_t pa_operation_get_state(pa_operation *o) {
94 if ( o == NULL )
95  return -1;
96
97 return o->state;
98}
99
100//ll
Note: See TracBrowser for help on using the repository browser.