Changeset 5056:b31e60545552 in roaraudio for roard/driver_portaudio.c
- Timestamp:
- 06/02/11 23:13:11 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/driver_portaudio.c
r5012 r5056 35 35 long flags = PABLIO_WRITE; 36 36 #elif defined(ROAR_HAVE_PA19_VERSION_19) 37 PaStreamParameters params; 38 #endif 37 39 PaError err; 38 PaStreamParameters params; 39 #endif 40 int autoconfig = 0; 40 41 41 42 if ( fh != -1 ) 42 43 return -1; 44 45 if ( sstream != NULL ) { 46 autoconfig = streams_get_flag(ROAR_STREAM(sstream)->id, ROAR_FLAG_AUTOCONF); 47 } 43 48 44 49 switch (info->bits) { … … 56 61 break; 57 62 default: 58 return -1; 63 if ( autoconfig ) { 64 info->codec = ROAR_CODEC_DEFAULT; 65 fmt = paInt8; 66 } else { 67 return -1; 68 } 59 69 break; 60 70 } 61 71 break; 62 72 case 16: 63 if ( info->codec != ROAR_CODEC_DEFAULT ) 64 return -1; 73 if ( info->codec != ROAR_CODEC_DEFAULT ) { 74 if ( autoconfig ) { 75 info->codec = ROAR_CODEC_DEFAULT; 76 } else { 77 return -1; 78 } 79 } 65 80 fmt = paInt16; 66 81 break; 67 82 #ifdef paPackedInt24 68 83 case 24: 69 if ( info->codec != ROAR_CODEC_DEFAULT ) 84 if ( info->codec != ROAR_CODEC_DEFAULT ) { 85 if ( autoconfig ) { 86 info->codec = ROAR_CODEC_DEFAULT; 87 } else { 88 return -1; 89 } 90 } 91 fmt = paPackedInt24; 92 break; 93 #endif 94 case 32: 95 if ( info->codec != ROAR_CODEC_DEFAULT ) { 96 if ( autoconfig ) { 97 info->codec = ROAR_CODEC_DEFAULT; 98 } else { 99 return -1; 100 } 101 } 102 fmt = paInt32; 103 break; 104 default: 105 if ( autoconfig ) { 106 info->codec = ROAR_CODEC_DEFAULT; 107 info->bits = 16; 108 fmt = paInt16; 109 } else { 70 110 return -1; 71 fmt = paPackedInt24; 72 break; 73 #endif 74 case 32: 75 if ( info->codec != ROAR_CODEC_DEFAULT ) 76 return -1; 77 fmt = paInt32; 78 break; 79 default: 80 return -1; 111 } 112 break; 81 113 } 82 114 … … 100 132 case 2: flags |= PABLIO_STEREO; break; 101 133 default: 102 roar_mm_free(self); 103 Pa_Terminate(); 104 return -1; 105 } 106 107 if ( OpenAudioStream(&(self->ostream), info->rate, fmt, flags) != paNoError ) { 134 if ( autoconfig ) { 135 info->channels = 2; 136 flags |= PABLIO_STEREO; 137 } else { 138 roar_mm_free(self); 139 Pa_Terminate(); 140 return -1; 141 } 142 } 143 144 err = OpenAudioStream(&(self->ostream), info->rate, fmt, flags); 145 146 if ( err != paNoError && autoconfig ) { 147 if ( (flags & PABLIO_MONO) == PABLIO_MONO ) { 148 flags -= PABLIO_MONO; 149 flags |= PABLIO_STEREO; 150 info->channels = 2; 151 } 152 fmt = paInt16; 153 info->codec = ROAR_CODEC_DEFAULT; 154 info->bits = 16; 155 156 err = OpenAudioStream(&(self->ostream), info->rate, fmt, flags); 157 } 158 159 if ( err != paNoError ) { 108 160 roar_mm_free(self); 109 161 Pa_Terminate(); … … 133 185 ); 134 186 187 if ( err != paNoError && autoconfig ) { 188 params.sampleFormat = paInt16; 189 params.channelCount = 2; 190 info->codec = ROAR_CODEC_DEFAULT; 191 info->bits = 16; 192 info->channels = 2; 193 194 err = Pa_OpenStream(&(self->stream), 195 NULL, 196 ¶ms, 197 info->rate, 198 128 /*FIXME:frames*/, 199 paClipOff, 200 NULL, 201 NULL 202 ); 203 } 204 135 205 if ( err != paNoError ) { 136 206 ROAR_ERR("driver_portaudio_open(*): Could not open PortAudio device: \"%s\".", Pa_GetErrorText(err));
Note: See TracChangeset
for help on using the changeset viewer.