Skip to content

Commit

Permalink
Build 1.4.2+ : SoundMaster ehm ehm
Browse files Browse the repository at this point in the history
  • Loading branch information
legendsayantan committed Jun 14, 2024
1 parent adcce78 commit 9fd06de
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
Binary file modified app/release/app-release.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ class VolumeBarAdapter(
//spawn radiobuttons
holder.outputGroup.removeAllViews()
getDevices().forEach { device ->
if ((device?.id?:-1) != currentItem.outputDevice){
val rButton = RadioButton(context)
showDevice(rButton, device)
rButton.setOnClickListener {
if(setDeviceFor(position, device)) showDevice(holder.outputName, device)
else rButton.isChecked = false
}
holder.outputGroup.addView(rButton)
val rButton = RadioButton(context)
showDevice(rButton, device)
if ((device?.id?:-1) == currentItem.outputDevice){
rButton.isChecked = true
}else rButton.setOnClickListener {
if(setDeviceFor(position, device)) showDevice(holder.outputName, device)
else rButton.isChecked = false
}
holder.outputGroup.addView(rButton)
}
}
}
Expand Down
25 changes: 12 additions & 13 deletions app/src/main/java/com/legendsayantan/adbtools/lib/PlayBackThread.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ class PlayBackThread(
try {
mCapture.startRecording()
Log.i(LOG_TAG, "Audio Recording started")
val players = mPlayers.values
while (playback) {
mCapture.read(dataBuffer, 0, BUF_SIZE)
val players = mPlayers.values.toList()
players.forEach {
it.write(dataBuffer, 0, dataBuffer.size)
}
Expand Down Expand Up @@ -133,22 +133,19 @@ class PlayBackThread(
mPlayers[device?.id ?: -1] = plyr
}

fun deleteOutput(outputId: Int) {
fun deleteOutput(outputId: Int, interruption:Boolean=true): AudioPlayer? {
val plyr = mPlayers.remove(outputId)
plyr?.stop()
if (mPlayers.size == 0) {
if (mPlayers.size == 0 && interruption) {
interrupt()
}
return plyr
}

fun switchOutputDevice(key: AudioOutputKey, newDevice: AudioDeviceInfo?):Boolean{
if(mPlayers.contains(newDevice?.id?:-1)) return false
mPlayers[key.outputDevice]?.let {
val vol = it.volume * 100f
val balance = it.getBalance()
val bands = it.savedBands
createOutput(newDevice, vol, balance, bands)
deleteOutput(key.outputDevice)
fun switchOutputDevice(key: AudioOutputKey, newDevice: AudioDeviceInfo?): Boolean {
if (mPlayers.contains(newDevice?.id ?: -1)) return false
deleteOutput(key.outputDevice,false)?.let {
createOutput(newDevice, it.volume * 100f, it.getBalance(), it.savedBands)
}
return true
}
Expand All @@ -168,8 +165,10 @@ class PlayBackThread(
}
}
})
mCapture.stop()
mCapture.release()
try {
mCapture.stop()
mCapture.release()
}catch (_:Exception){}
mPlayers.values.forEach { it.stop() }
super.interrupt()
}
Expand Down

0 comments on commit 9fd06de

Please sign in to comment.