- Timestamp:
- Apr 5, 2007 11:09:18 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/alsaaudio.c
r1071 r1947 98 98 audfmt_e fmt; 99 99 int nchannels; 100 unsigned intbuffer_size;101 unsigned intperiod_size;100 unsigned long buffer_size; 101 unsigned long period_size; 102 102 }; 103 103 … … 269 269 snd_pcm_t *handle; 270 270 snd_pcm_hw_params_t *hw_params; 271 int err ;271 int err, dir; 272 272 unsigned int freq, nchannels; 273 273 const char *pcm_name = in ? conf.pcm_name_in : conf.pcm_name_out; 274 274 unsigned int period_size, buffer_size; 275 snd_pcm_uframes_t obt_buffer_size; 275 snd_pcm_uframes_t period_size_f, buffer_size_f; 276 snd_pcm_uframes_t obt_buffer_size, obt_period_size; 276 277 const char *typ = in ? "ADC" : "DAC"; 277 278 … … 279 280 period_size = req->period_size; 280 281 buffer_size = req->buffer_size; 282 period_size_f = (snd_pcm_uframes_t)period_size; 283 buffer_size_f = (snd_pcm_uframes_t)buffer_size; 281 284 nchannels = req->nchannels; 282 285 … … 415 418 } 416 419 else { 417 int dir;418 420 snd_pcm_uframes_t minval; 419 421 420 if (period_size ) {421 minval = period_size ;422 if (period_size_f) { 423 minval = period_size_f; 422 424 dir = 0; 423 425 … … 440 442 else { 441 443 dolog("minimal period size %ld\n", minval); 442 if (period_size < minval) {444 if (period_size_f < minval) { 443 445 if ((in && conf.period_size_in_overriden) 444 446 || (!in && conf.period_size_out_overriden)) { … … 446 448 "than minmal period size(%ld)\n", 447 449 typ, 448 period_size ,450 period_size_f, 449 451 minval); 450 452 } 451 period_size = minval;453 period_size_f = minval; 452 454 } 453 455 } … … 457 459 handle, 458 460 hw_params, 459 period_size ,461 period_size_f, 460 462 0 461 463 ); … … 464 466 handle, 465 467 hw_params, 466 (snd_pcm_uframes_t*)&period_size,468 &period_size_f, 467 469 0 468 470 ); 469 471 #endif 470 dolog("PERIOD_SIZE %d\n", period_size );472 dolog("PERIOD_SIZE %d\n", period_size_f); 471 473 if (err < 0) { 472 474 #ifndef VBOX 473 475 alsa_logerr2 (err, typ, "Failed to set period size %d\n", 474 period_size );476 period_size_f); 475 477 #else 476 478 LogRel(("ALSA: Failed to set period size %d (%s)\n", 477 period_size , snd_strerror(err)));479 period_size_f, snd_strerror(err))); 478 480 #endif 479 481 goto err; … … 484 486 /* Calculate default buffer size here since it might have been changed 485 487 * in the _near functions */ 486 buffer_size = 4 * period_size;487 #endif 488 489 minval = buffer_size ;488 buffer_size_f = 4 * period_size_f; 489 #endif 490 491 minval = buffer_size_f; 490 492 err = snd_pcm_hw_params_get_buffer_size_min ( 491 493 hw_params, … … 501 503 } 502 504 else { 503 if (buffer_size < minval) {505 if (buffer_size_f < minval) { 504 506 if ((in && conf.buffer_size_in_overriden) 505 507 || (!in && conf.buffer_size_out_overriden)) { … … 508 510 "than minimal buffer size(%ld)\n", 509 511 typ, 510 buffer_size ,512 buffer_size_f, 511 513 minval 512 514 ); 513 515 } 514 buffer_size = minval;516 buffer_size_f = minval; 515 517 } 516 518 } … … 519 521 handle, 520 522 hw_params, 521 (snd_pcm_uframes_t*)&buffer_size523 &buffer_size_f 522 524 ); 523 dolog("BUFFER_SIZE %d\n", buffer_size );525 dolog("BUFFER_SIZE %d\n", buffer_size_f); 524 526 if (err < 0) { 525 527 #ifndef VBOX 526 528 alsa_logerr2 (err, typ, "Failed to set buffer size %d\n", 527 buffer_size );529 buffer_size_f); 528 530 #else 529 531 LogRel(("ALSA: Failed to set buffer size %d (%s)\n", 530 buffer_size , snd_strerror(err)));532 buffer_size_f, snd_strerror(err))); 531 533 #endif 532 534 goto err; … … 559 561 560 562 #ifdef VBOX 561 LogRel(("ALSA: %s frequency %dHz, period size %d, buffer size %d\n", 562 typ, req->freq, period_size, obt_buffer_size)); 563 dir = 0; 564 err = snd_pcm_hw_params_get_period_size (hw_params, &obt_period_size, &dir); 565 if (err < 0) 566 { 567 LogRel(("ALSA: Failed to get period size\n")); 568 goto err; 569 } 570 LogRel(("ALSA: %s frequency %dHz, period size %ld, buffer size %ld\n", 571 typ, req->freq, obt_period_size, obt_buffer_size)); 563 572 #endif 564 573
Note:
See TracChangeset
for help on using the changeset viewer.