Changeset 664

Show
Ignore:
Timestamp:
12/16/09 16:33:32 (2 years ago)
Author:
erikd
Message:

driver_pulseaudio.c : Handle the case where pa_simple_new() returns NULL.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sweep/trunk/src/driver_pulseaudio.c

    r586 r664  
    122122pulse_read (sw_handle * handle, sw_audio_t * buf, size_t count) 
    123123{ 
     124  struct pa_simple * pa ; 
    124125  int error; 
    125126  size_t byte_count; 
    126127 
     128  if ((pa = (struct pa_simple *)handle->custom_data) == NULL) 
     129    return 0; 
     130 
    127131  byte_count = count * sizeof (sw_audio_t); 
    128132 
    129   if (pa_simple_read((struct pa_simple *)handle->custom_data, buf, byte_count, &error) < 0) { 
     133  if (pa_simple_read(pa, buf, byte_count, &error) < 0) { 
    130134    fprintf(stderr, __FILE__": pa_simple_read() failed: %s\n", pa_strerror(error)); 
    131135    return 0; 
     
    138142    sw_framecount_t offset) 
    139143{ 
     144  struct pa_simple * pa ; 
    140145  int error; 
    141146  size_t byte_count; 
    142147 
     148  if ((pa = (struct pa_simple *)handle->custom_data) == NULL) 
     149    return 0; 
     150 
    143151  byte_count = count * sizeof (sw_audio_t); 
    144152 
    145   if (pa_simple_write((struct pa_simple *)handle->custom_data, buf, byte_count, &error) < 0) { 
     153  if (pa_simple_write(pa, buf, byte_count, &error) < 0) { 
    146154    fprintf(stderr, __FILE__": pa_simple_write() failed: %s\n", pa_strerror(error)); 
    147155    return 0; 
     
    165173pulse_flush (sw_handle * handle) 
    166174{ 
    167   int error; 
    168  
    169   if (pa_simple_flush((struct pa_simple *)handle->custom_data, &error) < 0) { 
     175  struct pa_simple * pa ; 
     176  int error; 
     177 
     178  if ((pa = (struct pa_simple *)handle->custom_data) == NULL) 
     179    return; 
     180 
     181  if (pa_simple_flush(pa, &error) < 0) { 
    170182    fprintf(stderr, __FILE__": pa_simple_flush() failed: %s\n", pa_strerror(error)); 
    171183  } 
     
    175187pulse_drain (sw_handle * handle) 
    176188{ 
    177   int error; 
    178  
    179   if (pa_simple_drain((struct pa_simple *)handle->custom_data, &error) < 0) { 
     189  struct pa_simple * pa ; 
     190  int error; 
     191 
     192  if ((pa = (struct pa_simple *)handle->custom_data) == NULL) 
     193    return; 
     194 
     195  if (pa_simple_drain(pa, &error) < 0) { 
    180196    fprintf(stderr, __FILE__": pa_simple_drain() failed: %s\n", pa_strerror(error)); 
    181197  } 
     
    185201pulse_close (sw_handle * handle) 
    186202{ 
     203  struct pa_simple * pa ; 
     204 
    187205  pulse_drain(handle); 
    188   pa_simple_free((struct pa_simple *)handle->custom_data); 
     206 
     207  if ((pa = (struct pa_simple *)handle->custom_data) == NULL) 
     208    return; 
     209 
     210  pa_simple_free(pa); 
    189211  handle->custom_data = NULL; 
    190212}