Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 512742 | Differences between
and this patch

Collapse All | Expand All

(-)file_not_specified_in_diff (-18 / +23 lines)
Line  Link Here
0
-- TiMidity++-2.14.0/timidity/alsa_a.c
0
++ TiMidity++-2.14.0-alsa/timidity/alsa_a.c
Lines 42-49 Link Here
42
42
43
/*ALSA header file*/
43
/*ALSA header file*/
44
#if HAVE_ALSA_ASOUNDLIB_H
44
#if HAVE_ALSA_ASOUNDLIB_H
45
#define ALSA_PCM_OLD_HW_PARAMS_API
46
#define ALSA_PCM_OLD_SW_PARAMS_API
47
#include <alsa/asoundlib.h>
45
#include <alsa/asoundlib.h>
48
#else
46
#else
49
#include <sys/asoundlib.h>
47
#include <sys/asoundlib.h>
Lines 112-119 static snd_pcm_t* handle = NULL; Link Here
112
static int card = 0;
110
static int card = 0;
113
static int device = 0;
111
static int device = 0;
114
#endif
112
#endif
115
static int total_bytes = -1;
113
static snd_pcm_uframes_t total_bytes = -1;
116
static int frag_size = 0;
114
static snd_pcm_uframes_t frag_size = 0;
117
static int sample_shift = 0;
115
static int sample_shift = 0;
118
static int output_counter;
116
static int output_counter;
119
117
Lines 289-296 static int open_output(void) Link Here
289
{
287
{
290
  int orig_rate = dpm.rate;
288
  int orig_rate = dpm.rate;
291
  int ret_val = 0;
289
  int ret_val = 0;
292
  int tmp, frags, r, pfds;
290
  int frags, r, pfds;
293
  int rate;
291
  int rate;
292
  snd_pcm_uframes_t tmp;
294
  snd_pcm_hw_params_t *pinfo;
293
  snd_pcm_hw_params_t *pinfo;
295
  snd_pcm_sw_params_t *swpinfo;
294
  snd_pcm_sw_params_t *swpinfo;
296
295
Lines 370-386 static int open_output(void) Link Here
370
  }
369
  }
371
370
372
  /*check rate*/
371
  /*check rate*/
373
  r = snd_pcm_hw_params_get_rate_min(pinfo, NULL);
372
  int ok = -1;
374
  if (r >= 0 && r > dpm.rate) {
373
  ok = snd_pcm_hw_params_get_rate_min(pinfo, &r, NULL);
374
  if (ok == 0 && r >= 0 && r > dpm.rate) {
375
    dpm.rate = r;
375
    dpm.rate = r;
376
    ret_val = 1;
376
    ret_val = 1;
377
  }
377
  }
378
  r = snd_pcm_hw_params_get_rate_max(pinfo, NULL);
378
  ok = snd_pcm_hw_params_get_rate_max(pinfo, &r, NULL);
379
  if (r >= 0 && r < dpm.rate) {
379
  if (ok == 0 && r >= 0 && r < dpm.rate) {
380
    dpm.rate = r;
380
    dpm.rate = r;
381
    ret_val = 1;
381
    ret_val = 1;
382
  }
382
  }
383
  if ((rate = snd_pcm_hw_params_set_rate_near(handle, pinfo, dpm.rate, 0)) < 0) {
383
  if (snd_pcm_hw_params_set_rate_near(handle, pinfo, &(dpm.rate), 0) < 0) {
384
    ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
384
    ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
385
	      "ALSA pcm '%s' can't set rate %d",
385
	      "ALSA pcm '%s' can't set rate %d",
386
	      alsa_device_name(), dpm.rate);
386
	      alsa_device_name(), dpm.rate);
Lines 437-443 static int open_output(void) Link Here
437
  ctl->cmsg(CMSG_INFO, VERB_VERBOSE,
437
  ctl->cmsg(CMSG_INFO, VERB_VERBOSE,
438
	    "Requested buffer size %d, fragment size %d",
438
	    "Requested buffer size %d, fragment size %d",
439
	    total_bytes, frag_size);
439
	    total_bytes, frag_size);
440
  if ((tmp = snd_pcm_hw_params_set_buffer_size_near(handle, pinfo, total_bytes >> sample_shift)) < 0) {
440
  tmp = total_bytes >> sample_shift;
441
  if (snd_pcm_hw_params_set_buffer_size_near(handle, pinfo, &tmp) < 0) {
441
    ctl->cmsg(CMSG_WARNING, VERB_NORMAL,
442
    ctl->cmsg(CMSG_WARNING, VERB_NORMAL,
442
	      "ALSA pcm '%s' can't set buffer size %d",
443
	      "ALSA pcm '%s' can't set buffer size %d",
443
	      alsa_device_name(), total_bytes);
444
	      alsa_device_name(), total_bytes);
Lines 445-451 static int open_output(void) Link Here
445
    return -1;
446
    return -1;
446
  }
447
  }
447
448
448
  if ((tmp = snd_pcm_hw_params_set_period_size_near(handle, pinfo, frag_size >> sample_shift, 0)) < 0) {
449
  tmp = frag_size >> sample_shift;
450
  if (snd_pcm_hw_params_set_period_size_near(handle, pinfo, &tmp, 0) < 0) {
449
    ctl->cmsg(CMSG_WARNING, VERB_NORMAL,
451
    ctl->cmsg(CMSG_WARNING, VERB_NORMAL,
450
	      "ALSA pcm '%s' can't set period size %d",
452
	      "ALSA pcm '%s' can't set period size %d",
451
	      alsa_device_name(), frag_size);
453
	      alsa_device_name(), frag_size);
Lines 463-476 static int open_output(void) Link Here
463
    return -1;
465
    return -1;
464
  }
466
  }
465
467
466
  total_bytes = snd_pcm_hw_params_get_buffer_size(pinfo) << sample_shift;
468
  snd_pcm_hw_params_get_buffer_size(pinfo, &total_bytes);
467
  frag_size = snd_pcm_hw_params_get_period_size(pinfo, NULL) << sample_shift;
469
  total_bytes <<= sample_shift;
470
  snd_pcm_hw_params_get_period_size(pinfo, &frag_size, NULL);
471
  frag_size <<= sample_shift;
468
  ctl->cmsg(CMSG_INFO, VERB_VERBOSE,
472
  ctl->cmsg(CMSG_INFO, VERB_VERBOSE,
469
	    "ALSA pcm '%s' set buffer size %d, period size %d bytes",
473
	    "ALSA pcm '%s' set buffer size %d, period size %d bytes",
470
	    alsa_device_name(), total_bytes, frag_size);
474
	    alsa_device_name(), total_bytes, frag_size);
471
  tmp = snd_pcm_hw_params_get_rate(pinfo, NULL);
475
  unsigned int tmp2;  
472
  if (tmp > 0 && tmp != dpm.rate) {
476
  ok = snd_pcm_hw_params_get_rate(pinfo, &tmp2, NULL);
473
    dpm.rate = tmp;
477
  if (ok == 0 && tmp2 > 0 && tmp2 != dpm.rate) {
478
    dpm.rate = tmp2;
474
    ret_val = 1;
479
    ret_val = 1;
475
  }
480
  }
476
  if (orig_rate != dpm.rate) {
481
  if (orig_rate != dpm.rate) {

Return to bug 512742