Skip to content

Commit bc81e6e

Browse files
gnifkraxel
authored andcommitted
audio/jack: simplify the re-init code path
Instead of checking for the audodev state in each code path, centralize the check into the initialize function itself to make it safe to call it at any time. Signed-off-by: Geoffrey McRae <[email protected]> Message-id: [email protected] Signed-off-by: Gerd Hoffmann <[email protected]>
1 parent 81e0efb commit bc81e6e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

audio/jackaudio.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ static int qjack_client_init(QJackClient *c)
395395
char client_name[jack_client_name_size()];
396396
jack_options_t options = JackNullOption;
397397

398+
if (c->state == QJACK_STATE_RUNNING) {
399+
return 0;
400+
}
401+
398402
c->connect_ports = true;
399403

400404
snprintf(client_name, sizeof(client_name), "%s-%s",
@@ -485,9 +489,7 @@ static int qjack_init_out(HWVoiceOut *hw, struct audsettings *as,
485489
QJackOut *jo = (QJackOut *)hw;
486490
Audiodev *dev = (Audiodev *)drv_opaque;
487491

488-
if (jo->c.state != QJACK_STATE_DISCONNECTED) {
489-
return 0;
490-
}
492+
qjack_client_fini(&jo->c);
491493

492494
jo->c.out = true;
493495
jo->c.enabled = false;
@@ -523,9 +525,7 @@ static int qjack_init_in(HWVoiceIn *hw, struct audsettings *as,
523525
QJackIn *ji = (QJackIn *)hw;
524526
Audiodev *dev = (Audiodev *)drv_opaque;
525527

526-
if (ji->c.state != QJACK_STATE_DISCONNECTED) {
527-
return 0;
528-
}
528+
qjack_client_fini(&ji->c);
529529

530530
ji->c.out = false;
531531
ji->c.enabled = false;

0 commit comments

Comments
 (0)