@@ -1392,23 +1392,33 @@ private void buildTracksFromSampleStreams() {
1392
1392
Format sampleFormat = Assertions .checkStateNotNull (sampleQueues [i ].getUpstreamFormat ());
1393
1393
if (i == primaryExtractorTrackIndex ) {
1394
1394
Format [] formats = new Format [chunkSourceTrackCount ];
1395
+ boolean mergeMuxedAudioFormat =
1396
+ primaryExtractorTrackType == C .TRACK_TYPE_AUDIO && muxedAudioFormat != null ;
1395
1397
if (chunkSourceTrackCount == 1 ) {
1396
- formats [0 ] = sampleFormat .withManifestFormatInfo (chunkSourceTrackGroup .getFormat (0 ));
1398
+ Format playlistFormat = chunkSourceTrackGroup .getFormat (0 );
1399
+ if (mergeMuxedAudioFormat ) {
1400
+ playlistFormat = playlistFormat .withManifestFormatInfo (muxedAudioFormat );
1401
+ }
1402
+ formats [0 ] = sampleFormat .withManifestFormatInfo (playlistFormat );
1397
1403
} else {
1398
1404
for (int j = 0 ; j < chunkSourceTrackCount ; j ++) {
1399
- formats [j ] = deriveFormat (chunkSourceTrackGroup .getFormat (j ), sampleFormat , true );
1405
+ Format playlistFormat = chunkSourceTrackGroup .getFormat (j );
1406
+ if (mergeMuxedAudioFormat ) {
1407
+ playlistFormat = playlistFormat .withManifestFormatInfo (muxedAudioFormat );
1408
+ }
1409
+ formats [j ] = deriveFormat (playlistFormat , sampleFormat , true );
1400
1410
}
1401
1411
}
1402
1412
trackGroups [i ] = new TrackGroup (formats );
1403
1413
primaryTrackGroupIndex = i ;
1404
1414
} else {
1405
1415
@ Nullable
1406
- Format trackFormat =
1416
+ Format playlistFormat =
1407
1417
primaryExtractorTrackType == C .TRACK_TYPE_VIDEO
1408
1418
&& MimeTypes .isAudio (sampleFormat .sampleMimeType )
1409
1419
? muxedAudioFormat
1410
1420
: null ;
1411
- trackGroups [i ] = new TrackGroup (deriveFormat (trackFormat , sampleFormat , false ));
1421
+ trackGroups [i ] = new TrackGroup (deriveFormat (playlistFormat , sampleFormat , false ));
1412
1422
}
1413
1423
}
1414
1424
this .trackGroups = createTrackGroupArrayWithDrmInfo (trackGroups );
0 commit comments