Changeset 5276:0eb24ca6810e in roaraudio for libroar/vio_pipe.c
- Timestamp:
- 11/20/11 18:36:49 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroar/vio_pipe.c
r5270 r5276 119 119 #ifndef ROAR_WITHOUT_VIO_PIPE 120 120 int roar_vio_pipe_init (struct roar_vio_calls * s, struct roar_vio_pipe * self, int flags) { 121 int nonblock = ROAR_SOCKET_NONBLOCK; 122 121 123 if ( s == NULL || self == NULL ) 122 124 return -1; … … 127 129 s->read = roar_vio_pipe_read; 128 130 s->write = roar_vio_pipe_write; 129 s->nonblock = roar_vio_pipe_nonblock;130 131 s->sync = roar_vio_pipe_sync; 131 132 … … 133 134 134 135 if ( flags & O_NONBLOCK ) { 135 roar_vio_pipe_ nonblock(s, ROAR_SOCKET_NONBLOCK);136 roar_vio_pipe_ctl(s, ROAR_VIO_CTL_NONBLOCK, &nonblock); 136 137 } 137 138 … … 187 188 } 188 189 189 int roar_vio_pipe_nonblock(struct roar_vio_calls * vio, int state) {190 struct roar_vio_pipe * self;191 192 if ( vio == NULL )193 return -1;194 195 if ( (self = (struct roar_vio_pipe *)vio->inst) == NULL )196 return -1;197 198 switch (self->type) {199 case ROAR_VIO_PIPE_TYPE_PIPE:200 if ( roar_socket_nonblock(self->b.p[ROAR_VIO_PIPE_S(self,vio)*2], state) == -1 )201 return -1;202 return roar_socket_nonblock(self->b.p[(ROAR_VIO_PIPE_SR(self,vio)*2)+1], state);203 break;204 #ifdef ROAR_HAVE_UNIX205 case ROAR_VIO_PIPE_TYPE_SOCKET:206 return roar_socket_nonblock(self->b.p[ROAR_VIO_PIPE_S(self,vio)], state);207 break;208 #endif209 }210 211 return -1;212 }213 214 190 int roar_vio_pipe_sync (struct roar_vio_calls * vio) { 215 191 // we may add fdatasync() calls here depending on the type … … 276 252 return 0; 277 253 break; 254 } 255 break; 256 case ROAR_VIO_CTL_NONBLOCK: 257 switch (self->type) { 258 case ROAR_VIO_PIPE_TYPE_PIPE: 259 if ( roar_socket_nonblock(self->b.p[ROAR_VIO_PIPE_S(self,vio)*2], *(int*)data) == -1 ) 260 return -1; 261 return roar_socket_nonblock(self->b.p[(ROAR_VIO_PIPE_SR(self,vio)*2)+1], *(int*)data); 262 break; 263 #ifdef ROAR_HAVE_UNIX 264 case ROAR_VIO_PIPE_TYPE_SOCKET: 265 return roar_socket_nonblock(self->b.p[ROAR_VIO_PIPE_S(self,vio)], *(int*)data); 266 break; 267 #endif 278 268 } 279 269 break;
Note: See TracChangeset
for help on using the changeset viewer.