Remove usage of rtc::MessageHandler in pc/remote_audio_source
Bug: webrtc:9702 Change-Id: Ibef43b8c1b61afe4cf4e79a7c6549af6d5bff93f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272546 Reviewed-by: Florent Castelli <orphis@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37859}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
cca4832042
commit
c6c346da61
@ -1854,14 +1854,13 @@ rtc_library("remote_audio_source") {
|
||||
"../api:media_stream_interface",
|
||||
"../api:scoped_refptr",
|
||||
"../api:sequence_checker",
|
||||
"../api/task_queue",
|
||||
"../media:rtc_media_base",
|
||||
"../rtc_base",
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base:location",
|
||||
"../rtc_base:logging",
|
||||
"../rtc_base:safe_conversions",
|
||||
"../rtc_base:stringutils",
|
||||
"../rtc_base:threading",
|
||||
"../rtc_base/synchronization:mutex",
|
||||
]
|
||||
absl_deps = [
|
||||
|
@ -14,15 +14,15 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "api/sequence_checker.h"
|
||||
#include "api/task_queue/task_queue_base.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/location.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/strings/string_format.h"
|
||||
#include "rtc_base/thread.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -51,9 +51,9 @@ class RemoteAudioSource::AudioDataProxy : public AudioSinkInterface {
|
||||
};
|
||||
|
||||
RemoteAudioSource::RemoteAudioSource(
|
||||
rtc::Thread* worker_thread,
|
||||
TaskQueueBase* worker_thread,
|
||||
OnAudioChannelGoneAction on_audio_channel_gone_action)
|
||||
: main_thread_(rtc::Thread::Current()),
|
||||
: main_thread_(TaskQueueBase::Current()),
|
||||
worker_thread_(worker_thread),
|
||||
on_audio_channel_gone_action_(on_audio_channel_gone_action),
|
||||
state_(MediaSourceInterface::kInitializing) {
|
||||
@ -163,24 +163,18 @@ void RemoteAudioSource::OnAudioChannelGone() {
|
||||
if (on_audio_channel_gone_action_ != OnAudioChannelGoneAction::kEnd) {
|
||||
return;
|
||||
}
|
||||
// Called when the audio channel is deleted. It may be the worker thread
|
||||
// in libjingle or may be a different worker thread.
|
||||
// This object needs to live long enough for the cleanup logic in OnMessage to
|
||||
// run, so take a reference to it as the data. Sometimes the message may not
|
||||
// be processed (because the thread was destroyed shortly after this call),
|
||||
// but that is fine because the thread destructor will take care of destroying
|
||||
// the message data which will release the reference on RemoteAudioSource.
|
||||
main_thread_->Post(RTC_FROM_HERE, this, 0,
|
||||
new rtc::ScopedRefMessageData<RemoteAudioSource>(this));
|
||||
}
|
||||
|
||||
void RemoteAudioSource::OnMessage(rtc::Message* msg) {
|
||||
RTC_DCHECK_RUN_ON(main_thread_);
|
||||
sinks_.clear();
|
||||
SetState(MediaSourceInterface::kEnded);
|
||||
// Will possibly delete this RemoteAudioSource since it is reference counted
|
||||
// in the message.
|
||||
delete msg->pdata;
|
||||
// Called when the audio channel is deleted. It may be the worker thread or
|
||||
// may be a different task queue.
|
||||
// This object needs to live long enough for the cleanup logic in the posted
|
||||
// task to run, so take a reference to it. Sometimes the task may not be
|
||||
// processed (because the task queue was destroyed shortly after this call),
|
||||
// but that is fine because the task queue destructor will take care of
|
||||
// destroying task which will release the reference on RemoteAudioSource.
|
||||
rtc::scoped_refptr<RemoteAudioSource> thiz(this);
|
||||
main_thread_->PostTask([thiz = std::move(thiz)] {
|
||||
thiz->sinks_.clear();
|
||||
thiz->SetState(MediaSourceInterface::kEnded);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -20,24 +20,16 @@
|
||||
#include "api/call/audio_sink.h"
|
||||
#include "api/media_stream_interface.h"
|
||||
#include "api/notifier.h"
|
||||
#include "api/task_queue/task_queue_base.h"
|
||||
#include "media/base/media_channel.h"
|
||||
#include "rtc_base/message_handler.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "rtc_base/thread.h"
|
||||
#include "rtc_base/thread_message.h"
|
||||
|
||||
namespace rtc {
|
||||
struct Message;
|
||||
class Thread;
|
||||
} // namespace rtc
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// This class implements the audio source used by the remote audio track.
|
||||
// This class works by configuring itself as a sink with the underlying media
|
||||
// engine, then when receiving data will fan out to all added sinks.
|
||||
class RemoteAudioSource : public Notifier<AudioSourceInterface>,
|
||||
rtc::MessageHandler {
|
||||
class RemoteAudioSource : public Notifier<AudioSourceInterface> {
|
||||
public:
|
||||
// In Unified Plan, receivers map to m= sections and their tracks and sources
|
||||
// survive SSRCs being reconfigured. The life cycle of the remote audio source
|
||||
@ -52,7 +44,7 @@ class RemoteAudioSource : public Notifier<AudioSourceInterface>,
|
||||
};
|
||||
|
||||
explicit RemoteAudioSource(
|
||||
rtc::Thread* worker_thread,
|
||||
TaskQueueBase* worker_thread,
|
||||
OnAudioChannelGoneAction on_audio_channel_gone_action);
|
||||
|
||||
// Register and unregister remote audio source with the underlying media
|
||||
@ -85,10 +77,8 @@ class RemoteAudioSource : public Notifier<AudioSourceInterface>,
|
||||
void OnData(const AudioSinkInterface::Data& audio);
|
||||
void OnAudioChannelGone();
|
||||
|
||||
void OnMessage(rtc::Message* msg) override;
|
||||
|
||||
rtc::Thread* const main_thread_;
|
||||
rtc::Thread* const worker_thread_;
|
||||
TaskQueueBase* const main_thread_;
|
||||
TaskQueueBase* const worker_thread_;
|
||||
const OnAudioChannelGoneAction on_audio_channel_gone_action_;
|
||||
std::list<AudioObserver*> audio_observers_;
|
||||
Mutex sink_lock_;
|
||||
|
Reference in New Issue
Block a user