chore(nests): standardise Log import in audio-pipeline files

Audit-12 cleanup. The audio-pipeline sources mixed two import styles:
some files used `com.vitorpamplona.quartz.utils.Log.d/w/e` fully-
qualified (NestPlayer's 13 sites, AudioTrackPlayer's 8, two each in
the encoder/decoder, three in NestMoqLiteBroadcaster) while
AudioRecordCapture had already migrated to a top-level
`import com.vitorpamplona.quartz.utils.Log`. The lambda overload
(`Log.d(tag) { lazyMessage }`) is what the find-non-lambda-logs
skill enforces and is the only style the rest of the codebase uses;
the fully-qualified form is verbose noise on every call site.

Add the `import com.vitorpamplona.quartz.utils.Log` line to each
file and rewrite call sites to bare `Log.d` / `Log.w` / `Log.e`. No
behaviour change; logs still go through PlatformLog with the same
tag and lazy-message contract. Five files updated, ~30 call sites.

https://claude.ai/code/session_014JfZJHSTvyYYWJbC9VbB47
This commit is contained in:
Claude
2026-05-06 19:38:19 +00:00
parent 8a49486b37
commit a96ec9db00
5 changed files with 33 additions and 28 deletions
@@ -23,6 +23,7 @@ package com.vitorpamplona.nestsclient.audio
import android.media.AudioAttributes
import android.media.AudioTrack
import android.os.Process
import com.vitorpamplona.quartz.utils.Log
import kotlinx.coroutines.ExecutorCoroutineDispatcher
import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.withContext
@@ -126,7 +127,7 @@ class AudioTrackPlayer(
override fun start() {
if (track != null) return
com.vitorpamplona.quartz.utils.Log
Log
.d("NestPlay") { "AudioTrackPlayer.start() — allocating AudioTrack" }
val channelMask =
@@ -214,7 +215,7 @@ class AudioTrackPlayer(
audioExecutor = executor
audioDispatcher = executor.asCoroutineDispatcher()
track = newTrack
com.vitorpamplona.quartz.utils.Log.d("NestPlay") {
Log.d("NestPlay") {
"AudioTrack allocated: state=${newTrack.state} playState=${newTrack.playState} " +
"bufferSizeBytes=$bufferBytes minBuffer=$minBuffer sampleRate=$sampleRate"
}
@@ -229,7 +230,7 @@ class AudioTrackPlayer(
val t = track ?: return
try {
t.play()
com.vitorpamplona.quartz.utils.Log.d("NestPlay") {
Log.d("NestPlay") {
"AudioTrack.play() returned, state=${t.playState} bufferSize=${t.bufferSizeInFrames} muted=$muted volume=$volume"
}
} catch (e: Throwable) {
@@ -238,7 +239,7 @@ class AudioTrackPlayer(
// track above. Throw so [NestPlayer]'s outer catch surfaces
// it via `onError(AudioException.PlaybackFailed)` — same path
// that handles every other mid-stream device failure.
com.vitorpamplona.quartz.utils.Log.w("NestPlay") {
Log.w("NestPlay") {
"AudioTrack.play() threw: ${e::class.simpleName}: ${e.message}"
}
throw AudioException(
@@ -261,7 +262,7 @@ class AudioTrackPlayer(
withContext(dispatcher) {
val written = t.write(pcm, 0, pcm.size, AudioTrack.WRITE_BLOCKING)
if (written < 0) {
com.vitorpamplona.quartz.utils.Log.w("NestPlay") {
Log.w("NestPlay") {
"AudioTrack.write returned error $written (state=${t.playState})"
}
throw AudioException(
@@ -270,7 +271,7 @@ class AudioTrackPlayer(
)
}
if (written != pcm.size) {
com.vitorpamplona.quartz.utils.Log.w("NestPlay") {
Log.w("NestPlay") {
"AudioTrack.write partial: requested=${pcm.size} written=$written"
}
}
@@ -279,14 +280,14 @@ class AudioTrackPlayer(
override fun setMuted(muted: Boolean) {
this.muted = muted
com.vitorpamplona.quartz.utils.Log
Log
.d("NestPlay") { "AudioTrackPlayer.setMuted($muted) volume=$volume" }
track?.let { applyMuteVolume(it) }
}
override fun setVolume(volume: Float) {
this.volume = volume.coerceIn(0f, 1f)
com.vitorpamplona.quartz.utils.Log
Log
.d("NestPlay") { "AudioTrackPlayer.setVolume($volume) muted=$muted" }
track?.let { applyMuteVolume(it) }
}
@@ -22,6 +22,7 @@ package com.vitorpamplona.nestsclient.audio
import android.media.MediaCodec
import android.media.MediaFormat
import com.vitorpamplona.quartz.utils.Log
import java.nio.ByteBuffer
import java.nio.ByteOrder
@@ -84,12 +85,12 @@ class MediaCodecOpusDecoder(
configure(buildFormat(channelCount, sampleRate), null, null, 0)
start()
}.also {
com.vitorpamplona.quartz.utils.Log.d("NestPlay") {
Log.d("NestPlay") {
"MediaCodecOpusDecoder allocated codec='${it.name}' channelCount=$channelCount"
}
}
} catch (t: Throwable) {
com.vitorpamplona.quartz.utils.Log.w("NestPlay") {
Log.w("NestPlay") {
"MediaCodec audio/opus decoder allocation FAILED: ${t::class.simpleName}: ${t.message}"
}
throw AudioException(
@@ -22,6 +22,7 @@ package com.vitorpamplona.nestsclient.audio
import android.media.MediaCodec
import android.media.MediaFormat
import com.vitorpamplona.quartz.utils.Log
import java.nio.ByteOrder
/**
@@ -122,7 +123,7 @@ class MediaCodecOpusEncoder(
codec.releaseOutputBuffer(outputIndex, false)
if (!loggedCsdSkip) {
loggedCsdSkip = true
com.vitorpamplona.quartz.utils.Log.d("NestTx") {
Log.d("NestTx") {
"MediaCodecOpusEncoder skipped ${bufferInfo.size}-byte CODEC_CONFIG (OpusHead/OpusTags) — not an audio frame"
}
}
@@ -135,7 +136,7 @@ class MediaCodecOpusEncoder(
// contract — broadcaster's
// `if (opus.isEmpty()) continue` handles it
// and the next encode call retries.
com.vitorpamplona.quartz.utils.Log.w("NestTx") {
Log.w("NestTx") {
"MediaCodecOpusEncoder hit MAX_CSD_SKIPS_PER_CALL=$MAX_CSD_SKIPS_PER_CALL; bailing this encode call (encoder may be misbehaving)"
}
return ByteArray(0)
@@ -21,6 +21,7 @@
package com.vitorpamplona.nestsclient.audio
import com.vitorpamplona.nestsclient.moq.lite.MoqLitePublisherHandle
import com.vitorpamplona.quartz.utils.Log
import com.vitorpamplona.quic.Varint
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
@@ -356,7 +357,7 @@ class NestMoqLiteBroadcaster(
if (accepted) {
sentFrames += 1
if (sentFrames % SEND_LOG_THROTTLE == 0L) {
com.vitorpamplona.quartz.utils.Log.d("NestTx") {
Log.d("NestTx") {
"broadcaster sent frame #$sentFrames (group $framesInCurrentGroup/$framesPerGroup)"
}
}
@@ -371,7 +372,7 @@ class NestMoqLiteBroadcaster(
} else {
droppedNoSubFrames += 1
if (droppedNoSubFrames % SEND_LOG_THROTTLE == 0L) {
com.vitorpamplona.quartz.utils.Log.w("NestTx") {
Log.w("NestTx") {
"broadcaster send returned false — frame dropped (count=$droppedNoSubFrames, sent=$sentFrames)"
}
}
@@ -379,7 +380,7 @@ class NestMoqLiteBroadcaster(
}.onFailure { t ->
if (t is CancellationException) throw t
consecutiveSendErrors += 1
com.vitorpamplona.quartz.utils.Log.w("NestTx") {
Log.w("NestTx") {
"broadcaster send threw (consecutive=$consecutiveSendErrors): ${t::class.simpleName}: ${t.message}"
}
onError(
@@ -21,6 +21,7 @@
package com.vitorpamplona.nestsclient.audio
import com.vitorpamplona.nestsclient.moq.MoqObject
import com.vitorpamplona.quartz.utils.Log
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
@@ -161,7 +162,7 @@ class NestPlayer(
var decodedFrames: Long = 0L
var emptyDecodes: Long = 0L
var enqueued: Long = 0L
com.vitorpamplona.quartz.utils.Log.d("NestPlay") {
Log.d("NestPlay") {
"NestPlayer.play started (prerollFrames=$prerollFrames)"
}
@@ -179,7 +180,7 @@ class NestPlayer(
// hardware starts pulling samples; getting
// [enqueue] in first means the very first sample
// pulled is from our pre-rolled audio, not silence.
com.vitorpamplona.quartz.utils.Log.d("NestPlay") {
Log.d("NestPlay") {
"NestPlayer flushing preroll (${preroll.size} frames) → beginPlayback"
}
while (preroll.isNotEmpty()) {
@@ -187,7 +188,7 @@ class NestPlayer(
}
player.beginPlayback()
playbackBegun = true
com.vitorpamplona.quartz.utils.Log
Log
.d("NestPlay") { "NestPlayer beginPlayback returned" }
}
// Track-alias of the most recently observed object.
@@ -201,7 +202,7 @@ class NestPlayer(
objects.collect { obj ->
receivedObjects += 1
if (receivedObjects % PLAY_LOG_THROTTLE == 0L) {
com.vitorpamplona.quartz.utils.Log.d("NestPlay") {
Log.d("NestPlay") {
"NestPlayer received obj #$receivedObjects (decoded=$decodedFrames empty=$emptyDecodes enqueued=$enqueued playbackBegun=$playbackBegun)"
}
}
@@ -233,14 +234,14 @@ class NestPlayer(
runCatching { factory() }
.onFailure { t ->
if (t is CancellationException) throw t
com.vitorpamplona.quartz.utils.Log.w("NestPlay") {
Log.w("NestPlay") {
"NestPlayer decoder factory threw on trackAlias " +
"$lastTrackAlias${obj.trackAlias}; keeping old decoder " +
"(${t::class.simpleName}: ${t.message})"
}
}.getOrNull()
if (replacement != null) {
com.vitorpamplona.quartz.utils.Log.d("NestPlay") {
Log.d("NestPlay") {
"NestPlayer publisher boundary: trackAlias $lastTrackAlias${obj.trackAlias}; rebuilding decoder"
}
runCatching { decoder.release() }
@@ -254,7 +255,7 @@ class NestPlayer(
} catch (ce: CancellationException) {
throw ce
} catch (t: Throwable) {
com.vitorpamplona.quartz.utils.Log.w("NestPlay") {
Log.w("NestPlay") {
"decoder.decode threw on obj #$receivedObjects: ${t::class.simpleName}: ${t.message}"
}
onError(
@@ -269,7 +270,7 @@ class NestPlayer(
if (pcm.isEmpty()) {
emptyDecodes += 1
if (emptyDecodes % PLAY_LOG_THROTTLE == 0L) {
com.vitorpamplona.quartz.utils.Log.w("NestPlay") {
Log.w("NestPlay") {
"decoder returned empty pcm (count=$emptyDecodes / received=$receivedObjects)"
}
}
@@ -282,7 +283,7 @@ class NestPlayer(
val enqueueMs = System.currentTimeMillis() - enqueueStart
enqueued += 1
if (enqueued % PLAY_LOG_THROTTLE == 0L || enqueueMs > 50) {
com.vitorpamplona.quartz.utils.Log.d("NestPlay") {
Log.d("NestPlay") {
"NestPlayer enqueued #$enqueued (took ${enqueueMs}ms)"
}
}
@@ -294,7 +295,7 @@ class NestPlayer(
}
}
}
com.vitorpamplona.quartz.utils.Log.w("NestPlay") {
Log.w("NestPlay") {
"NestPlayer objects flow COMPLETED (received=$receivedObjects decoded=$decodedFrames empty=$emptyDecodes enqueued=$enqueued)"
}
// Flow ended without enough frames to fill the pre-roll
@@ -303,12 +304,12 @@ class NestPlayer(
// already-decoded audio still reaches the device.
beginAndFlushIfNeeded()
} catch (ce: CancellationException) {
com.vitorpamplona.quartz.utils.Log.d("NestPlay") {
Log.d("NestPlay") {
"NestPlayer cancelled (received=$receivedObjects decoded=$decodedFrames enqueued=$enqueued)"
}
throw ce
} catch (t: Throwable) {
com.vitorpamplona.quartz.utils.Log.w("NestPlay") {
Log.w("NestPlay") {
"NestPlayer pipeline threw: ${t::class.simpleName}: ${t.message}"
}
onError(
@@ -334,7 +335,7 @@ class NestPlayer(
suspend fun stop() {
if (stopped) return
stopped = true
com.vitorpamplona.quartz.utils.Log
Log
.d("NestPlay") { "NestPlayer.stop()" }
job?.cancelAndJoin()
runCatching { player.stop() }