Skip to content

Commit

Permalink
Fixes race condition on single, shared BufferedImage instance produce…
Browse files Browse the repository at this point in the history
…d by Java2DFrameConverter.

Signed-off-by: Ralph Gasser <[email protected]>
  • Loading branch information
ppanopticon committed Dec 22, 2023
1 parent 9ecaf6d commit e59760e
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ class VideoDecoder : DecoderFactory {
/** [KLogger] instance. */
private val logger: KLogger = KotlinLogging.logger {}

/** The [Java2DFrameConverter] used by this [VideoDecoder] instance. */
private val converter: Java2DFrameConverter by lazy { Java2DFrameConverter() }

/**
* Converts this [VideoDecoder] to a [Flow] of [Content] elements.
*
Expand Down Expand Up @@ -113,7 +110,7 @@ class VideoDecoder : DecoderFactory {
* @param source The [ProducerScope]'s to send [ContentElement] to.
*/
private suspend fun emitImageContent(frame: Frame, source: Source, channel: ProducerScope<ContentElement<*>>) {
val image = this.context.contentFactory.newImageContent(this.converter.convert(frame))
val image = this.context.contentFactory.newImageContent(Java2DFrameConverter().convert(frame))
val timestampNs: Long = frame.timestamp * 1000 // Convert microseconds to nanoseconds
channel.send(object : ImageContent by image, SourcedContent.Temporal {
override val source: Source = source
Expand Down

0 comments on commit e59760e

Please sign in to comment.