Skip to content

Commit

Permalink
Improved a few logging statements
Browse files Browse the repository at this point in the history
  • Loading branch information
MShekow committed Aug 9, 2020
1 parent 2ba55e4 commit cbfc78b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,21 @@ class MediaCallbackService : Service(), OnSharedPreferenceChangeListener {
return
}
val newState = state.state
Log.d(TAG, "onPlaybackStateChanged $newState (last: $lastState)")
if (newState == lastState) {
Log.d(TAG, "onPlaybackStateChanged(): ignoring new state $newState because " +
"it matches the old state")
return
}
if (newState != PlaybackState.STATE_PAUSED && newState != PlaybackState.STATE_PLAYING) {
Log.d(TAG, "onPlaybackStateChanged: ignoring irrelevant state $newState")
Log.d(TAG, "onPlaybackStateChanged(): ignoring irrelevant state $newState")
return
}
Log.d(TAG, "pos " + state.position + " last updttime " + state.lastPositionUpdateTime)
val timestampSeconds = (state.position / 1000).toInt()
Log.d(TAG, "timestampSeconds $timestampSeconds")
val correspondingController = controllers[packageAndSessionName]
stateChangeProcessor.processStateChange(newState, timestampSeconds, correspondingController, this.cachedMetadata, this.cachedMediaId)
val correspondingController = controllers[packageAndSessionName]!!
stateChangeProcessor.processStateChange(newState, timestampSeconds,
correspondingController, this.cachedMetadata, this.cachedMediaId)
lastState = newState
Log.d(TAG, "onPlaybackStateChanged " + state.state)
}

override fun onMetadataChanged(metadata: MediaMetadata?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ class PlaybackStateChangeProcessor(val onBookmarkDetected: (Bookmark) -> (Unit),
private var lastPauseTimestampMs: Long = 0
private var lastMetaData: AudioMetadata? = null

fun processStateChange(newState: Int, timestampSeconds: Int, controller: MediaController?,
fun processStateChange(newState: Int, timestampSeconds: Int, controller: MediaController,
cachedMetadata: AudioMetadata?, cachedMediaId: String?) {
val metaData: AudioMetadata?
val mediaId: String?
val mediaMetadata = controller!!.metadata
val mediaMetadata = controller.metadata
if (mediaMetadata == null) {
Log.e(TAG, "processStateChange(): Unable to get metadata (null was returned), " +
"using cached one instead")
Expand Down

0 comments on commit cbfc78b

Please sign in to comment.