Changeset 7525 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Mar 25, 2008 10:17:49 AM (17 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/audio.c
r6598 r7525 1870 1870 case AUD_MIXER_PCM: 1871 1871 name = "PCM_OUT"; 1872 vol = &pcm_out_volume; 1872 1873 break; 1873 1874 case AUD_MIXER_LINE_IN: -
trunk/src/VBox/Devices/Audio/solaudio.c
r7454 r7525 59 59 } conf = 60 60 { 61 INIT_FIELD (cbBuffer =) 8912,61 INIT_FIELD (cbBuffer =) 4352, 62 62 }; 63 63 … … 123 123 124 124 125 static char *solaudio_getdevice ( )125 static char *solaudio_getdevice (void) 126 126 { 127 127 /* This is for multiple audio devices where env. var determines current one, 128 128 * otherwise else we fallback to default. 129 129 */ 130 c har *pszAudioDev = RTEnvGet("AUDIODEV");130 const char *pszAudioDev = RTEnvGet("AUDIODEV"); 131 131 if (pszAudioDev) 132 132 return RTStrDup(pszAudioDev); … … 141 141 int AudioCtl; 142 142 struct stat FileStat; 143 c onst char *pszAudioDev = NULL;144 c onst char *pszAudioCtl = "/dev/audioctl";143 char *pszAudioDev = NULL; 144 char *pszAudioCtl = NULL; 145 145 audio_info_t AudioInfo; 146 146 … … 149 149 { 150 150 LogRel(("solaudio: solaudio_getdevice() failed to return a valid device.\n")); 151 goto err;151 return -1; 152 152 } 153 153 … … 155 155 { 156 156 LogRel(("solaudio: failed to stat %s\n", pszAudioDev)); 157 goto err ;157 goto err2; 158 158 } 159 159 … … 161 161 { 162 162 LogRel(("solaudio: invalid mode for %s\n", pszAudioDev)); 163 goto err ;163 goto err2; 164 164 } 165 165 … … 168 168 { 169 169 LogRel(("solaudio: failed to open %s\n", pszAudioDev)); 170 goto err; 171 } 172 170 goto err2; 171 } 172 173 RTStrAPrintf(&pszAudioCtl, "%sctl", pszAudioDev); 173 174 AudioCtl = open(pszAudioCtl, O_WRONLY | O_NONBLOCK); 174 175 if (AudioCtl < 0) … … 193 194 AudioInfo.play.buffer_size = info->play.buffer_size; 194 195 AudioInfo.play.gain = AUDIO_MAX_GAIN; 195 AudioInfo.play.balance = AUDIO_MID_BALANCE;196 196 if (ioctl(AudioDev, AUDIO_SETINFO, &AudioInfo) < 0) 197 197 { … … 204 204 *pfd = AudioDev; 205 205 *pctl_fd = AudioCtl; 206 RTStrFree(pszAudioDev); 207 RTStrFree(pszAudioCtl); 206 208 return 0; 207 209 208 210 err: 211 RTStrFree(pszAudioCtl); 212 err2: 209 213 RTStrFree(pszAudioDev); 210 214 return -1; … … 224 228 AudioInfo.play.channels = as->nchannels; 225 229 AudioInfo.play.precision = aud_to_solfmt(as->fmt); 230 #if 0 231 /* Not really needed. */ 232 int cbPerSample = (AudioInfo.play.channels * AudioInfo.play.precision) / 8; 233 int cbPerSecond = cbPerSample * AudioInfo.play.sample_rate; 234 AudioInfo.play.buffer_size = cbPerSecond > 131072 ? conf.cbBuffer : conf.cbBuffer / 2; 235 #endif 226 236 AudioInfo.play.buffer_size = conf.cbBuffer; 237 227 238 if (as->fmt == AUD_FMT_U8) 228 239 AudioInfo.play.encoding = AUDIO_ENCODING_LINEAR8; … … 260 271 static void solaudio_stop (solaudioVoiceOut *sol) 261 272 { 273 audio_info_t AudioInfo; 262 274 LogFlow(("solaudio: stop\n")); 263 275 if (sol->AudioDev < 0 || sol->AudioCtl < 0) … … 269 281 if (ioctl(sol->AudioCtl, I_SETSIG, 0) < 0) 270 282 { 271 Log Rel(("solaudio: failed to stop signalling\n"));283 Log(("solaudio: failed to stop signalling\n")); 272 284 return; 273 285 } … … 275 287 if (ioctl(sol->AudioDev, I_FLUSH, FLUSHW) < 0) 276 288 { 277 Log (("solaudio: failed to drop unplayed buffers\n"));289 LogRel(("solaudio: failed to drop unplayed buffers\n")); 278 290 return; 279 291 } 292 293 AUDIO_INITINFO(&AudioInfo); 294 AudioInfo.play.samples = 0; 295 AudioInfo.play.pause = 0; 296 AudioInfo.play.eof = 0; 297 AudioInfo.play.error = 0; 298 sol->cBuffersPlayed = 0; 299 if (ioctl(sol->AudioDev, AUDIO_SETINFO, &AudioInfo) < 0) 300 { 301 LogRel(("solaudio: AUDIO_SETINFO failed during stop.\n")); 302 return; 303 } 304 } 305 306 307 static void solaudio_fini_out (HWVoiceOut *hw) 308 { 309 solaudioVoiceOut *sol = (solaudioVoiceOut *) hw; 310 solaudio_stop (sol); 280 311 281 312 close(sol->AudioDev); … … 283 314 close(sol->AudioCtl); 284 315 sol->AudioCtl = -1; 285 sol->cBuffersPlayed = 0;286 316 if (sol->pPCMBuf) 287 317 { … … 289 319 sol->pPCMBuf = NULL; 290 320 } 291 } 292 293 294 static void solaudio_fini_out (HWVoiceOut *hw) 295 { 296 solaudioVoiceOut *sol = (solaudioVoiceOut *) hw; 297 solaudio_stop (sol); 321 298 322 LogFlow(("solaudio: fini_out done\n")); 299 323 } … … 312 336 } 313 337 314 cbBuffer = AudioInfo.play.buffer_size * (2 + AudioInfo.play.eof - sol->cBuffersPlayed); 338 if (sol->cBuffersPlayed - AudioInfo.play.eof <= 2) 339 cbBuffer = AudioInfo.play.buffer_size; 315 340 316 341 LogFlow(("avail: eof=%d samples=%d bufsize=%d bufplayed=%d avail=%d\n", AudioInfo.play.eof, AudioInfo.play.samples, … … 328 353 329 354 WaitTimeSpec.tv_sec = 0; 330 WaitTimeSpec.tv_nsec = 1000000 ;331 332 while (AudioInfo.play.eof < pSol->cBuffersPlayed - 2)355 WaitTimeSpec.tv_nsec = 100000000; 356 357 while (AudioInfo.play.eof + 10 < pSol->cBuffersPlayed) 333 358 { 334 359 nanosleep(&WaitTimeSpec, NULL); … … 373 398 break; 374 399 400 /* Increment eof marker for synchronous buffer processed */ 401 write (pSol->AudioDev, NULL, 0); 402 pSol->cBuffersPlayed++; 403 375 404 hw->rpos = (hw->rpos + csToWrite) % hw->samples; 376 405 csSamples -= csToWrite; 377 406 } 378 /* Increment eof marker for synchronous buffer processed */379 write (pSol->AudioDev, NULL, 0);380 pSol->cBuffersPlayed++;381 407 return csDecr; 382 408 } … … 392 418 /* reset the eof marker and samples markers */ 393 419 audio_info_t AudioInfo; 420 LogFlow(("solaudio: voice_enable\n")); 394 421 AUDIO_INITINFO(&AudioInfo); 395 422 ioctl(pSol->AudioDev, AUDIO_GETINFO, &AudioInfo); … … 400 427 401 428 audio_pcm_info_clear_buf(&hw->info, pSol->pPCMBuf, hw->samples); 402 LogFlow(("solaudio: voice_enable\n"));403 429 break; 404 430 } … … 429 455 static void solaudio_audio_fini (void *opaque) 430 456 { 431 (void) opaque; 432 } 433 434 435 static struct audio_pcm_ops solaudio_pcm_ops = { 457 NOREF(opaque); 458 } 459 460 461 static struct audio_pcm_ops solaudio_pcm_ops = 462 { 436 463 solaudio_init_out, 437 464 solaudio_fini_out, … … 447 474 }; 448 475 449 static struct audio_option solaudio_options[] = { 476 static struct audio_option solaudio_options[] = 477 { 450 478 {"BUFFER_SIZE", AUD_OPT_INT, &conf.cbBuffer, 451 479 "Size of the buffer in bytes", NULL, 0}, … … 453 481 }; 454 482 455 struct audio_driver solaudio_audio_driver = { 483 struct audio_driver solaudio_audio_driver = 484 { 456 485 INIT_FIELD (name = ) "solaudio", 457 486 INIT_FIELD (descr = ) "SolarisAudio http://sun.com",
Note:
See TracChangeset
for help on using the changeset viewer.