Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
Moriafly committed Nov 25, 2024
1 parent 75e4a25 commit b05e531
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MrwComment {
}

/**
* See also [Id3v2DeclaredFrames].
* @see Id3v2DeclaredFrames
*/
enum class MrwCommentField(vararg val field: String) {
Title(MrwCommentCommonFields.TITLE, Id3v2DeclaredFrames.TIT2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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) ||
Expand Down Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
/**
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -91,7 +91,7 @@ internal class FlacMrwReader : MrwReader() {

companion object {
/**
* "fLaC"
* "fLaC".
*/
private val MAGIC_HEADER = ByteString(0x66, 0x4C, 0x61, 0x43)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -328,7 +332,7 @@ internal class Id3v2FrameHeader(

companion object {
/**
* 0xFF 00 -> 0xFF
* 0xFF 00 -> 0xFF.
*/
fun synchronizeByteString(byteString: ByteString): ByteString {
val byteArray = byteString.toByteArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit b05e531

Please sign in to comment.