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