fix messed up sink cleanup
Some checks are pending
ContinuousDelivery / linux-ubuntu (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / linux (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run

This commit is contained in:
Green Sky 2024-10-05 13:30:47 +02:00
parent ee8604b234
commit 050af74ef2
No known key found for this signature in database

View File

@ -290,18 +290,24 @@ void ToxAVVoIPModel::destroySession(ObjectHandle session) {
_video_sources.erase(it_vsrc); _video_sources.erase(it_vsrc);
} }
} }
if (session.all_of<ToxAVCallAudioSink*>()) { if (session.all_of<Components::ToxAVAudioSink>()) {
std::lock_guard lg{_audio_sinks_mutex}; auto asink = session.get<Components::ToxAVAudioSink>().o;
auto it = std::find(_audio_sinks.cbegin(), _audio_sinks.cend(), session.get<ToxAVCallAudioSink*>()); if (asink.all_of<ToxAVCallAudioSink*>()) {
if (it != _audio_sinks.cend()) { std::lock_guard lg{_audio_sinks_mutex};
_audio_sinks.erase(it); auto it = std::find(_audio_sinks.cbegin(), _audio_sinks.cend(), asink.get<ToxAVCallAudioSink*>());
if (it != _audio_sinks.cend()) {
_audio_sinks.erase(it);
}
} }
} }
if (session.all_of<ToxAVCallVideoSink*>()) { if (session.all_of<Components::ToxAVVideoSink>()) {
std::lock_guard lg{_video_sinks_mutex}; auto vsink = session.get<Components::ToxAVVideoSink>().o;
auto it = std::find(_video_sinks.cbegin(), _video_sinks.cend(), session.get<ToxAVCallVideoSink*>()); if (vsink.all_of<ToxAVCallVideoSink*>()) {
if (it != _video_sinks.cend()) { std::lock_guard lg{_video_sinks_mutex};
_video_sinks.erase(it); auto it = std::find(_video_sinks.cbegin(), _video_sinks.cend(), vsink.get<ToxAVCallVideoSink*>());
if (it != _video_sinks.cend()) {
_video_sinks.erase(it);
}
} }
} }
@ -331,7 +337,7 @@ void ToxAVVoIPModel::destroySession(ObjectHandle session) {
void ToxAVVoIPModel::audio_thread_tick(void) { void ToxAVVoIPModel::audio_thread_tick(void) {
//for (const auto& [oc, asink] : _os.registry().view<ToxAVCallAudioSink*>().each()) { //for (const auto& [oc, asink] : _os.registry().view<ToxAVCallAudioSink*>().each()) {
std::lock_guard lg{_audio_sinks_mutex}; std::lock_guard lg{_audio_sinks_mutex};
for (const auto& asink : _audio_sinks) { for (const auto* asink : _audio_sinks) {
if (!asink->_writer) { if (!asink->_writer) {
continue; continue;
} }
@ -369,7 +375,7 @@ void ToxAVVoIPModel::audio_thread_tick(void) {
void ToxAVVoIPModel::video_thread_tick(void) { void ToxAVVoIPModel::video_thread_tick(void) {
//for (const auto& [oc, vsink] : _os.registry().view<ToxAVCallVideoSink*>().each()) { //for (const auto& [oc, vsink] : _os.registry().view<ToxAVCallVideoSink*>().each()) {
std::lock_guard lg{_video_sinks_mutex}; std::lock_guard lg{_video_sinks_mutex};
for (const auto& vsink : _video_sinks) { for (const auto* vsink : _video_sinks) {
if (!vsink->_writer) { if (!vsink->_writer) {
continue; continue;
} }