source: roaraudio/libroarsndio/events.c @ 3790:1ba31162e041

Last change on this file since 3790:1ba31162e041 was 3790:1ba31162e041, checked in by phi, 14 years ago

fixed copyright

File size: 2.6 KB
Line 
1//events.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2010
5 *  The code (may) include prototypes and comments (and maybe
6 *  other code fragements) from EsounD.
7 *  They are mostly copyrighted by Eric B. Mitchell (aka 'Ricdude)
8 *  <ericmit@ix.netcom.com>. For more information see AUTHORS.esd.
9 *
10 *  This file is part of libroaresd 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, 51 Franklin Street, Fifth Floor,
26 *  Boston, MA 02110-1301, USA.
27 *
28 *  NOTE for everyone want's to change something and send patches:
29 *  read README and HACKING! There a addition information on
30 *  the license of this document you need to read before you send
31 *  any patches.
32 */
33
34#define ROAR_USE_OWN_SNDIO_HDL
35#include "libroarsndio.h"
36
37#define _CHECK() if ( hdl == NULL ) return 0
38
39int    sio_nfds   (struct sio_hdl * hdl) {
40#ifdef ROAR_HAVE_H_POLL
41 int fh = -1;
42
43 _CHECK();
44
45 if ( hdl->stream_opened != 1 )
46  return 0;
47
48 if ( roar_vio_ctl(&(hdl->svio), ROAR_VIO_CTL_GET_FH, &fh) == -1 )
49  return 0;
50
51 if ( fh == -1 )
52  return 0;
53
54 return 1;
55#else
56 (void)hdl;
57 return 0;
58#endif
59}
60
61int    sio_pollfd (struct sio_hdl * hdl, struct pollfd * pfd, int events) {
62#ifdef ROAR_HAVE_H_POLL
63 int num;
64 int fh;
65
66 _CHECK();
67
68 if ( (num = sio_nfds(hdl)) == 0 )
69  return 0;
70
71 // not supportet currently:
72 if ( num > 1 )
73  return 0;
74
75 memset(pfd, 0, num*sizeof(struct pollfd));
76
77 // if stream is ok is tested by sio_nfds()
78
79 if ( roar_vio_ctl(&(hdl->svio), ROAR_VIO_CTL_GET_FH, &fh) == -1 )
80  return 0;
81
82 if ( fh == -1 )
83  return 0;
84
85 pfd->fd      = fh;
86 pfd->events  = events;
87 pfd->revents = 0;
88
89 return num;
90#else
91 (void)hdl, (void)pfd, (void)events;
92 return 0;
93#endif
94}
95
96int    sio_revents(struct sio_hdl * hdl, struct pollfd * pfd) {
97#ifdef ROAR_HAVE_H_POLL
98 short revents = 0;
99 int num;
100 int i;
101
102 _CHECK();
103
104 if ( (num = sio_nfds(hdl)) == 0 )
105  return 0;
106
107 for (i = 0; i < num; i++)
108  revents |= pfd[i].revents;
109
110 return revents;
111#else
112 (void)hdl, (void)pfd;
113 return 0;
114#endif
115}
116
117
118//ll
Note: See TracBrowser for help on using the repository browser.