soundserver: shut-down safely.

This commit is contained in:
Maxim Poliakovski 2022-07-17 05:50:32 +02:00
parent c37893847a
commit 5e6f3a51b5
4 changed files with 8 additions and 11 deletions

View File

@ -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) {

View File

@ -40,7 +40,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
class AwacsBase {
public:
AwacsBase();
~AwacsBase();
~AwacsBase() = default;
void set_dma_out(DmaOutChannel *dma_out_ch) {
this->dma_out_ch = dma_out_ch;

View File

@ -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;
}

View File

@ -41,6 +41,7 @@ enum {
SND_SERVER_DOWN = 0,
SND_API_READY,
SND_SERVER_UP,
SND_STREAM_OPENED
};