Changeset 3848:b161cd9c3443 in roaraudio for libroarpulse


Ignore:
Timestamp:
05/16/10 22:30:52 (10 years ago)
Author:
phi
Branch:
default
Message:

corrected use of NULL, some better VIO handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroarpulse/simple.c

    r3517 r3848  
    5252    int *error                          /**< A pointer where the error code is stored when the routine returns NULL. It is OK to pass NULL here. */ 
    5353    ) { 
    54  struct roarpulse_simple * s = roar_mm_malloc(sizeof(struct roarpulse_simple)); 
     54 struct roarpulse_simple * s; 
    5555 struct roar_audio_info info; 
    5656 int roar_dir; 
    5757 struct roar_meta meta; 
    58  
    59  if ( !s ) 
    60   return NULL; 
    6158 
    6259 if ( dir == PA_STREAM_PLAYBACK ) { 
     
    6562  roar_dir = ROAR_DIR_RECORD; 
    6663 } else { 
    67   roar_mm_free(s); 
    6864  return NULL; 
    6965 } 
    7066 
    7167 if ( roar_pa_sspec2auinfo(&info, ss) == -1 ) { 
    72   roar_mm_free(s); 
    7368  return NULL; 
    7469 } 
     70 
     71 if ( (s = roar_mm_malloc(sizeof(struct roarpulse_simple))) == NULL ) 
     72  return NULL; 
    7573 
    7674 server = roar_pa_find_server((char*)server); 
     
    8987 } 
    9088 
    91  if ( stream_name && stream_name[0] != 0 ) { 
     89 if ( stream_name != NULL && stream_name[0] != 0 ) { 
    9290  meta.value  = (char*)stream_name; 
    9391  meta.key[0] = 0; 
     
    103101void pa_simple_free(pa_simple *s) { 
    104102 struct roarpulse_simple * ss = (struct roarpulse_simple*) s; 
    105  if ( !s ) 
     103 
     104 if ( s == NULL ) 
    106105  return; 
    107106 
     
    115114int pa_simple_write(pa_simple *s, const void*data, size_t length, int *error) { 
    116115 struct roarpulse_simple * ss = (struct roarpulse_simple*) s; 
    117  if ( !s ) 
     116 
     117 if ( s == NULL ) 
    118118  return -1; 
    119119 
     
    124124int pa_simple_drain(pa_simple *s, int *error) { 
    125125// struct roarpulse_simple * ss = (struct roarpulse_simple*) s; 
    126  if ( !s ) 
     126 
     127 if ( s == NULL ) 
    127128  return -1; 
    128129 
    129  pa_simple_flush(s, NULL); 
     130 pa_simple_flush(s, error); 
    130131 
    131132 return -1; 
     
    135136int pa_simple_read(pa_simple *s, void*data, size_t length, int *error) { 
    136137 struct roarpulse_simple * ss = (struct roarpulse_simple*) s; 
    137  if ( !s ) 
     138 
     139 if ( s == NULL ) 
    138140  return -1; 
    139141 
     
    144146pa_usec_t pa_simple_get_latency(pa_simple *s, int *error) { 
    145147 struct roarpulse_simple * ss = (struct roarpulse_simple*) s; 
    146  if ( !s ) 
     148 
     149 if ( s == NULL ) 
    147150  return -1; 
    148151 
     
    153156int pa_simple_flush(pa_simple *s, int *error) { 
    154157 struct roarpulse_simple * ss = (struct roarpulse_simple*) s; 
    155  if ( !s ) 
     158 
     159 if ( s == NULL ) 
    156160  return -1; 
    157161 
    158 #ifdef ROAR_FDATASYNC 
    159162 return roar_vio_sync(&(ss->vio)); 
    160 #else 
    161  return 0; 
    162 #endif 
    163163} 
    164164 
Note: See TracChangeset for help on using the changeset viewer.