Fix dangling pointers in CefAudioMirrorDestination (fixes issue #2713).
This commit is contained in:
parent
1086495096
commit
367c6eb704
|
@ -29,7 +29,7 @@ void CefAudioMirrorDestination::Start() {
|
|||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&content::AudioMirroringManager::StartMirroring,
|
||||
base::Unretained(mirroring_manager_),
|
||||
base::Unretained(this)));
|
||||
base::RetainedRef(this)));
|
||||
}
|
||||
|
||||
void CefAudioMirrorDestination::Stop() {
|
||||
|
@ -39,7 +39,7 @@ void CefAudioMirrorDestination::Stop() {
|
|||
FROM_HERE, {content::BrowserThread::IO},
|
||||
base::BindOnce(&content::AudioMirroringManager::StopMirroring,
|
||||
base::Unretained(mirroring_manager_),
|
||||
base::Unretained(this)));
|
||||
base::RetainedRef(this)));
|
||||
}
|
||||
|
||||
// Asynchronously query whether this MirroringDestination wants to consume
|
||||
|
@ -56,7 +56,7 @@ void CefAudioMirrorDestination::QueryForMatches(
|
|||
base::PostTaskWithTraits(
|
||||
FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&CefAudioMirrorDestination::QueryForMatchesOnUIThread,
|
||||
base::Unretained(this), candidates,
|
||||
base::RetainedRef(this), candidates,
|
||||
media::BindToCurrentLoop(std::move(results_callback))));
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ media::AudioPushSink* CefAudioMirrorDestination::AddPushInput(
|
|||
return new CefAudioPushSink(
|
||||
params, browser_, cef_audio_handler_,
|
||||
base::Bind(&CefAudioMirrorDestination::ReleasePushInput,
|
||||
base::Unretained(this)));
|
||||
base::RetainedRef(this)));
|
||||
}
|
||||
|
||||
void CefAudioMirrorDestination::ReleasePushInput(CefAudioPushSink* sink) {
|
||||
|
|
|
@ -22,14 +22,13 @@ class CefAudioPushSink;
|
|||
class CefBrowserHostImpl;
|
||||
|
||||
class CefAudioMirrorDestination
|
||||
: public content::AudioMirroringManager::MirroringDestination {
|
||||
: public base::RefCountedThreadSafe<CefAudioMirrorDestination>,
|
||||
public content::AudioMirroringManager::MirroringDestination {
|
||||
public:
|
||||
CefAudioMirrorDestination(CefRefPtr<CefBrowserHostImpl> browser,
|
||||
CefRefPtr<CefAudioHandler> cef_audio_handler,
|
||||
content::AudioMirroringManager* mirroring_manager);
|
||||
|
||||
virtual ~CefAudioMirrorDestination() = default;
|
||||
|
||||
// Start mirroring. This needs to be triggered on the IO thread.
|
||||
void Start();
|
||||
|
||||
|
@ -65,6 +64,10 @@ class CefAudioMirrorDestination
|
|||
const media::AudioParameters& params) override;
|
||||
|
||||
private:
|
||||
friend class base::RefCountedThreadSafe<CefAudioMirrorDestination>;
|
||||
|
||||
~CefAudioMirrorDestination() override = default;
|
||||
|
||||
void QueryForMatchesOnUIThread(
|
||||
const std::set<content::GlobalFrameRoutingId>& candidates,
|
||||
MatchesCallback results_callback);
|
||||
|
|
|
@ -2744,8 +2744,8 @@ bool CefBrowserHostImpl::StartAudioMirroring() {
|
|||
if (client_.get()) {
|
||||
CefRefPtr<CefAudioHandler> audio_handler = client_->GetAudioHandler();
|
||||
if (audio_handler.get()) {
|
||||
audio_mirror_destination_.reset(new CefAudioMirrorDestination(
|
||||
this, audio_handler, content::AudioMirroringManager::GetInstance()));
|
||||
audio_mirror_destination_ = new CefAudioMirrorDestination(
|
||||
this, audio_handler, content::AudioMirroringManager::GetInstance());
|
||||
audio_mirror_destination_->Start();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -666,7 +666,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
|||
bool is_background_host_ = false;
|
||||
|
||||
// Used to mirror audio streams
|
||||
std::unique_ptr<CefAudioMirrorDestination> audio_mirror_destination_;
|
||||
scoped_refptr<CefAudioMirrorDestination> audio_mirror_destination_;
|
||||
|
||||
// Used with auto-resize.
|
||||
bool auto_resize_enabled_ = false;
|
||||
|
|
Loading…
Reference in New Issue