1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-24 15:52:25 +00:00

This replaces the hardcoded numbers for the sample format widths with a

call to snd_pcm_format_physical_width().


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17571 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
cladisch 2006-02-10 09:18:27 +00:00
parent 3f6e7ce5f5
commit 7bb5f4e138

View File

@ -545,37 +545,9 @@ static int init(int rate_hz, int channels, int format, int flags)
return(0); return(0);
} }
ao_data.bps = ao_data.channels * ao_data.samplerate; bytes_per_sample = snd_pcm_format_physical_width(alsa_format) / 8;
bytes_per_sample *= ao_data.channels;
//setting bw according to the input-format. resolution seems to be always s16_le or ao_data.bps = ao_data.samplerate * bytes_per_sample;
//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 #ifdef BUFFERTIME
{ {