music: catch cancellation events during indexing

Catch and propagate cancellation events during indexing.

This is just better for debug information.
This commit is contained in:
Alexander Capehart 2022-08-16 16:46:31 -06:00
parent 7cc5c77ad7
commit 4d8c2abd09
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
2 changed files with 7 additions and 3 deletions

View file

@ -23,6 +23,7 @@ import android.content.pm.PackageManager
import android.database.Cursor
import android.os.Build
import androidx.core.content.ContextCompat
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.oxycblt.auxio.BuildConfig
@ -153,8 +154,12 @@ class Indexer {
logE("No music found")
Response.NoMusic
}
} catch (e: CancellationException) {
// Got cancelled, propagate upwards
logD("Loading routine was cancelled")
throw e
} catch (e: Exception) {
logE("Music indexing failed.")
logE("Music indexing failed")
logE(e.stackTraceToString())
Response.Err(e)
}

View file

@ -64,8 +64,7 @@ import org.oxycblt.auxio.util.logD
* TODO: Remove the player callback once smooth seeking is implemented
*
* TODO: Rework what is considered to "start foreground" and what is not from the context of this
* object. This could help reduce the amount of post calls I send on Android 13 onwards,
* hopefully.
* object. This could help reduce the amount of post calls I send on Android 13 onwards, hopefully.
*/
class MediaSessionComponent(
private val context: Context,