From: Oron Peled Date: Tue, 19 Dec 2017 08:52:54 +0000 (+0200) Subject: chan_console: don't read and write at the same time X-Git-Tag: 13.20.0-rc1~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0fc3e831a7dd7db8c314bc5a43a1782ba58e0763;p=thirdparty%2Fasterisk.git chan_console: don't read and write at the same time It seems that the ALSA backend of PortAudio doesn't know how to both read and write at the same time by adding a per-device mutex. FIXME: currently only a draft version. Need to either auto-detect we work with the ALSA backend or add an extra configuration option to use this mutex. ASTERISK-27426 #close Change-Id: I635eacee45f5413faa18f5a3b606af03b926dacb --- diff --git a/channels/chan_console.c b/channels/chan_console.c index bc5f7f2fed..f09694bcf4 100644 --- a/channels/chan_console.c +++ b/channels/chan_console.c @@ -280,7 +280,9 @@ static void *stream_monitor(void *data) for (;;) { pthread_testcancel(); + console_pvt_lock(pvt); res = Pa_ReadStream(pvt->stream, buf, sizeof(buf) / sizeof(int16_t)); + console_pvt_unlock(pvt); pthread_testcancel(); if (!pvt->owner) { @@ -613,7 +615,9 @@ static int console_write(struct ast_channel *chan, struct ast_frame *f) { struct console_pvt *pvt = ast_channel_tech_pvt(chan); + console_pvt_lock(pvt); Pa_WriteStream(pvt->stream, f->data.ptr, f->samples); + console_pvt_unlock(pvt); return 0; }