Changeset 3065:fffa0ef8d698 in roaraudio


Ignore:
Timestamp:
12/27/09 23:58:03 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

wrote most of the new proto inst parts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/vio_proto.c

    r1650 r3065  
    150150 
    151151#ifndef ROAR_WITHOUT_VIO_PROTO 
     152ssize_t roar_vio_proto_read    (struct roar_vio_calls * vio, void *buf, size_t count) { 
     153 struct roar_vio_proto * self = vio->inst; 
     154 ssize_t ret; 
     155 ssize_t have = 0; 
     156 size_t  len; 
     157 
     158 if ( self->reader.buffer != NULL ) { 
     159  len = count; 
     160  if ( roar_buffer_shift_out(&(self->reader.buffer), buf, &len) == -1 ) { 
     161   // This is very bad. 
     162   return -1; 
     163  } 
     164 
     165  if ( len ) { 
     166   have   = len; 
     167   buf   += len; 
     168   count -= len; 
     169  } 
     170 } 
     171 
     172 if ( count == 0 ) 
     173  return have; 
     174 
     175 if ( (ret = roar_vio_read(self->next, buf, count)) == -1 ) 
     176  return ret; 
     177 
     178 return have + ret; 
     179} 
     180 
     181ssize_t roar_vio_proto_write   (struct roar_vio_calls * vio, void *buf, size_t count) { 
     182 struct roar_vio_proto * self = vio->inst; 
     183 
     184 return roar_vio_write(self->next, buf, count); 
     185} 
     186 
     187// TODO: this is currently not implemented as this is hard to implement with buffers: 
     188off_t   roar_vio_proto_lseek   (struct roar_vio_calls * vio, off_t offset, int whence); 
     189 
     190int     roar_vio_proto_nonblock(struct roar_vio_calls * vio, int state) { 
     191 struct roar_vio_proto * self = vio->inst; 
     192 
     193 /* we can simply use the next layer's nonblock as all we do in addtion * 
     194  * to call there functions are our buffers which do not block normaly  */ 
     195 
     196 return roar_vio_nonblock(self->next, state); 
     197} 
     198 
     199int     roar_vio_proto_sync    (struct roar_vio_calls * vio) { 
     200 struct roar_vio_proto * self = vio->inst; 
     201 
     202 return roar_vio_sync(self->next); 
     203} 
     204 
     205int     roar_vio_proto_ctl     (struct roar_vio_calls * vio, int cmd, void * data) { 
     206 struct roar_vio_proto * self = vio->inst; 
     207 
     208 if (vio == NULL || cmd == -1) 
     209  return -1; 
     210 
     211 ROAR_DBG("roar_vio_proto_ctl(vio=%p, cmd=0x%.8x, data=%p) = ?", vio, cmd, data); 
     212 
     213 switch (cmd) { 
     214  case ROAR_VIO_CTL_GET_NEXT: 
     215    *(struct roar_vio_calls **)data = self->next; 
     216    return 0; 
     217   break; 
     218  case ROAR_VIO_CTL_SET_NEXT: 
     219    self->next = *(struct roar_vio_calls **)data; 
     220    return 0; 
     221   break; 
     222 } 
     223 
     224 return roar_vio_ctl(self->next, cmd, data); 
     225} 
     226 
     227int     roar_vio_proto_close   (struct roar_vio_calls * vio) { 
     228 struct roar_vio_proto * self = vio->inst; 
     229 
     230 if ( roar_vio_close(self->next) == -1 ) 
     231  return -1; 
     232 
     233 roar_mm_free(self); 
     234 
     235 return 0; 
     236} 
     237 
     238 
    152239int roar_vio_open_proto_http   (struct roar_vio_calls * calls, struct roar_vio_calls * dst, char * host, char * file) { 
    153240 char buf[1024]; 
Note: See TracChangeset for help on using the changeset viewer.