1
mirror of https://github.com/mpv-player/mpv synced 2025-01-20 21:07:29 +01:00

reordered bps calculation

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16310 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
henry 2005-08-25 21:46:32 +00:00
parent 4b40fd60f0
commit 99bd394969

View File

@ -284,7 +284,6 @@ static int init(int rate_hz, int channels, int format, int flags)
}
ao_data.samplerate = rate_hz;
ao_data.bps = channels * rate_hz;
ao_data.format = format;
ao_data.channels = channels;
ao_data.outburst = OUTBURST;
@ -330,34 +329,6 @@ static int init(int rate_hz, int channels, int format, int flags)
break;
}
//setting bw according to the input-format. resolution seems to be always s16_le or
//u16_le so 32bit is probably obsolet.
switch(alsa_format)
{
case SND_PCM_FORMAT_S8:
case SND_PCM_FORMAT_U8:
ao_data.bps *= 1;
break;
case SND_PCM_FORMAT_S16_LE:
case SND_PCM_FORMAT_U16_LE:
case SND_PCM_FORMAT_S16_BE:
case SND_PCM_FORMAT_U16_BE:
ao_data.bps *= 2;
break;
case SND_PCM_FORMAT_S32_LE:
case SND_PCM_FORMAT_S32_BE:
case SND_PCM_FORMAT_FLOAT_LE:
ao_data.bps *= 4;
break;
case -1:
mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: invalid format (%s) requested - output disabled\n",af_fmt2str_short(format));
return(0);
break;
default:
ao_data.bps *= 2;
mp_msg(MSGT_AO,MSGL_WARN,"alsa-init: couldn't convert to right format. setting bps to: %d", ao_data.bps);
}
//subdevice parsing
// set defaults
ao_mmap = 0;
@ -537,12 +508,8 @@ static int init(int rate_hz, int channels, int format, int flags)
"alsa-init: format %s are not supported by hardware, trying default\n", af_fmt2str_short(format));
alsa_format = SND_PCM_FORMAT_S16_LE;
ao_data.format = AF_FORMAT_S16_LE;
ao_data.bps = channels * rate_hz * 2;
}
bytes_per_sample = ao_data.bps / ao_data.samplerate; //it should be here
if ((err = snd_pcm_hw_params_set_format(alsa_handler, alsa_hwparams,
alsa_format)) < 0)
{
@ -567,6 +534,38 @@ static int init(int rate_hz, int channels, int format, int flags)
return(0);
}
ao_data.bps = ao_data.channels * ao_data.samplerate;
//setting bw according to the input-format. resolution seems to be always s16_le or
//u16_le so 32bit is probably obsolet.
switch(alsa_format)
{
case SND_PCM_FORMAT_S8:
case SND_PCM_FORMAT_U8:
ao_data.bps *= 1;
break;
case SND_PCM_FORMAT_S16_LE:
case SND_PCM_FORMAT_U16_LE:
case SND_PCM_FORMAT_S16_BE:
case SND_PCM_FORMAT_U16_BE:
ao_data.bps *= 2;
break;
case SND_PCM_FORMAT_S32_LE:
case SND_PCM_FORMAT_S32_BE:
case SND_PCM_FORMAT_FLOAT_LE:
ao_data.bps *= 4;
break;
case -1:
mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: invalid format (%s) requested - output disabled\n",af_fmt2str_short(format));
return(0);
break;
default:
ao_data.bps *= 2;
mp_msg(MSGT_AO,MSGL_WARN,"alsa-init: couldn't convert to right format. setting bps to: %d", ao_data.bps);
}
bytes_per_sample = ao_data.bps / ao_data.samplerate;
#ifdef BUFFERTIME
{
int alsa_buffer_time = 500000; /* original 60 */
@ -661,7 +660,7 @@ static int init(int rate_hz, int channels, int format, int flags)
}
bits_per_sample = snd_pcm_format_physical_width(alsa_format);
bits_per_frame = bits_per_sample * channels;
bits_per_frame = bits_per_sample * ao_data.channels;
chunk_bytes = chunk_size * bits_per_frame / 8;
mp_msg(MSGT_AO,MSGL_V,"alsa-init: bits per sample (bps)=%i, bits per frame (bpf)=%i, chunk_bytes=%i\n",bits_per_sample,bits_per_frame,chunk_bytes);}