Changeset 3849:dbd0c483126a in roaraudio for libroaross


Ignore:
Timestamp:
05/16/10 22:32:00 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added support to handle O_NONBLOCK

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroaross/libroaross.c

    r3792 r3849  
    233233}; 
    234234 
     235 
     236static int _update_nonblock (struct handle * handle); 
     237 
    235238static void _init_os (void) { 
    236239 memset(&_os, 0, sizeof(_os)); 
     
    656659 
    657660 _mix_settings.sid.pcm = roar_stream_get_id(&(handle->stream)); 
     661 
     662 _update_nonblock(handle); 
     663 
     664 return 0; 
     665} 
     666 
     667// ------------------------------------- 
     668// function to update O_NONBLOCK: 
     669// ------------------------------------- 
     670 
     671static int _update_nonblock (struct handle * handle) { 
     672 int opened = 0; 
     673 int state  = handle->sysio_flags & O_NONBLOCK ? ROAR_SOCKET_NONBLOCK : ROAR_SOCKET_BLOCK; 
     674 
     675 switch (handle->type) { 
     676  case HT_NONE: 
     677  case HT_STATIC: 
     678  case HT_MIXER: 
     679    // we can ignore setting of nonblock flag here. 
     680    return 0; 
     681   break; 
     682  case HT_VIO: 
     683    opened = 1; 
     684   break; 
     685  case HT_STREAM: 
     686  case HT_WAVEFORM: 
     687  case HT_MIDI: 
     688  case HT_DMX: 
     689    opened = handle->stream_opened; 
     690   break; 
     691 } 
     692 
     693 if ( opened ) { 
     694  return roar_vio_nonblock(&(handle->stream_vio), state); 
     695 } 
    658696 
    659697 return 0; 
     
    16461684    diff  = (int)argl ^ pointer->handle->sysio_flags; 
    16471685    diff &= (int)~(int)(O_DIRECT|O_APPEND|O_LARGEFILE|O_NOATIME|O_NOCTTY|O_TRUNC); 
     1686 
     1687    if ( diff & O_NONBLOCK ) { 
     1688     diff -= O_NONBLOCK; 
     1689     pointer->handle->sysio_flags ^= O_NONBLOCK; 
     1690     if ( _update_nonblock(pointer->handle) == -1 ) { 
     1691      pointer->handle->sysio_flags ^= O_NONBLOCK; 
     1692      return -1; 
     1693     } 
     1694    } 
     1695 
    16481696    if ( diff == 0 ) { // only flags changed we ignore anyway. 
    1649      pointer->handle->sysio_flags = (int)argl; 
     1697     pointer->handle->sysio_flags  = (int)argl; 
    16501698     ret = 0; 
    16511699    } else { 
Note: See TracChangeset for help on using the changeset viewer.