Skip to content

Commit a3bc3a4

Browse files
joevtdingusdev
authored andcommitted
soundserver_cubeb: Set pointers to null after destroy.
This will make the shutdown method reusable.
1 parent 807f961 commit a3bc3a4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

devices/sound/soundserver_cubeb.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,14 @@ void SoundServer::shutdown()
100100
case SND_SERVER_UP:
101101
/* fall through */
102102
case SND_API_READY:
103+
if (!impl->cubeb_ctx)
104+
break;
103105
cubeb_destroy(impl->cubeb_ctx);
106+
impl->cubeb_ctx = nullptr;
104107
break;
105108
case SND_SERVER_DOWN:
106109
// Nothing to do.
107-
break;
110+
return;
108111
}
109112

110113
impl->status = SND_SERVER_DOWN;
@@ -231,6 +234,8 @@ int SoundServer::start_out_stream()
231234

232235
void SoundServer::close_out_stream()
233236
{
237+
if (!impl->out_stream)
238+
return;
234239
if (is_deterministic) {
235240
LOG_F(9, "Stopping sound output deterministic polling.");
236241
TimerManager::get_instance()->cancel_timer(impl->deterministic_poll_timer);
@@ -239,6 +244,7 @@ void SoundServer::close_out_stream()
239244
}
240245
cubeb_stream_stop(impl->out_stream);
241246
cubeb_stream_destroy(impl->out_stream);
247+
impl->out_stream = nullptr;
242248
impl->status = SND_STREAM_CLOSED;
243249
LOG_F(9, "Sound output stream closed.");
244250
}

0 commit comments

Comments
 (0)