From 1395a966d7de7375efad53f6dbbe709a22c307d5 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 13 May 2018 13:47:52 +0200 Subject: Only initialise/deinitialise once. --- src/player.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/player.cc b/src/player.cc index 1181841..af3cd7c 100644 --- a/src/player.cc +++ b/src/player.cc @@ -57,7 +57,12 @@ void Player::run() { Selection sel; - ao_initialize(); + static int init = 0; + if(init == 0) + { + ao_initialize(); + } + ++init; ao_sample_format sf; memset(&sf, 0, sizeof(sf)); @@ -121,7 +126,12 @@ void Player::run() } ao_close(dev); - ao_shutdown(); + + --init; + if(init == 0) + { + ao_shutdown(); + } } bool Player::playSelectionDone() -- cgit v1.2.3