From a79706df4638e0177b1d26f38e38f3f5609aa411 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 2 Oct 2009 16:49:41 +0000 Subject: Make the ao_alsa play function always process a multiple of ao_data.outburst except for the last chunk. Should fix high CPU usage reported e.g. here: http://bugs.gentoo.org/show_bug.cgi?id=286020 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29748 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/ao_alsa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libao2') diff --git a/libao2/ao_alsa.c b/libao2/ao_alsa.c index 5c4c5c585b..8d2a0510c7 100644 --- a/libao2/ao_alsa.c +++ b/libao2/ao_alsa.c @@ -763,8 +763,11 @@ static void reset(void) static int play(void* data, int len, int flags) { - int num_frames = len / bytes_per_sample; + int num_frames; snd_pcm_sframes_t res = 0; + if (!(flags & AOPLAY_FINAL_CHUNK)) + len = len / ao_data.outburst * ao_data.outburst; + num_frames = len / bytes_per_sample; //mp_msg(MSGT_AO,MSGL_ERR,"alsa-play: frames=%i, len=%i\n",num_frames,len); -- cgit v1.2.3 From 59b6e1393dee644f32db9ee09f03acbe208f41ef Mon Sep 17 00:00:00 2001 From: cladisch Date: Mon, 5 Oct 2009 07:42:02 +0000 Subject: fix calculation of ao_data.bps for sample formats with more than 16 bits git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29750 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/ao_oss.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'libao2') diff --git a/libao2/ao_oss.c b/libao2/ao_oss.c index acfb6db48a..1e369c31a1 100644 --- a/libao2/ao_oss.c +++ b/libao2/ao_oss.c @@ -396,8 +396,19 @@ ac3_retry: } ao_data.bps=ao_data.channels; - if(ao_data.format != AF_FORMAT_U8 && ao_data.format != AF_FORMAT_S8) + switch (ao_data.format & AF_FORMAT_BITS_MASK) { + case AF_FORMAT_8BIT: + break; + case AF_FORMAT_16BIT: ao_data.bps*=2; + break; + case AF_FORMAT_24BIT: + ao_data.bps*=3; + break; + case AF_FORMAT_32BIT: + ao_data.bps*=4; + break; + } ao_data.outburst-=ao_data.outburst % ao_data.bps; // round down ao_data.bps*=ao_data.samplerate; -- cgit v1.2.3