Changeset 2859:277d77b307d5 in roaraudio for libroarsndio


Ignore:
Timestamp:
10/05/09 12:14:54 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added sndio events system

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroarsndio/events.c

    r1571 r2859  
    3434#include "libroarsndio.h" 
    3535 
     36#define _CHECK() if ( hdl == NULL ) return 0 
     37 
    3638int    sio_nfds   (struct sio_hdl * hdl) { 
    37  return 0; 
     39 int fh = -1; 
     40 
     41 _CHECK(); 
     42 
     43 if ( hdl->stream_opened != 1 ) 
     44  return 0; 
     45 
     46 if ( roar_vio_ctl(&(hdl->svio), ROAR_VIO_CTL_GET_FH, &fh) == -1 ) 
     47  return 0; 
     48 
     49 if ( fh == -1 ) 
     50  return 0; 
     51 
     52 return 1; 
    3853} 
    3954 
    4055int    sio_pollfd (struct sio_hdl * hdl, struct pollfd * pfd, int events) { 
    41  return 0; 
     56 int num; 
     57 int fh; 
     58 
     59 _CHECK(); 
     60 
     61 if ( (num = sio_nfds(hdl)) == 0 ) 
     62  return 0; 
     63 
     64 // not supportet currently: 
     65 if ( num > 1 ) 
     66  return 0; 
     67 
     68 memset(pfd, 0, num*sizeof(struct pollfd)); 
     69 
     70 // if stream is ok is tested by sio_nfds() 
     71 
     72 if ( roar_vio_ctl(&(hdl->svio), ROAR_VIO_CTL_GET_FH, &fh) == -1 ) 
     73  return 0; 
     74 
     75 if ( fh == -1 ) 
     76  return 0; 
     77 
     78 pfd->fd      = fh; 
     79 pfd->events  = events; 
     80 pfd->revents = 0; 
     81 
     82 return num; 
    4283} 
    4384 
    4485int    sio_revents(struct sio_hdl * hdl, struct pollfd * pfd) { 
    45  return 0; 
     86 short revents = 0; 
     87 int num; 
     88 int i; 
     89 
     90 _CHECK(); 
     91 
     92 if ( (num = sio_nfds(hdl)) == 0 ) 
     93  return 0; 
     94 
     95 for (i = 0; i < num; i++) 
     96  revents |= pfd[i].revents; 
     97 
     98 return revents; 
    4699} 
    47100 
Note: See TracChangeset for help on using the changeset viewer.