Skip to content

Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.

Raise the volume of a track created after playback started

Lelonio2d25f7e47f89
diff --git a/.claude/settings.local.json b/.claude/settings.local.json
index 8cb31a7..a621ede 100644
--- a/.claude/settings.local.json
+++ b/.claude/settings.local.json
@@ -87,7 +87,8 @@
"Bash(git -c user.name=Emanuele -c [email protected] commit -qm 'Add the Connect device picker to the player *)",
"Bash(git -c user.name=Emanuele -c [email protected] commit -qm 'Cut the cost of expanding the player *)",
"Bash(git -c user.name=Emanuele -c [email protected] commit -qm 'Blur the page backdrop at decode time *)",
- "Bash(git -c user.name=Emanuele -c [email protected] commit -qm 'Reorder the home sections *)"
+ "Bash(git -c user.name=Emanuele -c [email protected] commit -qm 'Reorder the home sections *)",
+ "Bash(git -c user.name=Emanuele -c [email protected] commit -qm 'Raise the volume of a track created after playback started *)"
]
}
}
diff --git a/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin b/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
index 04aaaca..cdca646 100644
--- a/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
+++ b/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/configure_fingerprint.bin
@@ -2,27 +2,27 @@ C/C++ Structured Logl
j
h/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/additional_project_files.txtC
A
-?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  ӝ���3  ����3i
+?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  �����3  ����3i
g
-e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build.json  ԝ���3� ����3n
+e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build.json  �����3� ����3n
l
-j/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build_mini.json  ԝ���3� �����3[
+j/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/android_gradle_build_mini.json  �����3� �����3[
Y
-W/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja  ԝ���3�� ����3_
+W/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja  �����3�� ����3_
]
-[/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja.txt  ԝ���3d
+[/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build.ninja.txt  �����3d
b
-`/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build_file_index.txt  ԝ���3 @ ����3e
+`/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/build_file_index.txt  �����3 @ ����3e
c
-a/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json  ԝ���3�� ����3i
+a/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json  �����3�� ����3i
g
-e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json.bin  ԝ���3 �" ����3o
+e/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/compile_commands.json.bin  �����3 �" ����3o
m
-k/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/metadata_generation_command.txt  ԝ���3
+k/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/metadata_generation_command.txt  �����3
� ����3b
`
-^/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/prefab_config.json  ԝ���3  ( ����3g
+^/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/prefab_config.json  �����3  ( ����3g
e
-c/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/symbol_folder_index.txt  ԝ���3  b ����3D
+c/Users/emanuele/Progetto Spotify/app/.cxx/RelWithDebInfo/151m4dr6/arm64-v8a/symbol_folder_index.txt  �����3  b ����3D
B
-@/Users/emanuele/Progetto Spotify/app/src/main/cpp/CMakeLists.txt  ԝ���3 � �Ȅ��3
\ No newline at end of file
+@/Users/emanuele/Progetto Spotify/app/src/main/cpp/CMakeLists.txt  �����3 � �Ȅ��3
\ No newline at end of file
diff --git a/app/src/main/java/dev/emanuele/spot/playback/AudioOutput.kt b/app/src/main/java/dev/emanuele/spot/playback/AudioOutput.kt
index 2692c74..00d5027 100644
--- a/app/src/main/java/dev/emanuele/spot/playback/AudioOutput.kt
+++ b/app/src/main/java/dev/emanuele/spot/playback/AudioOutput.kt
@@ -53,6 +53,21 @@ class AudioOutput {
@Volatile
private var currentGain = 1f
+ /**
+ * Whether the sink has been told to play.
+ *
+ * Kept because [start] can arrive before there is an AudioTrack to start —
+ * the sink is started when playback begins, and the track is built by the
+ * first packet that follows. Without this the track was created silent and
+ * nothing ever raised it: the dry signal stayed at zero while the reverb's
+ * send, which does not go through the track's volume, carried on at full
+ * level. That is the "everything is reverb and muffled until I change
+ * track" this fixes — a track change ran start() again, this time with a
+ * track present.
+ */
+ @Volatile
+ private var playing = false
+
/**
* Drops incoming PCM instead of writing it.
*
@@ -169,6 +184,7 @@ class AudioOutput {
// A gate left closed by a load that never got its fade-in — a track
// loaded paused, say — would otherwise silence the next play outright.
discarding = false
+ playing = true
val output = synchronized(this) {
track?.takeIf { it.state == AudioTrack.STATE_INITIALIZED }
} ?: return
@@ -192,6 +208,7 @@ class AudioOutput {
@Suppress("unused")
fun stop() {
discarding = false
+ playing = false
val output = synchronized(this) {
track?.takeIf { it.state == AudioTrack.STATE_INITIALIZED }
}
@@ -461,10 +478,15 @@ class AudioOutput {
)
// Silent until something fades it up, so the first track of a session
- // arrives the same way every later one does.
+ // arrives the same way every later one does — and if playback has
+ // already started, that something is here: `start` may well have run
+ // before this track existed.
runCatching { created.setVolume(0f) }
currentGain = 0f
created.play()
+ if (playing) {
+ fadeExecutor.execute { ramp(created, 1f, FADE_IN_MS) }
+ }
track = created
configuredSampleRate = sampleRate
configuredChannels = channels