all: fix db memory leak
Fix an issue where the database instances would leak memory due to an incorrect context use.
This commit is contained in:
parent
2413edfd5e
commit
4012c35cf4
3 changed files with 6 additions and 2 deletions
|
@ -187,7 +187,9 @@ private abstract class CacheDatabase : RoomDatabase() {
|
|||
synchronized(this) {
|
||||
val newInstance =
|
||||
Room.databaseBuilder(
|
||||
context, CacheDatabase::class.java, "auxio_metadata_cache.db")
|
||||
context.applicationContext,
|
||||
CacheDatabase::class.java,
|
||||
"auxio_metadata_cache.db")
|
||||
.fallbackToDestructiveMigration()
|
||||
.fallbackToDestructiveMigrationFrom(0)
|
||||
.fallbackToDestructiveMigrationOnDowngrade()
|
||||
|
|
|
@ -69,7 +69,7 @@ abstract class PersistenceDatabase : RoomDatabase() {
|
|||
synchronized(this) {
|
||||
val newInstance =
|
||||
Room.databaseBuilder(
|
||||
context,
|
||||
context.applicationContext,
|
||||
PersistenceDatabase::class.java,
|
||||
"auxio_playback_persistence.db")
|
||||
.fallbackToDestructiveMigration()
|
||||
|
|
|
@ -280,6 +280,7 @@ interface PlaybackStateManager {
|
|||
*/
|
||||
fun get(): PlaybackStateManager {
|
||||
val currentInstance = INSTANCE
|
||||
logD(currentInstance)
|
||||
|
||||
if (currentInstance != null) {
|
||||
return currentInstance
|
||||
|
@ -553,6 +554,7 @@ private class RealPlaybackStateManager : PlaybackStateManager {
|
|||
// Internal player may have reloaded the media item, re-seek to the previous position
|
||||
seekTo(savedState.positionMs)
|
||||
}
|
||||
isInitialized = true
|
||||
}
|
||||
|
||||
// --- CALLBACKS ---
|
||||
|
|
Loading…
Reference in a new issue