From b05e53188e9d9cc74f0813e1591ab1cc242a8416 Mon Sep 17 00:00:00 2001 From: Moriafly Date: Mon, 25 Nov 2024 22:55:11 +0800 Subject: [PATCH] Format code --- .../com/xuncorp/openmrw/core/format/MrwComment.kt | 2 +- .../com/xuncorp/openmrw/core/format/MrwFormat.kt | 4 ++-- .../com/xuncorp/openmrw/core/format/ape/Ape.kt | 6 +++--- .../xuncorp/openmrw/core/format/ape/ApeMrwReader.kt | 4 ++-- .../com/xuncorp/openmrw/core/format/flac/Flac.kt | 12 ++++++------ .../openmrw/core/format/flac/FlacMrwReader.kt | 4 ++-- .../xuncorp/openmrw/core/format/mp3/Mp3MrwReader.kt | 7 ------- .../com/xuncorp/openmrw/core/rw/ReaderProperties.kt | 8 +++++--- .../openmrw/core/rw/id3v2/Id3v2FrameHeader.kt | 10 +++++++--- .../kotlin/com/xuncorp/openmrw/core/util/Charsets.kt | 4 ++-- 10 files changed, 30 insertions(+), 31 deletions(-) diff --git a/core/src/main/kotlin/com/xuncorp/openmrw/core/format/MrwComment.kt b/core/src/main/kotlin/com/xuncorp/openmrw/core/format/MrwComment.kt index 5e1dbfe..5095ac6 100644 --- a/core/src/main/kotlin/com/xuncorp/openmrw/core/format/MrwComment.kt +++ b/core/src/main/kotlin/com/xuncorp/openmrw/core/format/MrwComment.kt @@ -63,7 +63,7 @@ class MrwComment { } /** - * See also [Id3v2DeclaredFrames]. + * @see Id3v2DeclaredFrames */ enum class MrwCommentField(vararg val field: String) { Title(MrwCommentCommonFields.TITLE, Id3v2DeclaredFrames.TIT2), diff --git a/core/src/main/kotlin/com/xuncorp/openmrw/core/format/MrwFormat.kt b/core/src/main/kotlin/com/xuncorp/openmrw/core/format/MrwFormat.kt index 16d8973..dc83a05 100644 --- a/core/src/main/kotlin/com/xuncorp/openmrw/core/format/MrwFormat.kt +++ b/core/src/main/kotlin/com/xuncorp/openmrw/core/format/MrwFormat.kt @@ -21,12 +21,12 @@ package com.xuncorp.openmrw.core.format abstract class MrwFormat(val mrwFormatType: MrwFormatType) { /** - * [MrwStreamInfo] + * @see MrwStreamInfo */ val mrwStreamInfo = MrwStreamInfo() /** - * [MrwComment] + * @see MrwComment */ val mrwComment = MrwComment() diff --git a/core/src/main/kotlin/com/xuncorp/openmrw/core/format/ape/Ape.kt b/core/src/main/kotlin/com/xuncorp/openmrw/core/format/ape/Ape.kt index 8ef6719..f2296d6 100644 --- a/core/src/main/kotlin/com/xuncorp/openmrw/core/format/ape/Ape.kt +++ b/core/src/main/kotlin/com/xuncorp/openmrw/core/format/ape/Ape.kt @@ -47,7 +47,7 @@ internal class ApeCommonHeader(source: Source) { companion object { /** - * Common magic header + * Common magic header. */ val ID_MAC = ByteString(0x4D, 0x41, 0x43, 0x20) @@ -78,7 +78,7 @@ internal class ApeHeaderOld(source: Source) { val finalFrameBlocks = source.readUIntLe() /** - * The number of audio blocks in one frame + * The number of audio blocks in one frame. */ val blocksPerFrame = if ((version >= 3900u) || @@ -141,7 +141,7 @@ internal class ApeHeader(source: Source) { val formatFlags = source.readUShortLe() /** - * The number of audio blocks in one frame + * The number of audio blocks in one frame. */ val blocksPerFrame = source.readUIntLe() diff --git a/core/src/main/kotlin/com/xuncorp/openmrw/core/format/ape/ApeMrwReader.kt b/core/src/main/kotlin/com/xuncorp/openmrw/core/format/ape/ApeMrwReader.kt index e8a70fe..26af865 100644 --- a/core/src/main/kotlin/com/xuncorp/openmrw/core/format/ape/ApeMrwReader.kt +++ b/core/src/main/kotlin/com/xuncorp/openmrw/core/format/ape/ApeMrwReader.kt @@ -39,7 +39,7 @@ internal class ApeMrwReader : MrwReader() { if (version > 3970u) { ApeDescriptor(source) - // new header + // New header. val apeHeader = ApeHeader(source) apeMrwFormat.mrwStreamInfo.apply { sampleRate = apeHeader.sampleRate.toInt() @@ -48,7 +48,7 @@ internal class ApeMrwReader : MrwReader() { sampleCount = apeHeader.sampleCount } } else { - // old header + // Old header. val apeHeaderOld = ApeHeaderOld(source) apeMrwFormat.mrwStreamInfo.apply { sampleRate = apeHeaderOld.sampleRate.toInt() diff --git a/core/src/main/kotlin/com/xuncorp/openmrw/core/format/flac/Flac.kt b/core/src/main/kotlin/com/xuncorp/openmrw/core/format/flac/Flac.kt index 0e2d35c..35e45b9 100644 --- a/core/src/main/kotlin/com/xuncorp/openmrw/core/format/flac/Flac.kt +++ b/core/src/main/kotlin/com/xuncorp/openmrw/core/format/flac/Flac.kt @@ -26,7 +26,7 @@ import kotlinx.io.readString import kotlinx.io.readUIntLe /** - * @param byteString The first 4 bytes of the metadata block header. + * @param byteString the first 4 bytes of the metadata block header. */ internal class FlacHeader(byteString: ByteString) { val isLastMetadataBlock = (byteString[0].toInt() and 0b10000000 shr 7) == 1 @@ -56,9 +56,9 @@ internal class FlacHeader(byteString: ByteString) { } /** - * [FlacHeader.BLOCK_TYPE_STREAMINFO] - * * @param byteString 34 bytes. + * + * @see FlacHeader.BLOCK_TYPE_STREAMINFO */ internal class FlacStreamInfo(byteString: ByteString) { /** @@ -115,11 +115,11 @@ internal class FlacStreamInfo(byteString: ByteString) { } /** - * [FlacHeader.BLOCK_TYPE_VORBIS_COMMENT] + * FLAC tags, without the framing bit. * - * FLAC tags, without the framing bit + * [Ogg Vorbis](https://www.xiph.org/vorbis/doc/v-comment.html). * - * [Ogg Vorbis](https://www.xiph.org/vorbis/doc/v-comment.html) + * @see FlacHeader.BLOCK_TYPE_VORBIS_COMMENT */ internal class FlacVorbisComment(source: Source) { val vendorString: String diff --git a/core/src/main/kotlin/com/xuncorp/openmrw/core/format/flac/FlacMrwReader.kt b/core/src/main/kotlin/com/xuncorp/openmrw/core/format/flac/FlacMrwReader.kt index 0ccdcfb..027e849 100644 --- a/core/src/main/kotlin/com/xuncorp/openmrw/core/format/flac/FlacMrwReader.kt +++ b/core/src/main/kotlin/com/xuncorp/openmrw/core/format/flac/FlacMrwReader.kt @@ -64,7 +64,7 @@ internal class FlacMrwReader : MrwReader() { override fun fetch(source: Source, properties: ReaderProperties): MrwFormat { val flacMrwFormat = FlacMrwFormat() - // Skip magic header + // Skip magic header. source.skip(MAGIC_HEADER.size.toLong()) var flacHeader: FlacHeader @@ -91,7 +91,7 @@ internal class FlacMrwReader : MrwReader() { companion object { /** - * "fLaC" + * "fLaC". */ private val MAGIC_HEADER = ByteString(0x66, 0x4C, 0x61, 0x43) } diff --git a/core/src/main/kotlin/com/xuncorp/openmrw/core/format/mp3/Mp3MrwReader.kt b/core/src/main/kotlin/com/xuncorp/openmrw/core/format/mp3/Mp3MrwReader.kt index df949f2..1bd0559 100644 --- a/core/src/main/kotlin/com/xuncorp/openmrw/core/format/mp3/Mp3MrwReader.kt +++ b/core/src/main/kotlin/com/xuncorp/openmrw/core/format/mp3/Mp3MrwReader.kt @@ -56,13 +56,6 @@ internal class Mp3MrwReader : MrwReader() { val frameSize = id3V2FrameHeader.frameSize - println( - """ - id3V2FrameHeader = $id3V2FrameHeader - frameId = ${id3V2FrameHeader.frameId.decodeToString()} - """.trimIndent() - ) - when (id3V2FrameHeader.frameType) { Id3v2FrameHeader.FrameType.TextInformation -> { val textInformation = id3V2FrameHeader.getTextInformation(source) diff --git a/core/src/main/kotlin/com/xuncorp/openmrw/core/rw/ReaderProperties.kt b/core/src/main/kotlin/com/xuncorp/openmrw/core/rw/ReaderProperties.kt index 2a75558..b8e4c9b 100644 --- a/core/src/main/kotlin/com/xuncorp/openmrw/core/rw/ReaderProperties.kt +++ b/core/src/main/kotlin/com/xuncorp/openmrw/core/rw/ReaderProperties.kt @@ -17,14 +17,16 @@ package com.xuncorp.openmrw.core.rw +import com.xuncorp.openmrw.core.rw.id3v2.Id3v2FrameHeader import java.nio.charset.Charset /** * Reader properties. * - * @property id3v2Charset In ID3v2 tags, the 0x00 flag indicates that the encoding is ISO_8859_1. - * However, many editors use the default encoding of the user's system when writing, such as GBK - * or GB18030 in a Chinese environment. + * @property id3v2Charset in ID3v2 tags, the 0x00 flag indicates that the encoding is + * [Charsets.ISO_8859_1]. However, many editors use the default encoding of the user's system when + * writing, such as [com.xuncorp.openmrw.core.util.GBK] or [com.xuncorp.openmrw.core.util.GB18030] + * in a Chinese environment. See also [Id3v2FrameHeader]. */ data class ReaderProperties( val id3v2Charset: Charset = Charsets.ISO_8859_1 diff --git a/core/src/main/kotlin/com/xuncorp/openmrw/core/rw/id3v2/Id3v2FrameHeader.kt b/core/src/main/kotlin/com/xuncorp/openmrw/core/rw/id3v2/Id3v2FrameHeader.kt index a1cb5c7..5a7e7df 100644 --- a/core/src/main/kotlin/com/xuncorp/openmrw/core/rw/id3v2/Id3v2FrameHeader.kt +++ b/core/src/main/kotlin/com/xuncorp/openmrw/core/rw/id3v2/Id3v2FrameHeader.kt @@ -311,12 +311,16 @@ internal class Id3v2FrameHeader( TextInformation, /** - * ID3v2.3.0 title 4.9 [Id3v2DeclaredFrames.USLT]. + * ID3v2.3.0 title 4.9. + * + * @see Id3v2DeclaredFrames.USLT */ UnsynchronizedLyrics, /** - * ID3v2.3.0 title 4.11 [Id3v2DeclaredFrames.COMM]. + * ID3v2.3.0 title 4.11. + * + * @see Id3v2DeclaredFrames.COMM */ Comment, @@ -328,7 +332,7 @@ internal class Id3v2FrameHeader( companion object { /** - * 0xFF 00 -> 0xFF + * 0xFF 00 -> 0xFF. */ fun synchronizeByteString(byteString: ByteString): ByteString { val byteArray = byteString.toByteArray() diff --git a/core/src/main/kotlin/com/xuncorp/openmrw/core/util/Charsets.kt b/core/src/main/kotlin/com/xuncorp/openmrw/core/util/Charsets.kt index 2b4e6a8..fba58b4 100644 --- a/core/src/main/kotlin/com/xuncorp/openmrw/core/util/Charsets.kt +++ b/core/src/main/kotlin/com/xuncorp/openmrw/core/util/Charsets.kt @@ -22,13 +22,13 @@ package com.xuncorp.openmrw.core.util import java.nio.charset.Charset /** - * [sun.nio.cs.GBK]. + * @see sun.nio.cs.GBK */ val Charsets.GBK: Charset get() = charset("GBK") /** - * [sun.nio.cs.GB18030]. + * @see sun.nio.cs.GB18030 */ val Charsets.GB18030: Charset get() = charset("GB18030") \ No newline at end of file