Commit f634b1d4 by andrewlewis Committed by Oliver Woodman

Resolve locale warnings in EventLogger

Use string concatenation for Metadata.Entry instances, and add
Util.formatInvariant for numerical formatting.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=190915643
parent 39e4112e
......@@ -92,6 +92,8 @@ public final class Metadata implements Parcelable {
return Arrays.hashCode(entries);
}
// Parcelable implementation.
@Override
public int describeContents() {
return 0;
......
......@@ -117,6 +117,11 @@ public final class EventMessage implements Metadata.Entry {
&& Util.areEqual(value, other.value) && Arrays.equals(messageData, other.messageData);
}
@Override
public String toString() {
return "EMSG: scheme=" + schemeIdUri + ", id=" + id + ", value=" + value;
}
// Parcelable implementation.
@Override
......
......@@ -73,6 +73,13 @@ public final class ApicFrame extends Id3Frame {
}
@Override
public String toString() {
return id + ": mimeType=" + mimeType + ", description=" + description;
}
// Parcelable implementation.
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mimeType);
dest.writeString(description);
......
......@@ -67,6 +67,13 @@ public final class CommentFrame extends Id3Frame {
}
@Override
public String toString() {
return id + ": language=" + language + ", description=" + description;
}
// Parcelable implementation.
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(id);
dest.writeString(language);
......
......@@ -72,6 +72,19 @@ public final class GeobFrame extends Id3Frame {
}
@Override
public String toString() {
return id
+ ": mimeType="
+ mimeType
+ ", filename="
+ filename
+ ", description="
+ description;
}
// Parcelable implementation.
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mimeType);
dest.writeString(filename);
......
......@@ -33,6 +33,11 @@ public abstract class Id3Frame implements Metadata.Entry {
}
@Override
public String toString() {
return id;
}
@Override
public int describeContents() {
return 0;
}
......
......@@ -63,6 +63,12 @@ public final class PrivFrame extends Id3Frame {
}
@Override
public String toString() {
return id + ": owner=" + owner;
}
// Parcelable implementation.
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(owner);
dest.writeByteArray(privateData);
......
......@@ -62,6 +62,13 @@ public final class TextInformationFrame extends Id3Frame {
}
@Override
public String toString() {
return id + ": value=" + value;
}
// Parcelable implementation.
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(id);
dest.writeString(description);
......
......@@ -62,6 +62,13 @@ public final class UrlLinkFrame extends Id3Frame {
}
@Override
public String toString() {
return id + ": url=" + url;
}
// Parcelable implementation.
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(id);
dest.writeString(description);
......
......@@ -23,6 +23,13 @@ import com.google.android.exoplayer2.metadata.Metadata;
public abstract class SpliceCommand implements Metadata.Entry {
@Override
public String toString() {
return "SCTE-35 splice command: type=" + getClass().getSimpleName();
}
// Parcelable implementation.
@Override
public int describeContents() {
return 0;
}
......
......@@ -31,15 +31,6 @@ import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.drm.DefaultDrmSessionEventListener;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.MetadataOutput;
import com.google.android.exoplayer2.metadata.emsg.EventMessage;
import com.google.android.exoplayer2.metadata.id3.ApicFrame;
import com.google.android.exoplayer2.metadata.id3.CommentFrame;
import com.google.android.exoplayer2.metadata.id3.GeobFrame;
import com.google.android.exoplayer2.metadata.id3.Id3Frame;
import com.google.android.exoplayer2.metadata.id3.PrivFrame;
import com.google.android.exoplayer2.metadata.id3.TextInformationFrame;
import com.google.android.exoplayer2.metadata.id3.UrlLinkFrame;
import com.google.android.exoplayer2.metadata.scte35.SpliceCommand;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.source.MediaSourceEventListener;
import com.google.android.exoplayer2.source.TrackGroup;
......@@ -123,9 +114,9 @@ public class EventLogger
@Override
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
logd(
"playbackParameters "
+ String.format(
"[speed=%.2f, pitch=%.2f]", playbackParameters.speed, playbackParameters.pitch));
Util.formatInvariant(
"playbackParameters [speed=%.2f, pitch=%.2f]",
playbackParameters.speed, playbackParameters.pitch));
}
@Override
......@@ -476,55 +467,7 @@ public class EventLogger
private void printMetadata(Metadata metadata, String prefix) {
for (int i = 0; i < metadata.length(); i++) {
Metadata.Entry entry = metadata.get(i);
if (entry instanceof TextInformationFrame) {
TextInformationFrame textInformationFrame = (TextInformationFrame) entry;
logd(
prefix
+ String.format(
"%s: value=%s", textInformationFrame.id, textInformationFrame.value));
} else if (entry instanceof UrlLinkFrame) {
UrlLinkFrame urlLinkFrame = (UrlLinkFrame) entry;
logd(prefix + String.format("%s: url=%s", urlLinkFrame.id, urlLinkFrame.url));
} else if (entry instanceof PrivFrame) {
PrivFrame privFrame = (PrivFrame) entry;
logd(prefix + String.format("%s: owner=%s", privFrame.id, privFrame.owner));
} else if (entry instanceof GeobFrame) {
GeobFrame geobFrame = (GeobFrame) entry;
logd(
prefix
+ String.format(
"%s: mimeType=%s, filename=%s, description=%s",
geobFrame.id, geobFrame.mimeType, geobFrame.filename, geobFrame.description));
} else if (entry instanceof ApicFrame) {
ApicFrame apicFrame = (ApicFrame) entry;
logd(
prefix
+ String.format(
"%s: mimeType=%s, description=%s",
apicFrame.id, apicFrame.mimeType, apicFrame.description));
} else if (entry instanceof CommentFrame) {
CommentFrame commentFrame = (CommentFrame) entry;
logd(
prefix
+ String.format(
"%s: language=%s, description=%s",
commentFrame.id, commentFrame.language, commentFrame.description));
} else if (entry instanceof Id3Frame) {
Id3Frame id3Frame = (Id3Frame) entry;
logd(prefix + id3Frame.id);
} else if (entry instanceof EventMessage) {
EventMessage eventMessage = (EventMessage) entry;
logd(
prefix
+ String.format(
"EMSG: scheme=%s, id=%d, value=%s",
eventMessage.schemeIdUri, eventMessage.id, eventMessage.value));
} else if (entry instanceof SpliceCommand) {
String description =
String.format("SCTE-35 splice command: type=%s.", entry.getClass().getSimpleName());
logd(prefix + description);
}
logd(prefix + metadata.get(i));
}
}
......
......@@ -330,6 +330,15 @@ public final class Util {
}
/**
* Formats a string using {@link Locale#US}.
*
* @see String#format(String, Object...)
*/
public static String formatInvariant(String format, Object... args) {
return String.format(Locale.US, format, args);
}
/**
* Divides a {@code numerator} by a {@code denominator}, returning the ceiled result.
*
* @param numerator The numerator to divide.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment