Changeset 3439:83fb987c6017 in roaraudio


Ignore:
Timestamp:
02/13/10 13:46:37 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

registzer IO event, still need callback

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroarpulse/stream.c

    r3434 r3439  
    4949 
    5050struct pa_stream { 
    51  size_t refc; 
    52  pa_context * c; 
    53  struct roar_vio_calls vio; 
    54  struct roar_stream stream; 
    55  pa_stream_state_t state; 
    56  pa_sample_spec    sspec; 
    57  struct roar_buffer * iobuffer; 
     51 size_t                  refc; 
     52 pa_context            * c; 
     53 struct roar_vio_calls   vio; 
     54 struct roar_stream      stream; 
     55 pa_stream_state_t       state; 
     56 pa_sample_spec          sspec; 
     57 pa_io_event           * io_event; 
     58 struct roar_buffer    * iobuffer; 
    5859 struct { 
    5960  size_t size; 
     
    178179                                 pa_stream_direction_t dir) { 
    179180 struct roar_connection * con; 
     181 pa_mainloop_api * api; 
     182 pa_io_event_flags_t event_flags = PA_IO_EVENT_HANGUP; 
     183 int fh; 
     184 int ctl = -1; 
    180185 
    181186 if ( s == NULL ) 
     
    195200  case PA_STREAM_PLAYBACK: 
    196201    s->stream.dir = ROAR_DIR_PLAY; 
     202    ctl           = ROAR_VIO_CTL_GET_SELECT_WRITE_FH; 
     203    event_flags  |= PA_IO_EVENT_OUTPUT; 
    197204   break; 
    198205  case PA_STREAM_RECORD: 
    199206    s->stream.dir = ROAR_DIR_MONITOR; 
     207    ctl           = ROAR_VIO_CTL_GET_SELECT_READ_FH; 
     208    event_flags  |= PA_IO_EVENT_INPUT; 
    200209   break; 
    201210  default: 
     
    211220  pa_stream_set_state(s, PA_STREAM_FAILED); 
    212221  return -1; 
     222 } 
     223 
     224 api = roar_pa_context_get_api(s->c); 
     225 
     226 if ( api != NULL && api->io_new != NULL ) { 
     227  if ( roar_vio_ctl(&(s->vio), ctl, &fh) != -1 ) { 
     228   s->io_event = api->io_new(api, fh, event_flags, NULL, s); 
     229  } 
    213230 } 
    214231 
     
    240257/** Disconnect a stream from a source/sink */ 
    241258int pa_stream_disconnect(pa_stream *s) { 
     259 pa_mainloop_api * api; 
     260 
    242261 if ( s == NULL ) 
    243262  return -1; 
     
    245264 if ( s->state != PA_STREAM_READY ) 
    246265  return -1; 
     266 
     267 if ( s->io_event != NULL ) { 
     268  api = roar_pa_context_get_api(s->c); 
     269 
     270  if ( api != NULL && api->io_free != NULL ) { 
     271   api->io_free(s->io_event); 
     272   s->io_event = NULL; 
     273  } 
     274 } 
    247275 
    248276 roar_vio_close(&(s->vio)); 
Note: See TracChangeset for help on using the changeset viewer.