From 88cbddb1b1c7a52d0eb5e9ee4ed920fd940511c0 Mon Sep 17 00:00:00 2001 From: Viktors Date: Sun, 20 Sep 2020 12:26:40 +0300 Subject: [PATCH 1/3] This change FIX Issue #2638 (Crash after rendering when using soundio). --- include/AudioSoundIo.h | 1 + src/core/audio/AudioSoundIo.cpp | 33 ++++++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/include/AudioSoundIo.h b/include/AudioSoundIo.h index 79b586f0645..def8827d473 100644 --- a/include/AudioSoundIo.h +++ b/include/AudioSoundIo.h @@ -110,6 +110,7 @@ class AudioSoundIo : public AudioDevice fpp_t m_outBufFrameIndex; bool m_stopped; + bool m_started; int m_disconnectErr; void onBackendDisconnect(int err); diff --git a/src/core/audio/AudioSoundIo.cpp b/src/core/audio/AudioSoundIo.cpp index 2c3d493a6de..32f19dd62a8 100644 --- a/src/core/audio/AudioSoundIo.cpp +++ b/src/core/audio/AudioSoundIo.cpp @@ -50,6 +50,7 @@ AudioSoundIo::AudioSoundIo( bool & outSuccessful, Mixer * _mixer ) : m_outBufFrameIndex = 0; m_outBufFramesTotal = 0; m_stopped = true; + m_started = false; m_soundio = soundio_create(); if (!m_soundio) @@ -196,6 +197,12 @@ void AudioSoundIo::onBackendDisconnect(int err) AudioSoundIo::~AudioSoundIo() { stopProcessing(); + + if (m_outstream) + { + soundio_outstream_destroy(m_outstream); + } + if (m_soundio) { soundio_destroy(m_soundio); @@ -205,18 +212,34 @@ AudioSoundIo::~AudioSoundIo() void AudioSoundIo::startProcessing() { + int err; + m_outBufFrameIndex = 0; m_outBufFramesTotal = 0; m_outBufSize = mixer()->framesPerPeriod(); m_outBuf = new surroundSampleFrame[m_outBufSize]; + if (! m_started) + { + if ((err = soundio_outstream_start(m_outstream))) + { + fprintf(stderr, + "AudioSoundIo::startProcessing() :: soundio unable to start stream: %s\n", + soundio_strerror(err)); + } else { + m_started = true; + } + } + m_stopped = false; - int err; - if ((err = soundio_outstream_start(m_outstream))) + + if ((err = soundio_outstream_pause(m_outstream, false))) { m_stopped = true; - fprintf(stderr, "soundio unable to start stream: %s\n", soundio_strerror(err)); + fprintf(stderr, + "AudioSoundIo::startProcessing() :: resuming result: %s\n", + soundio_strerror(err)); } } @@ -225,8 +248,8 @@ void AudioSoundIo::stopProcessing() m_stopped = true; if (m_outstream) { - soundio_outstream_destroy(m_outstream); - m_outstream = NULL; + fprintf(stderr, "AudioSoundIo::stopProcessing() :: pausing result: %s\n", + soundio_strerror(soundio_outstream_pause(m_outstream, true))); } if (m_outBuf) From 0d7041f727d7b848a8e9138b500cbf4b28557110 Mon Sep 17 00:00:00 2001 From: Valters Brouns Date: Mon, 21 Sep 2020 09:37:54 +0300 Subject: [PATCH 2/3] This change FIX the issue #5664 "LMMS freezes at 100% on export" (JACK audio) --- src/core/audio/AudioJack.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/audio/AudioJack.cpp b/src/core/audio/AudioJack.cpp index 44ecafa23a0..7e7b703a1a3 100644 --- a/src/core/audio/AudioJack.cpp +++ b/src/core/audio/AudioJack.cpp @@ -204,6 +204,7 @@ void AudioJack::startProcessing() { if( m_active || m_client == NULL ) { + m_stopped = false; return; } From d5103a2623f13069020abec545d31041662c278f Mon Sep 17 00:00:00 2001 From: Valters Brouns Date: Mon, 21 Sep 2020 23:04:41 +0300 Subject: [PATCH 3/3] Better variable name & stderr message only if error. --- include/AudioSoundIo.h | 2 +- src/core/audio/AudioSoundIo.cpp | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/AudioSoundIo.h b/include/AudioSoundIo.h index def8827d473..6a740a02400 100644 --- a/include/AudioSoundIo.h +++ b/include/AudioSoundIo.h @@ -110,7 +110,7 @@ class AudioSoundIo : public AudioDevice fpp_t m_outBufFrameIndex; bool m_stopped; - bool m_started; + bool m_outstreamStarted; int m_disconnectErr; void onBackendDisconnect(int err); diff --git a/src/core/audio/AudioSoundIo.cpp b/src/core/audio/AudioSoundIo.cpp index 32f19dd62a8..b2be4884f93 100644 --- a/src/core/audio/AudioSoundIo.cpp +++ b/src/core/audio/AudioSoundIo.cpp @@ -50,7 +50,7 @@ AudioSoundIo::AudioSoundIo( bool & outSuccessful, Mixer * _mixer ) : m_outBufFrameIndex = 0; m_outBufFramesTotal = 0; m_stopped = true; - m_started = false; + m_outstreamStarted = false; m_soundio = soundio_create(); if (!m_soundio) @@ -220,7 +220,7 @@ void AudioSoundIo::startProcessing() m_outBuf = new surroundSampleFrame[m_outBufSize]; - if (! m_started) + if (! m_outstreamStarted) { if ((err = soundio_outstream_start(m_outstream))) { @@ -228,7 +228,7 @@ void AudioSoundIo::startProcessing() "AudioSoundIo::startProcessing() :: soundio unable to start stream: %s\n", soundio_strerror(err)); } else { - m_started = true; + m_outstreamStarted = true; } } @@ -238,18 +238,24 @@ void AudioSoundIo::startProcessing() { m_stopped = true; fprintf(stderr, - "AudioSoundIo::startProcessing() :: resuming result: %s\n", + "AudioSoundIo::startProcessing() :: resuming result error: %s\n", soundio_strerror(err)); } } void AudioSoundIo::stopProcessing() { + int err; + m_stopped = true; if (m_outstream) { - fprintf(stderr, "AudioSoundIo::stopProcessing() :: pausing result: %s\n", - soundio_strerror(soundio_outstream_pause(m_outstream, true))); + if (err = soundio_outstream_pause(m_outstream, true)) + { + fprintf(stderr, + "AudioSoundIo::stopProcessing() :: pausing result error: %s\n", + soundio_strerror(err)); + } } if (m_outBuf)