Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Dec 14, 2024
1 parent fd16b2f commit 240c597
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ChangeDefaultAudioLanguagePatch {
* it.10
*/
private static final Pattern AUDIO_TRACK_ID_PATTERN =
Pattern.compile("^([a-z]{2})(-[A-Z]{2})?(\\.\\d+)");
Pattern.compile("^([a-z]{2})(-[A-Z]{2})?.*");

/**
* Injection point.
Expand All @@ -38,13 +38,13 @@ public static boolean isAudioStreamAsDefault(boolean isDefault, String audioTrac
return isDefault; // Do nothing.
}

Logger.printDebug(() -> "isDefault: " + String.format("%-5s", isDefault) + " audioTrackId: "
+ audioTrackId + " audioTrackDisplayName:" + audioTrackDisplayName);
Logger.printDebug(() -> "default: " + String.format("%-5s", isDefault) + " id: "
+ String.format("%-8s", audioTrackId) + " name:" + audioTrackDisplayName);

if (defaultLanguage == AudioStreamLanguage.ORIGINAL) {
final boolean isOriginal = audioTrackDisplayName.contains(DEFAULT_AUDIO_TRACKS_IDENTIFIER);
if (isOriginal) {
Logger.printDebug(() -> "Using original audio language: " + audioTrackId);
Logger.printDebug(() -> "Using audio: " + audioTrackId);
}

return isOriginal;
Expand All @@ -59,11 +59,11 @@ public static boolean isAudioStreamAsDefault(boolean isDefault, String audioTrac
String desiredIso639 = defaultLanguage.getIso639_1();
if (desiredIso639.equals(matcher.group(1))
|| desiredIso639.equals(matcher.group(2))) {
Logger.printDebug(() -> "Using preferred audio language: " + audioTrackId);
Logger.printDebug(() -> "Using audio: " + audioTrackId);
return true;
}
} catch (Exception ex) {
Logger.printException(() -> "setAudioStreamAsDefault failure", ex);
Logger.printException(() -> "isAudioStreamAsDefault failure", ex);
}

return isDefault;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ val changeDefaultAudioLanguagePatch = bytecodePatch(
// Boolean is a 100% immutable class (all fields are final)
// and safe to write to a shared field without volatile/synchronization,
// but without volatile the field can show stale data
// and it's calculated by more than one thread.
// and the same field is calculated more than once by different threads.
AccessFlags.PRIVATE.value or AccessFlags.VOLATILE.value,
null,
null,
Expand Down

0 comments on commit 240c597

Please sign in to comment.