diff --git a/devices/sound/awacs.cpp b/devices/sound/awacs.cpp index 8fda847..e49b8df 100644 --- a/devices/sound/awacs.cpp +++ b/devices/sound/awacs.cpp @@ -46,14 +46,6 @@ AwacsBase::AwacsBase() this->out_stream_ready = false; } -AwacsBase::~AwacsBase() -{ - // disconnect from SoundServer - if (this->out_stream_ready) { - snd_server->close_out_stream(); - } -} - void AwacsBase::set_sample_rate(int sr_id) { if (sr_id > this->max_sr_id) { diff --git a/devices/sound/awacs.h b/devices/sound/awacs.h index e5e1d0b..eb8a245 100644 --- a/devices/sound/awacs.h +++ b/devices/sound/awacs.h @@ -40,7 +40,7 @@ along with this program. If not, see . class AwacsBase { public: AwacsBase(); - ~AwacsBase(); + ~AwacsBase() = default; void set_dma_out(DmaOutChannel *dma_out_ch) { this->dma_out_ch = dma_out_ch; diff --git a/devices/sound/soundserver.cpp b/devices/sound/soundserver.cpp index c833acc..66091be 100644 --- a/devices/sound/soundserver.cpp +++ b/devices/sound/soundserver.cpp @@ -1,6 +1,6 @@ /* DingusPPC - The Experimental PowerPC Macintosh emulator -Copyright (C) 2018-21 divingkatae and maximum +Copyright (C) 2018-22 divingkatae and maximum (theweirdo) spatium (Contact divingkatae#1017 or powermax#2286 on Discord for more info) @@ -114,8 +114,10 @@ int SoundServer::start() void SoundServer::shutdown() { switch (this->status) { + case SND_STREAM_OPENED: + close_out_stream(); + /* fall through */ case SND_SERVER_UP: - //soundio_device_unref(this->out_device); /* fall through */ case SND_API_READY: cubeb_destroy(this->cubeb_ctx); @@ -203,6 +205,8 @@ int SoundServer::open_out_stream(uint32_t sample_rate, void *user_data) LOG_F(INFO, "Sound output stream opened."); + this->status = SND_STREAM_OPENED; + return 0; } diff --git a/devices/sound/soundserver.h b/devices/sound/soundserver.h index c7ead0b..71f3bed 100644 --- a/devices/sound/soundserver.h +++ b/devices/sound/soundserver.h @@ -41,6 +41,7 @@ enum { SND_SERVER_DOWN = 0, SND_API_READY, SND_SERVER_UP, + SND_STREAM_OPENED };