pad-block-deadlock.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.CompletableFuture; | |
import java.util.concurrent.ExecutionException; | |
import java.util.concurrent.TimeUnit; | |
import java.util.concurrent.TimeoutException; | |
import org.freedesktop.gstreamer.Element; | |
import org.freedesktop.gstreamer.Gst; | |
import org.freedesktop.gstreamer.Pad; | |
import org.freedesktop.gstreamer.Pipeline; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
public class Main { | |
private static final Logger log = LoggerFactory.getLogger(Main.class); | |
public static void main(String[] args) throws InterruptedException, ExecutionException, TimeoutException { | |
Gst.init(); | |
Pipeline pipeline = (Pipeline) Gst | |
.parseLaunch("audiotestsrc name=src ! fakesink sync=false"); | |
pipeline.play(); | |
Element src = pipeline.getElementByName("src"); | |
Pad srcPad = src.getStaticPad("src"); | |
//noinspection InfiniteLoopStatement | |
while (true) { | |
log.info("> blocking"); | |
CompletableFuture<Void> future = new CompletableFuture<>(); | |
srcPad.block(() -> { | |
log.info("= blocked"); | |
future.complete(null); | |
log.info("= completed"); | |
}); | |
log.info("< getting"); | |
future.get(10, TimeUnit.SECONDS); | |
log.info("< got"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment