Skip to content

Commit

Permalink
[visionOS] Multi-window audio is coming from wrong location
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=274493
rdar://128499204

Reviewed by Andy Estes and Sam Weinig.

Initially, a MediaPlayerPrivateAVFoundationObjC will have an AVPlayer but no AVPlayerLayer, so
will get the "default" spatial tracking label. When an AVPlayerLayer is created (or destroyed!)
the tracking label will need to be re-calculated.

* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer):
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateSpatialTrackingLabel):

Canonical link: https://commits.webkit.org/279103@main
  • Loading branch information
jernoble committed May 22, 2024
1 parent 7b532a0 commit 00222bd
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,9 @@ static WallTime toSystemClockTime(NSDate *date)
[m_videoLayer setPIPModeEnabled:(player->fullscreenMode() & MediaPlayer::VideoFullscreenModePictureInPicture)];
#endif

#if HAVE(SPATIAL_TRACKING_LABEL)
updateSpatialTrackingLabel();
#endif
setNeedsRenderingModeChanged();
}

Expand All @@ -688,6 +691,9 @@ static WallTime toSystemClockTime(NSDate *date)
m_videoLayer = nil;
m_haveBeenAskedToCreateLayer = false;

#if HAVE(SPATIAL_TRACKING_LABEL)
updateSpatialTrackingLabel();
#endif
setNeedsRenderingModeChanged();
}

Expand Down Expand Up @@ -4085,24 +4091,28 @@ void determineChangedTracksFromNewTracksAndOldItems(MediaSelectionGroupAVFObjC*
return;

if (!m_spatialTrackingLabel.isNull()) {
INFO_LOG(LOGIDENTIFIER, "Explicitly set STSLabel: ", m_spatialTrackingLabel);
[m_avPlayer _setSTSLabel:m_spatialTrackingLabel];
return;
}

if (m_videoLayer) {
// Let AVPlayer manage setting the spatial tracking label in its AVPlayerLayer itself;
INFO_LOG(LOGIDENTIFIER, "No videoLayer, set STSLabel: nil");
[m_avPlayer _setSTSLabel:nil];
return;
}

if (!m_defaultSpatialTrackingLabel.isNull()) {
// If a default spatial tracking label was explicitly set, use it.
INFO_LOG(LOGIDENTIFIER, "Default STSLabel: ", m_defaultSpatialTrackingLabel);
[m_avPlayer _setSTSLabel:m_defaultSpatialTrackingLabel];
return;
}

// If there is no AVPlayerLayer, and no default spatial tracking label is available, use the session's spatial tracking label.
AVAudioSession *session = [PAL::getAVAudioSessionClass() sharedInstance];
INFO_LOG(LOGIDENTIFIER, "AVAudioSession label: ", session.spatialTrackingLabel);
[m_avPlayer _setSTSLabel:session.spatialTrackingLabel];
}
#endif
Expand Down

0 comments on commit 00222bd

Please sign in to comment.