Fix crash/freezing after rendering when using soundio/JACK (#5681)

This commit is contained in:
firewall1110
2020-10-30 06:16:27 +02:00
committed by GitHub
parent ec2e854a47
commit 435dbc5e00
3 changed files with 36 additions and 5 deletions

View File

@@ -110,6 +110,7 @@ private:
fpp_t m_outBufFrameIndex;
bool m_stopped;
bool m_outstreamStarted;
int m_disconnectErr;
void onBackendDisconnect(int err);

View File

@@ -204,6 +204,7 @@ void AudioJack::startProcessing()
{
if( m_active || m_client == NULL )
{
m_stopped = false;
return;
}

View File

@@ -50,6 +50,7 @@ AudioSoundIo::AudioSoundIo( bool & outSuccessful, Mixer * _mixer ) :
m_outBufFrameIndex = 0;
m_outBufFramesTotal = 0;
m_stopped = true;
m_outstreamStarted = 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,28 +212,50 @@ 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_outstreamStarted)
{
if ((err = soundio_outstream_start(m_outstream)))
{
fprintf(stderr,
"AudioSoundIo::startProcessing() :: soundio unable to start stream: %s\n",
soundio_strerror(err));
} else {
m_outstreamStarted = 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 error: %s\n",
soundio_strerror(err));
}
}
void AudioSoundIo::stopProcessing()
{
int err;
m_stopped = true;
if (m_outstream)
{
soundio_outstream_destroy(m_outstream);
m_outstream = NULL;
if (err = soundio_outstream_pause(m_outstream, true))
{
fprintf(stderr,
"AudioSoundIo::stopProcessing() :: pausing result error: %s\n",
soundio_strerror(err));
}
}
if (m_outBuf)