Changeset 3432:0c3347ed155b in roaraudio for libroarpulse


Ignore:
Timestamp:
02/12/10 15:36:04 (10 years ago)
Author:
phi
Branch:
default
Message:

wrote pa_stream_write()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroarpulse/stream.c

    r3431 r3432  
    214214        pa_free_cb_t free_cb     /**< A cleanup routine for the data or NULL to request an internal copy */, 
    215215        int64_t offset,          /**< Offset for seeking, must be 0 for upload streams */ 
    216         pa_seek_mode_t seek      /**< Seek mode, must be PA_SEEK_RELATIVE for upload streams */); 
     216        pa_seek_mode_t seek      /**< Seek mode, must be PA_SEEK_RELATIVE for upload streams */) { 
     217 struct roar_buffer * buf; 
     218 void               * bufdata; 
     219 
     220 // TODO: implement seeking in output buffer 
     221 
     222 if ( p == NULL ) 
     223  return -1; 
     224 
     225 if ( offset != 0 || seek != PA_SEEK_RELATIVE ) 
     226  return -1; 
     227 
     228 if ( data == NULL ) { 
     229  if ( length == 0 ) { 
     230   if ( free_cb != NULL ) 
     231    free_cb(NULL); 
     232 
     233   return 0; 
     234  } else { 
     235   return -1; 
     236  } 
     237 } 
     238 
     239 // seems we have a valid write from here. 
     240 
     241 if ( roar_buffer_new(&buf, length) == -1 ) { 
     242  if ( free_cb != NULL ) 
     243   free_cb((void*)data); 
     244 
     245  return -1; 
     246 } 
     247 
     248 if ( roar_buffer_get_data(buf, &bufdata) == -1 ) { 
     249  if ( free_cb != NULL ) 
     250   free_cb((void*)data); 
     251 
     252  return -1; 
     253 } 
     254 
     255 memcpy(bufdata, data, length); 
     256 if ( free_cb != NULL ) 
     257  free_cb((void*)data); 
     258 
     259 if ( p->iobuffer == NULL ) { 
     260  p->iobuffer = buf; 
     261 } else { 
     262  if ( roar_buffer_add(p->iobuffer, buf) == -1 ) 
     263   return -1; 
     264 } 
     265 
     266 return 0; 
     267} 
    217268 
    218269/** Read the next fragment from the buffer (for recording). 
Note: See TracChangeset for help on using the changeset viewer.