[Mac][WebAudio] Update the AVAudioMix in the AudioSourceProviderAVFObjC when the...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Apr 2015 18:12:56 +0000 (18:12 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Apr 2015 18:12:56 +0000 (18:12 +0000)
commit5d77fc62a1ca9b8527d72e958ee2c50497ca3641
tree77f4e3a88696f56c4d9f302b0ccddb3983563108
parent6050cfb674dff4d4428551b90ad4873f8f019a12
[Mac][WebAudio] Update the AVAudioMix in the AudioSourceProviderAVFObjC when the list of enabled audio tracks change.
https://bugs.webkit.org/show_bug.cgi?id=143332

Reviewed by Eric Carlson.

Some media assets (notably, mp3s) will not have an enabled audio track when the AVAsset is
first loaded, so the AVAudioMix will have no trackID in it's parameters. Whenever the list
of enabled tracks change, recreate the AVAudioMix with the new first enabled audio trackID.

To facilitate this, add a new setter to AudioSourceProviderAVFObjC taking an AVAssetTrack to
use with the AVAudioMix. Whenever this parameter changes, the AVAudioMix is destroyed and
recreated.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerEngineUpdated): Drive-by fix: when the media
    player switches engines, re-associate the audio source node with its provider.
* platform/graphics/avfoundation/AudioSourceProviderAVFObjC.h:
* platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm:
(WebCore::AudioSourceProviderAVFObjC::setPlayerItem): Only create the mix if there is a valid AVPlayerItem and AVAssetTrack
(WebCore::AudioSourceProviderAVFObjC::setAudioTrack): Ditto.
(WebCore::AudioSourceProviderAVFObjC::createMix): Don't iterate over the AVPlayerItem's tracks,
    just use the one passed in through setAudioTrack().
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::cancelLoad): Clear the provider's track.
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Set the provider's track.
(WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::audioSourceProvider): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182555 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm