Changeset 787 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Feb 8, 2007 4:34:04 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/alsaaudio.c
r1 r787 44 44 } ALSAVoiceIn; 45 45 46 /* latency = period_size * periods / (rate * bytes_per_frame) */ 47 46 48 static struct { 47 49 int size_in_usec_in; … … 288 290 ); 289 291 if (err < 0) { 292 #ifndef VBOX 290 293 alsa_logerr2 (err, typ, "Failed to open `%s':\n", pcm_name); 294 #else 291 295 LogRel(("Audio/ALSA: Failed to open '%s' as %s\n", pcm_name, typ)); 296 #endif 292 297 return -1; 293 298 } … … 295 300 err = snd_pcm_hw_params_any (handle, hw_params); 296 301 if (err < 0) { 302 #ifndef VBOX 297 303 alsa_logerr2 (err, typ, "Failed to initialize hardware parameters\n"); 304 #else 305 LogRel(("Audio/ALSA: Failed to initialize hardware parameters\n")); 306 #endif 298 307 goto err; 299 308 } … … 305 314 ); 306 315 if (err < 0) { 316 #ifndef VBOX 307 317 alsa_logerr2 (err, typ, "Failed to set access type\n"); 318 #else 319 LogRel(("Audio/ALSA: Failed to set access type\n")); 320 #endif 308 321 goto err; 309 322 } … … 311 324 err = snd_pcm_hw_params_set_format (handle, hw_params, req->fmt); 312 325 if (err < 0) { 326 #ifndef VBOX 313 327 alsa_logerr2 (err, typ, "Failed to set format %d\n", req->fmt); 328 #else 329 LogRel(("Audio/ALSA: Failed to set format %d\n", req->fmt)); 330 #endif 314 331 goto err; 315 332 } … … 317 334 err = snd_pcm_hw_params_set_rate_near (handle, hw_params, &freq, 0); 318 335 if (err < 0) { 336 #ifndef VBOX 319 337 alsa_logerr2 (err, typ, "Failed to set frequency %d\n", req->freq); 338 #else 339 LogRel(("Audio/ALSA: Failed to set frequency %dHz\n", req->freq)); 340 #endif 320 341 goto err; 321 342 } … … 327 348 ); 328 349 if (err < 0) { 350 #ifndef VBOX 329 351 alsa_logerr2 (err, typ, "Failed to set number of channels %d\n", 330 352 req->nchannels); 353 #else 354 LogRel(("Audio/ALSA: Failed to set number of channels to %d\n", req->nchannels)); 355 #endif 331 356 goto err; 332 357 } 333 358 334 359 if (nchannels != 1 && nchannels != 2) { 360 #ifndef VBOX 335 361 alsa_logerr2 (err, typ, 336 362 "Can not handle obtained number of channels %d\n", 337 363 nchannels); 364 #else 365 LogRel(("Audio/ALSA: Cannot handle obtained number of channels (%d)\n", nchannels)); 366 #endif 338 367 goto err; 339 368 } … … 356 385 ); 357 386 if (err < 0) { 387 #ifndef VBOX 358 388 alsa_logerr2 (err, typ, 359 389 "Failed to set period time %d\n", 360 390 req->period_size); 391 #else 392 LogRel(("Audio/ALSA: Failed to set period time %d\n", req->period_size)); 393 #endif 361 394 goto err; 362 395 } … … 371 404 372 405 if (err < 0) { 406 #ifndef VBOX 373 407 alsa_logerr2 (err, typ, 374 408 "Failed to set buffer time %d\n", 375 409 req->buffer_size); 410 #else 411 LogRel(("Audio/ALSA: Failed to set buffer time %d\n", req->buffer_size)); 412 #endif 376 413 goto err; 377 414 } … … 391 428 ); 392 429 if (err < 0) { 430 #ifndef VBOX 393 431 alsa_logerr ( 394 432 err, … … 396 434 typ 397 435 ); 436 #else 437 LogRel(("Audio/ALSA: Could not get minimal period size for %s\n", typ)); 438 #endif 398 439 } 399 440 else { 441 dolog("minimal period size %ld\n", minval); 400 442 if (period_size < minval) { 401 443 if ((in && conf.period_size_in_overriden) … … 411 453 } 412 454 455 #ifndef VBOX 413 456 err = snd_pcm_hw_params_set_period_size ( 414 457 handle, … … 417 460 0 418 461 ); 462 #else 463 err = snd_pcm_hw_params_set_period_size_near ( 464 handle, 465 hw_params, 466 (snd_pcm_uframes_t*)&period_size, 467 0 468 ); 469 #endif 470 dolog("PERIOD_SIZE %d\n", period_size); 419 471 if (err < 0) { 472 #ifndef VBOX 420 473 alsa_logerr2 (err, typ, "Failed to set period size %d\n", 421 req->period_size); 474 period_size); 475 #else 476 LogRel(("Audio/ALSA: Failed to set period size %d (%s)\n", 477 period_size, snd_strerror(err))); 478 #endif 422 479 goto err; 423 480 } 424 481 } 482 483 #ifdef VBOX 484 /* Calculate default buffer size here since it might have been changed 485 * in the _near functions */ 486 buffer_size = 4 * period_size; 487 #endif 425 488 426 489 minval = buffer_size; … … 430 493 ); 431 494 if (err < 0) { 495 #ifndef VBOX 432 496 alsa_logerr (err, "Could not get minmal buffer size for %s\n", 433 497 typ); 498 #else 499 LogRel(("Audio/ALSA: Could not get minimal buffer size for %s\n", typ)); 500 #endif 434 501 } 435 502 else { … … 449 516 } 450 517 451 err = snd_pcm_hw_params_set_buffer_size (518 err = snd_pcm_hw_params_set_buffer_size_near ( 452 519 handle, 453 520 hw_params, 454 buffer_size521 (snd_pcm_uframes_t*)&buffer_size 455 522 ); 523 dolog("BUFFER_SIZE %d\n", buffer_size); 456 524 if (err < 0) { 525 #ifndef VBOX 457 526 alsa_logerr2 (err, typ, "Failed to set buffer size %d\n", 458 req->buffer_size); 527 buffer_size); 528 #else 529 LogRel(("Audio/ALSA: Failed to set buffer size %d (%s)\n", 530 buffer_size, snd_strerror(err))); 531 #endif 459 532 goto err; 460 533 } … … 467 540 err = snd_pcm_hw_params (handle, hw_params); 468 541 if (err < 0) { 542 #ifndef VBOX 469 543 alsa_logerr2 (err, typ, "Failed to apply audio parameters\n"); 544 #else 545 LogRel(("Audio/ALSA: Failed to apply audio parameters\n")); 546 #endif 470 547 goto err; 471 548 } … … 473 550 err = snd_pcm_hw_params_get_buffer_size (hw_params, &obt_buffer_size); 474 551 if (err < 0) { 552 #ifndef VBOX 475 553 alsa_logerr2 (err, typ, "Failed to get buffer size\n"); 554 #else 555 LogRel(("Audio/ALSA: Failed to get buffer size\n")); 556 #endif 476 557 goto err; 477 558 } 559 560 #ifdef VBOX 561 LogRel(("Audio/ALSA: %s frequency %dHz, period size %d, buffer size %d\n", 562 typ, req->freq, period_size, obt_buffer_size)); 563 #endif 478 564 479 565 err = snd_pcm_prepare (handle); … … 619 705 } 620 706 621 #if 0622 mixeng_sniff_and_clear (hw, src, dst, written);623 #endif624 707 rpos = (rpos + written) % hw->samples; 625 708 samples -= written;
Note:
See TracChangeset
for help on using the changeset viewer.