You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe we could move the initialization check bit to its own function to avoid the repetition.
Also, fun init(context: Context) { ytStream = YTStream(context = context) } this can be a potential for races and deadlocks, if different threads try to invoke the init function at the same time, it can lead to unwanted results. In as much as the YoutubeStream object is singleton, the initialization function isn't, so chances of the ytStream being initialized twice are high.
I suggest we either do a single or double lock synchronization when creating the ytStream
Example:
private val lock = Any()
fun init(context: Context) {
synchronized(lock) {
if (ytStream == null) {
ytStream = YTStream(context = context)
}
}
}
It is something we can probably, think about
The text was updated successfully, but these errors were encountered:
this is in reference to https://github.com/Bizyback/youtubestream/blob/main/youtubestream/src/main/java/com/bizyback/libs/youtubestream/YoutubeStream.kt and
val stream = ytStream ?: return YoutubeStreamResult.Error(message = "YoutubeStream is not initialized, please initialize to continue \nRun `YoutubeStream.init(context)` to initialize")
Maybe we could move the initialization check bit to its own function to avoid the repetition.
Also,
fun init(context: Context) { ytStream = YTStream(context = context) }
this can be a potential for races and deadlocks, if different threads try to invoke the init function at the same time, it can lead to unwanted results. In as much as the YoutubeStream object is singleton, the initialization function isn't, so chances of theytStream
being initialized twice are high.I suggest we either do a single or double lock synchronization when creating the
ytStream
Example:
It is something we can probably, think about
The text was updated successfully, but these errors were encountered: