commit 07/10/2025
This commit is contained in:
@@ -143,8 +143,7 @@ class AudioPlayer (var samplingrate: Int) {
|
||||
mem.write(0, data, 0, data.size)
|
||||
val pushresult = bass.BASS_StreamPutData(streamhandle, mem, data.size)
|
||||
if (pushresult==-1){
|
||||
val errcode = bass.BASS_ErrorGetCode()
|
||||
println("BASS_StreamPutData failed: $errcode")
|
||||
Logger.error { "BASS_StreamPutData failed: ${bass.BASS_ErrorGetCode()}" }
|
||||
}
|
||||
return pushresult != -1
|
||||
}
|
||||
@@ -154,32 +153,27 @@ class AudioPlayer (var samplingrate: Int) {
|
||||
if (withChime){
|
||||
val chup = contentCache.getAudioFile("chimeup")
|
||||
if (chup!=null && chup.isValid()){
|
||||
if (pushData(chup.bytes)){
|
||||
println("Chime up pushed")
|
||||
} else {
|
||||
if (!pushData(chup.bytes)){
|
||||
all_success = false
|
||||
println("Chime up failed")
|
||||
Logger.error { "Failed to push Chime Up" }
|
||||
}
|
||||
} else println("Chime Up not valid")
|
||||
} else Logger.error { "withChime=true, but Chime Up not available" }
|
||||
}
|
||||
|
||||
if (pushData(data)){
|
||||
println("Data pushed")
|
||||
} else {
|
||||
if (!pushData(data)){
|
||||
all_success = false
|
||||
println("Data push failed")
|
||||
Logger.error { "Failed to push Data ByteArray" }
|
||||
}
|
||||
|
||||
|
||||
if (withChime){
|
||||
val chdn = contentCache.getAudioFile("chimedown")
|
||||
if (chdn!=null && chdn.isValid()){
|
||||
if (pushData(chdn.bytes)){
|
||||
println("Chime down pushed")
|
||||
} else {
|
||||
if (!pushData(chdn.bytes)){
|
||||
all_success = false
|
||||
println("Chime down failed")
|
||||
Logger.error { "Failed to push Chime Down" }
|
||||
}
|
||||
} else println("Chime Down not valid")
|
||||
} else Logger.error { "withChime=true, but Chime Down not available" }
|
||||
}
|
||||
|
||||
val readsize: Long = 1024 * 1024 // read 1 MB at a time
|
||||
@@ -191,7 +185,6 @@ class AudioPlayer (var samplingrate: Int) {
|
||||
totalread += read
|
||||
}
|
||||
} while (read > 0)
|
||||
println("Finished reading stream data, total $totalread bytes read")
|
||||
bassenc.BASS_Encode_Stop(encodehandle)
|
||||
bass.BASS_StreamFree(streamhandle)
|
||||
|
||||
@@ -246,8 +239,7 @@ class AudioPlayer (var samplingrate: Int) {
|
||||
mem.write(0, data, 0, data.size)
|
||||
val pushresult = bass.BASS_StreamPutData(streamhandle, mem, data.size)
|
||||
if (pushresult==-1){
|
||||
val errcode = bass.BASS_ErrorGetCode()
|
||||
println("BASS_StreamPutData failed: $errcode")
|
||||
Logger.error { "BASS_StreamPutData failed: ${bass.BASS_ErrorGetCode()}" }
|
||||
}
|
||||
return pushresult != -1
|
||||
}
|
||||
@@ -258,39 +250,34 @@ class AudioPlayer (var samplingrate: Int) {
|
||||
if (withChime){
|
||||
val chup = contentCache.getAudioFile("chimeup")
|
||||
if (chup!=null && chup.isValid()){
|
||||
if (pushData(chup.bytes)){
|
||||
println("Chime up pushed")
|
||||
} else {
|
||||
if (!pushData(chup.bytes)){
|
||||
allsuccess = false
|
||||
println("Chime up failed")
|
||||
Logger.error { "Failed to push Chime Up" }
|
||||
}
|
||||
} else println("Chime Up not valid")
|
||||
} else Logger.error { "withChime=true, but Chime Up not available" }
|
||||
}
|
||||
sources.forEach { source ->
|
||||
if (source.isValid()) {
|
||||
// write the bytes to the stream
|
||||
if (pushData(source.bytes)){
|
||||
println("Source ${source.fileName} pushed")
|
||||
} else {
|
||||
if (!pushData(source.bytes)){
|
||||
allsuccess = false
|
||||
println("Source ${source.fileName} push failed")
|
||||
Logger.error { "Source ${source.fileName} push failed" }
|
||||
}
|
||||
|
||||
} else {
|
||||
allsuccess = false
|
||||
println("Source ${source.fileName} is not valid")
|
||||
Logger.error { "Not pushing Source=${source.fileName} because invalid" }
|
||||
}
|
||||
|
||||
}
|
||||
if (withChime){
|
||||
val chdn = contentCache.getAudioFile("chimedown")
|
||||
if (chdn!=null && chdn.isValid()){
|
||||
if (pushData(chdn.bytes)){
|
||||
println("Chime down pushed")
|
||||
} else {
|
||||
if (!pushData(chdn.bytes)){
|
||||
allsuccess = false
|
||||
println("Chime down failed")
|
||||
Logger.error { "Failed to push Chime Down" }
|
||||
}
|
||||
} else println("Chime Down not valid")
|
||||
} else Logger.error { "withChime=true, but Chime Down not available"}
|
||||
}
|
||||
|
||||
val readsize: Long = 1024 * 1024 // read 1 MB at a time
|
||||
@@ -302,7 +289,6 @@ class AudioPlayer (var samplingrate: Int) {
|
||||
totalread += read
|
||||
}
|
||||
} while (read > 0)
|
||||
println("Finished reading stream data, total $totalread bytes read")
|
||||
|
||||
|
||||
// close the encoding handle
|
||||
|
||||
Reference in New Issue
Block a user