Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit 2eb65f4

Browse files
authored
Fix active audio stream issue (#824)
1 parent 070d01c commit 2eb65f4

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

source/agent/audio/activeAudioSelector.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ class ActiveAudioSelector extends EventEmitter {
9797
getOutputs() {
9898
return this.topK;
9999
}
100+
101+
close() {}
100102
}
101103

102104
exports.ActiveAudioSelector = ActiveAudioSelector;

source/agent/conference/conference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1903,7 +1903,7 @@ var Conference = function (rpcClient, selfRpcId) {
19031903
if (streams[activeAudioId] instanceof SelectedStream) {
19041904
if (streams[activeAudioId].info.activeInput !== input) {
19051905
streams[activeAudioId].info.activeInput = input;
1906-
streams[activeAudioId].info.owner = target.owner;
1906+
streams[activeAudioId].info.activeOwner = target.owner;
19071907
room_config.notifying.streamChange &&
19081908
sendMsg('room', 'all', 'stream',
19091909
{id: activeAudioId, status: 'update', data: {field: 'activeInput', value: input}});

source/core/owt_base/selector/AudioRanker.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "AudioRanker.h"
66
#include <chrono>
7+
#include <future>
78

89
namespace owt_base {
910

@@ -28,6 +29,9 @@ AudioRanker::AudioRanker(AudioRanker::Visitor* visitor, bool detectMute, uint32_
2829

2930
AudioRanker::~AudioRanker()
3031
{
32+
m_service->service().dispatch([this]() {
33+
m_processors.clear();
34+
});
3135
}
3236

3337
void AudioRanker::addOutput(FrameDestination* output)
@@ -86,9 +90,11 @@ void AudioRanker::addInput(FrameSource* input, std::string streamId, std::string
8690
void AudioRanker::removeInput(std::string streamId)
8791
{
8892
ELOG_DEBUG("removeInput: %s", streamId.c_str());
89-
m_service->service().dispatch([this, streamId]() {
93+
auto promise = std::make_shared<std::promise<void>>();
94+
m_service->service().dispatch([this, streamId, promise]() {
9095
if (m_processors.count(streamId) == 0) {
9196
// Not exist
97+
promise->set_value();
9298
return;
9399
}
94100
auto audioProc = m_processors[streamId];
@@ -102,7 +108,13 @@ void AudioRanker::removeInput(std::string streamId)
102108
// Remove in others
103109
m_others.erase(audioProc->iter());
104110
}
111+
audioProc.reset();
112+
promise->set_value();
105113
});
114+
std::chrono::milliseconds span (1000);
115+
if (promise->get_future().wait_for(span) == std::future_status::timeout) {
116+
ELOG_WARN("removeInput timeout: %s", streamId.c_str());
117+
}
106118
}
107119

108120
void AudioRanker::updateInput(std::string streamId, int level)

0 commit comments

Comments
 (0)