[MPlayer-cvslog] r37600 - trunk/libao2/ao_pulse.c

rtogni subversion at mplayerhq.hu
Thu Jan 21 22:55:36 CET 2016


Author: rtogni
Date: Thu Jan 21 22:55:35 2016
New Revision: 37600

Log:
Fix playback with pulseaudio >= 6.0 and multichannel audio

This fixes the message "pa_stream_write() failed: Invalid argument when
sending audio to pulseaudio" caused by pulseaudio commit:
https://github.com/pulseaudio/pulseaudio/commit/150ace90f3808bbb7240e18a11140d66a7bda146
(stream: Fail on client submitting non-frame-aligned memblocks).

Fixes trac #2241

Patch by Matthew Stapleton on Gentoo's Bugzilla – Bug 549680

Modified:
   trunk/libao2/ao_pulse.c

Modified: trunk/libao2/ao_pulse.c
==============================================================================
--- trunk/libao2/ao_pulse.c	Tue Jan 19 23:02:20 2016	(r37599)
+++ trunk/libao2/ao_pulse.c	Thu Jan 21 22:55:35 2016	(r37600)
@@ -53,6 +53,8 @@ static struct pa_threaded_mainloop *main
 
 static int broken_pause;
 
+static size_t bytes_per_sample;
+
 LIBAO_EXTERN(pulse)
 
 #define GENERIC_ERR_MSG(ctx, str) \
@@ -201,6 +203,8 @@ static int init(int rate_hz, int channel
     }
 
     pa_channel_map_init_auto(&map, ss.channels, PA_CHANNEL_MAP_ALSA);
+    bytes_per_sample = af_fmt2bits(ao_data.format) / 8;
+    bytes_per_sample *= ao_data.channels;
     ao_data.bps = pa_bytes_per_second(&ss);
 
     if (!(mainloop = pa_threaded_mainloop_new())) {
@@ -297,6 +301,11 @@ static void uninit(int immed) {
 
 /** Play the specified data to the pulseaudio server */
 static int play(void* data, int len, int flags) {
+    //Align length to frame size
+    len=len - (len % bytes_per_sample);
+    if (len==0) {
+      return 0;
+    }
     pa_threaded_mainloop_lock(mainloop);
     if (pa_stream_write(stream, data, len, NULL, 0, PA_SEEK_RELATIVE) < 0) {
         GENERIC_ERR_MSG(context, "pa_stream_write() failed");


More information about the MPlayer-cvslog mailing list