Changeset 3400:e2e4250da752 in roaraudio


Ignore:
Timestamp:
02/11/10 15:55:09 (10 years ago)
Author:
phi
Branch:
default
Message:

support pa_operations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroarpulse/operation.c

    r3398 r3400  
    3939#include <libroarpulse/libroarpulse.h> 
    4040 
     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 
    41100//ll 
Note: See TracChangeset for help on using the changeset viewer.