Commit f3b5298316aa7885b83d49b6499388189b3e08f7

Authored by malc
1 parent ece43b8d

Emit warning message if user supplied buffer/period size/time was rejected

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4773 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 16 additions and 0 deletions
audio/alsaaudio.c
@@ -334,6 +334,8 @@ static int alsa_open (int in, struct alsa_params_req *req, @@ -334,6 +334,8 @@ static int alsa_open (int in, struct alsa_params_req *req,
334 } 334 }
335 335
336 if (req->buffer_size) { 336 if (req->buffer_size) {
  337 + unsigned long obt;
  338 +
337 if (size_in_usec) { 339 if (size_in_usec) {
338 int dir = 0; 340 int dir = 0;
339 unsigned int btime = req->buffer_size; 341 unsigned int btime = req->buffer_size;
@@ -344,6 +346,7 @@ static int alsa_open (int in, struct alsa_params_req *req, @@ -344,6 +346,7 @@ static int alsa_open (int in, struct alsa_params_req *req,
344 &btime, 346 &btime,
345 &dir 347 &dir
346 ); 348 );
  349 + obt = btime;
347 } 350 }
348 else { 351 else {
349 snd_pcm_uframes_t bsize = req->buffer_size; 352 snd_pcm_uframes_t bsize = req->buffer_size;
@@ -353,15 +356,22 @@ static int alsa_open (int in, struct alsa_params_req *req, @@ -353,15 +356,22 @@ static int alsa_open (int in, struct alsa_params_req *req,
353 hw_params, 356 hw_params,
354 &bsize 357 &bsize
355 ); 358 );
  359 + obt = bsize;
356 } 360 }
357 if (err < 0) { 361 if (err < 0) {
358 alsa_logerr2 (err, typ, "Failed to set buffer %s to %d\n", 362 alsa_logerr2 (err, typ, "Failed to set buffer %s to %d\n",
359 size_in_usec ? "time" : "size", req->buffer_size); 363 size_in_usec ? "time" : "size", req->buffer_size);
360 goto err; 364 goto err;
361 } 365 }
  366 +
  367 + if (obt - req->buffer_size)
  368 + dolog ("Requested buffer %s %u was rejected, using %lu\n",
  369 + size_in_usec ? "time" : "size", req->buffer_size, obt);
362 } 370 }
363 371
364 if (req->period_size) { 372 if (req->period_size) {
  373 + unsigned long obt;
  374 +
365 if (size_in_usec) { 375 if (size_in_usec) {
366 int dir = 0; 376 int dir = 0;
367 unsigned int ptime = req->period_size; 377 unsigned int ptime = req->period_size;
@@ -372,6 +382,7 @@ static int alsa_open (int in, struct alsa_params_req *req, @@ -372,6 +382,7 @@ static int alsa_open (int in, struct alsa_params_req *req,
372 &ptime, 382 &ptime,
373 &dir 383 &dir
374 ); 384 );
  385 + obt = ptime;
375 } 386 }
376 else { 387 else {
377 snd_pcm_uframes_t psize = req->period_size; 388 snd_pcm_uframes_t psize = req->period_size;
@@ -381,6 +392,7 @@ static int alsa_open (int in, struct alsa_params_req *req, @@ -381,6 +392,7 @@ static int alsa_open (int in, struct alsa_params_req *req,
381 hw_params, 392 hw_params,
382 &psize 393 &psize
383 ); 394 );
  395 + obt = psize;
384 } 396 }
385 397
386 if (err < 0) { 398 if (err < 0) {
@@ -388,6 +400,10 @@ static int alsa_open (int in, struct alsa_params_req *req, @@ -388,6 +400,10 @@ static int alsa_open (int in, struct alsa_params_req *req,
388 size_in_usec ? "time" : "size", req->period_size); 400 size_in_usec ? "time" : "size", req->period_size);
389 goto err; 401 goto err;
390 } 402 }
  403 +
  404 + if (obt - req->period_size)
  405 + dolog ("Requested period %s %u was rejected, using %lu\n",
  406 + size_in_usec ? "time" : "size", req->period_size, obt);
391 } 407 }
392 408
393 err = snd_pcm_hw_params (handle, hw_params); 409 err = snd_pcm_hw_params (handle, hw_params);