Changeset 3869:c63e1367041c in roaraudio for roard/driver_portaudio.c


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

fixed long outstanding Con vs. VIO bug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/driver_portaudio.c

    r3751 r3869  
    3333#ifdef ROAR_HAVE_LIBPABLIO 
    3434 long flags = PABLIO_WRITE; 
     35#elif defined(ROAR_HAVE_LIBPORTAUDIO_V0_19) 
     36 PaError err; 
     37 PaStreamParameters params; 
    3538#endif 
    3639 
     
    102105 
    103106 return 0; 
     107#elif defined(ROAR_HAVE_LIBPORTAUDIO_V0_19) 
     108 params.device                    = Pa_GetDefaultOutputDevice(); 
     109 params.channelCount              = info->channels; 
     110 params.sampleFormat              = fmt; 
     111 params.suggestedLatency          = Pa_GetDeviceInfo(params.device)->defaultLowOutputLatency; 
     112 params.hostApiSpecificStreamInfo = NULL; 
     113 
     114 // TODO: FIXME: use libroar for this. 
     115 self->framesize = info->bits * info->channels / 8; 
     116 
     117 // Sets up blocking I/O stream. 
     118#if 0 
     119 err = Pa_OpenStream(&(self->stream), 
     120                     NULL, 
     121                     &params, 
     122                     info->rate, 
     123                     128 /*FIXME:frames*/, 
     124                     paClipOff, 
     125                     NULL, 
     126                     NULL 
     127                    ); 
     128#endif 
     129 
     130 if ( err != paNoError ) { 
     131  ROAR_ERR("driver_portaudio_open(*): Could not open PortAudio device: \"%s\".", Pa_GetErrorText(err)); 
     132  roar_mm_free(self); 
     133  return -1; 
     134 } 
     135 
     136 err = Pa_StartStream(self->stream); 
     137 
     138 if ( err != paNoError ) { 
     139  ROAR_ERR("driver_portaudio_open(*): Could not start stream: \"%s\".", Pa_GetErrorText(err)); 
     140  roar_mm_free(self); 
     141  return -1; 
     142 } 
     143 
     144 return 0; 
    104145#else 
    105146 return -1; 
     
    110151 struct driver_portaudio * self = vio->inst; 
    111152 
     153 // TODO: cleanup common code. 
     154 
    112155#ifdef ROAR_HAVE_LIBPABLIO 
    113156 CloseAudioStream(self->ostream); 
     
    116159 
    117160 roar_mm_free(self); 
     161 
     162 return 0; 
     163#elif defined(ROAR_HAVE_LIBPORTAUDIO_V0_19) 
     164 if ( (self != NULL) && (self->stream != NULL) ) { 
     165  Pa_StopStream(self->stream); 
     166  Pa_CloseStream(self->stream); 
     167 } 
     168 
     169 roar_mm_free(self); 
     170 
     171 Pa_Terminate(); 
    118172 
    119173 return 0; 
     
    132186 ROAR_DBG("driver_portaudio_write(vio=%p, buf=%p, count=%llu) = ? // PABLIO mode", vio, buf, (long long unsigned int)count); 
    133187 return WriteAudioStream(self->ostream, buf, count) * self->ostream->bytesPerFrame; 
     188#elif defined(ROAR_HAVE_LIBPORTAUDIO_V0_19) 
     189 size_t write_frames = count / self->framesize; 
     190 PaError err; 
     191 
     192 ROAR_DBG("driver_portaudio_write(vio=%p, buf=%p, size=%llu) = ?", vio, buf, (long long unsigned int)size); 
     193 
     194 // I'm not 100% sure if you could write arbitrary number of frames to Pa_WriteStream(), but it seems to be backend dependent. 
     195 err = Pa_WriteStream(self->stream, buf, write_frames); 
     196 
     197 if ( err < 0 && err != paOutputUnderflowed ) 
     198  return -1; 
     199 
     200 // PA always seems to write requested size, or it will error out. 
     201 return count; 
    134202#else 
    135203 return -1; 
Note: See TracChangeset for help on using the changeset viewer.