Gabe Kauffman
11/18/2020, 11:45 PMGuillermo Alcantara
11/18/2020, 11:47 PMwhat are you trying to do? Can't you do Single.fromCallable { <code> }.subscribeOn(Schedulers.computation())?
(Sorry for the markdown)
Gabe Kauffman
11/18/2020, 11:48 PMrenderSample()
which is providing me with raw audio data 1000s of times per secondSingle.fromCallable { <code> }.subscribeOn(Schedulers.computation())
in the callback, that won't work AFAIK since I need to define the observable outside of the callback and then only pass data through the observable in the callbackGuillermo Alcantara
11/18/2020, 11:54 PMGabe Kauffman
11/18/2020, 11:55 PMGuillermo Alcantara
11/18/2020, 11:57 PMGabe Kauffman
11/18/2020, 11:59 PMStavFX
11/19/2020, 6:24 PMcalculateAudioVolume
run on a different thread than the one renderSample
is being called on.
What you can do is have a subject of ByteBuffer instead of Double then you can handle audioSample
on another thread.Gabe Kauffman
11/19/2020, 9:02 PMval observable = publishSubject.hide().observeOn(Schedulers.computation())
.flatMap { Observable.just(AudioProcessingHelper.calculateAudioVolume(it)) }
StavFX
11/19/2020, 10:10 PMhide()
, since the other operators will do that for you anyway. And anytime you see .flatMap { Observable.just(foo) }
, you can use .map { foo }
instead.
Also now you’ll have to pay attention to whether or not you can actually still trust the content of ByteBuffer to be usable after renderSample has completed, or does the SDK recycle it, making it not-thread-safe.Gabe Kauffman
11/19/2020, 10:44 PM