Changeset 5697:f3a6f503e20e in roaraudio


Ignore:
Timestamp:
10/14/12 00:11:34 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

allow CPI stubs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/scheduler.c

    r5696 r5697  
    5858}; 
    5959 
     60static int __update_cpi_listen_client (struct roar_scheduler * sched, struct roar_scheduler_source * source); 
     61 
    6062struct roar_scheduler * roar_scheduler_new(int flags, enum roar_scheduler_strategy strategy) { 
    6163 struct roar_scheduler * sched = roar_mm_malloc(sizeof(struct roar_scheduler)); 
     
    247249    break; 
    248250   case ROAR_SCHEDULER_CPI_LISTEN: 
    249      ROAR_VIO_SELECT_SETVIO(&(sched->vios[i]), cur->vio, ROAR_VIO_SELECT_READ); 
    250      todo++; 
    251      vios++; 
     251     if ( cur->flags & ROAR_SCHEDULER_FLAG_STUB ) 
     252      __update_cpi_listen_client(sched, cur); 
     253 
     254     if ( !(cur->flags & ROAR_SCHEDULER_FLAG_STUB) ) { 
     255      ROAR_VIO_SELECT_SETVIO(&(sched->vios[i]), cur->vio, ROAR_VIO_SELECT_READ); 
     256      todo++; 
     257      vios++; 
     258     } 
    252259    break; 
    253260   case ROAR_SCHEDULER_CPI_CLIENT: 
    254      tmp = 0; 
    255  
    256      if ( cur->handle.cpi.impl->status != NULL ) { 
    257       if ( cur->lhandle != NULL ) 
    258        roar_dl_context_restore(cur->lhandle); 
    259  
    260       para = roar_dl_getpara(cur->lhandle); 
    261       if ( cur->handle.cpi.impl->status(cur->handle.cpi.client, cur->vio, &(cur->handle.cpi.obuffer), &(cur->handle.cpi.userdata), cur->handle.cpi.protopara, cur->handle.cpi.protoparalen, para) & ROAR_DL_PROTO_STATUS_RX_READY ) 
     261     if ( cur->flags & ROAR_SCHEDULER_FLAG_STUB ) 
     262      __update_cpi_listen_client(sched, cur); 
     263 
     264     if ( !(cur->flags & ROAR_SCHEDULER_FLAG_STUB) ) { 
     265      tmp = 0; 
     266 
     267      if ( cur->handle.cpi.impl->status != NULL ) { 
     268       if ( cur->lhandle != NULL ) 
     269        roar_dl_context_restore(cur->lhandle); 
     270 
     271       para = roar_dl_getpara(cur->lhandle); 
     272       if ( cur->handle.cpi.impl->status(cur->handle.cpi.client, cur->vio, &(cur->handle.cpi.obuffer), &(cur->handle.cpi.userdata), cur->handle.cpi.protopara, cur->handle.cpi.protoparalen, para) & ROAR_DL_PROTO_STATUS_RX_READY ) 
     273        tmp |= ROAR_VIO_SELECT_READ; 
     274       if ( para != NULL ) 
     275        roar_dl_para_unref(para); 
     276 
     277       if ( cur->lhandle != NULL ) 
     278        roar_dl_context_store(cur->lhandle); 
     279      } else { 
    262280       tmp |= ROAR_VIO_SELECT_READ; 
    263       if ( para != NULL ) 
    264        roar_dl_para_unref(para); 
    265  
    266       if ( cur->lhandle != NULL ) 
    267        roar_dl_context_store(cur->lhandle); 
    268      } else { 
    269       tmp |= ROAR_VIO_SELECT_READ; 
    270      } 
    271  
    272      if ( sched->sources[i]->handle.cpi.obuffer != NULL ) 
    273       tmp |= ROAR_VIO_SELECT_WRITE; 
    274  
    275      ROAR_VIO_SELECT_SETVIO(&(sched->vios[i]), sched->sources[i]->vio, tmp); 
    276      todo++; 
    277      vios++; 
     281      } 
     282 
     283      if ( sched->sources[i]->handle.cpi.obuffer != NULL ) 
     284       tmp |= ROAR_VIO_SELECT_WRITE; 
     285 
     286      ROAR_VIO_SELECT_SETVIO(&(sched->vios[i]), sched->sources[i]->vio, tmp); 
     287      todo++; 
     288      vios++; 
     289     } 
    278290    break; 
    279291   case ROAR_SCHEDULER_PLUGIN: 
     
    342354      continue; 
    343355 
     356     if ( cur->flags & ROAR_SCHEDULER_FLAG_STUB ) 
     357      continue; 
     358 
    344359     if ( cur->cb != NULL ) 
    345360      cur->cb(sched->sources[i], sched->sources[i]->userdata, sched->vios[i].eventsa); 
     
    391406   case ROAR_SCHEDULER_CPI_CLIENT: 
    392407     if ( !sched->vios[i].eventsa ) 
     408      continue; 
     409 
     410     if ( cur->flags & ROAR_SCHEDULER_FLAG_STUB ) 
    393411      continue; 
    394412 
     
    572590 } 
    573591 
    574  if ( source->handle.cpi.proto > 0 && source->handle.cpi.impl != NULL ) 
     592 if ( source->handle.cpi.proto > 0 ) { 
     593  source->flags |= ROAR_SCHEDULER_FLAG_STUB; 
     594  if ( source->handle.cpi.impl == NULL ) 
     595   return 0; 
     596  source->flags -= ROAR_SCHEDULER_FLAG_STUB; 
    575597  return 0; 
     598 } 
    576599 
    577600 roar_err_set(ROAR_ERROR_INVAL); 
Note: See TracChangeset for help on using the changeset viewer.