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,20 +290,26 @@ 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>()) {
auto asink = session.get<Components::ToxAVAudioSink>().o;
if (asink.all_of<ToxAVCallAudioSink*>()) {
std::lock_guard lg{_audio_sinks_mutex}; std::lock_guard lg{_audio_sinks_mutex};
auto it = std::find(_audio_sinks.cbegin(), _audio_sinks.cend(), session.get<ToxAVCallAudioSink*>()); auto it = std::find(_audio_sinks.cbegin(), _audio_sinks.cend(), asink.get<ToxAVCallAudioSink*>());
if (it != _audio_sinks.cend()) { if (it != _audio_sinks.cend()) {
_audio_sinks.erase(it); _audio_sinks.erase(it);
} }
} }
if (session.all_of<ToxAVCallVideoSink*>()) { }
if (session.all_of<Components::ToxAVVideoSink>()) {
auto vsink = session.get<Components::ToxAVVideoSink>().o;
if (vsink.all_of<ToxAVCallVideoSink*>()) {
std::lock_guard lg{_video_sinks_mutex}; std::lock_guard lg{_video_sinks_mutex};
auto it = std::find(_video_sinks.cbegin(), _video_sinks.cend(), session.get<ToxAVCallVideoSink*>()); auto it = std::find(_video_sinks.cbegin(), _video_sinks.cend(), vsink.get<ToxAVCallVideoSink*>());
if (it != _video_sinks.cend()) { if (it != _video_sinks.cend()) {
_video_sinks.erase(it); _video_sinks.erase(it);
} }
} }
}
// destory sources // destory sources
if (auto* ss = session.try_get<Components::VoIP::StreamSources>(); ss != nullptr) { if (auto* ss = session.try_get<Components::VoIP::StreamSources>(); ss != nullptr) {
@ -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;
} }