MP3: Make a defensive copy of the header in XingFrame
constructor
This is currently set from `Mp3Extractor.synchronizedHeader` which gets overwritten every time we read a new frame. It seems safer to make this defensive copy (and there will be at most one `XingFrame` instance per-playback, so this is not prohibitively expensive). PiperOrigin-RevId: 636181038
This commit is contained in:
parent
a74076f691
commit
8d515c8cdc
@ -48,6 +48,20 @@ public final class MpegAudioUtil {
|
||||
/** Number of samples stored in the frame. */
|
||||
public int samplesPerFrame;
|
||||
|
||||
/** Constructs an empty instance. */
|
||||
public Header() {}
|
||||
|
||||
/** Constructs an instance with values from {@code header}. */
|
||||
public Header(Header header) {
|
||||
this.version = header.version;
|
||||
this.mimeType = header.mimeType;
|
||||
this.frameSize = header.frameSize;
|
||||
this.sampleRate = header.sampleRate;
|
||||
this.channels = header.channels;
|
||||
this.bitrate = header.bitrate;
|
||||
this.samplesPerFrame = header.samplesPerFrame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the fields in this instance to reflect the MPEG audio header in {@code headerData},
|
||||
* returning whether the header was valid. If false, the values of the fields in this instance
|
||||
|
@ -60,7 +60,7 @@ import androidx.media3.extractor.MpegAudioUtil;
|
||||
@Nullable long[] tableOfContents,
|
||||
int encoderDelay,
|
||||
int encoderPadding) {
|
||||
this.header = header;
|
||||
this.header = new MpegAudioUtil.Header(header);
|
||||
this.frameCount = frameCount;
|
||||
this.dataSize = dataSize;
|
||||
this.tableOfContents = tableOfContents;
|
||||
|
Loading…
x
Reference in New Issue
Block a user