Commit 46db71d6 authored by Tristan Matthews's avatar Tristan Matthews Committed by Rémi Denis-Courmont

jack: don't deactivate/activate client in Flush()

Suspending audio processing in Flush() was breaking playback
for larger values of frames per period. Fixes #8551
Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent e7460479
...@@ -307,8 +307,6 @@ static void Flush(audio_output_t *p_aout, bool wait) ...@@ -307,8 +307,6 @@ static void Flush(audio_output_t *p_aout, bool wait)
{ {
struct aout_sys_t * p_sys = p_aout->sys; struct aout_sys_t * p_sys = p_aout->sys;
jack_ringbuffer_t *rb = p_sys->p_jack_ringbuffer; jack_ringbuffer_t *rb = p_sys->p_jack_ringbuffer;
jack_client_t *client = p_sys->p_jack_client;
int i_error;
/* Sleep if wait was requested */ /* Sleep if wait was requested */
if( wait ) if( wait )
...@@ -318,60 +316,8 @@ static void Flush(audio_output_t *p_aout, bool wait) ...@@ -318,60 +316,8 @@ static void Flush(audio_output_t *p_aout, bool wait)
msleep(delay); msleep(delay);
} }
/* FIXME: maybe the ringbuffer_reset should just be protected by signalling
* with atomic variables?
* Here we save and restore connections, otherwise we'd lose the connections
* every seek because of the deactivate/activate */
/* Save connections */
const char **connections_list[p_sys->i_channels];
for( size_t i = 0; i < p_sys->i_channels; i++ )
{
const char **port_connections = jack_port_get_all_connections( client,
p_sys->p_jack_ports[i] );
connections_list[i] = port_connections;
}
/* Suspend audio processing */
i_error = jack_deactivate( p_sys->p_jack_client );
if( i_error )
{
msg_Err( p_aout, "failed to deactivate JACK client (error %d)",
i_error );
return;
}
/* reset ringbuffer read and write pointers */ /* reset ringbuffer read and write pointers */
jack_ringbuffer_reset(rb); jack_ringbuffer_reset(rb);
/* Resume audio processing */
i_error = jack_activate( p_sys->p_jack_client );
if( i_error )
{
msg_Err( p_aout, "failed to activate JACK client (error %d)", i_error );
return;
}
/* Restore connections */
for( size_t i = 0; i < p_sys->i_channels; i++ )
{
const char **port_connections = connections_list[i];
const char *psz_out = jack_port_name( p_sys->p_jack_ports[i] );
for (const char **psz_in = port_connections; psz_in && *psz_in;
psz_in++)
{
i_error = jack_connect( client, psz_out, *psz_in );
if( i_error )
{
msg_Err( p_aout, "failed to connect ports %s and %s (error %d)",
psz_out, *psz_in, i_error );
}
}
if( port_connections )
jack_free(port_connections);
}
} }
static int TimeGet(audio_output_t *p_aout, mtime_t *delay) static int TimeGet(audio_output_t *p_aout, mtime_t *delay)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment