From 50025100efc985799bbcd7033c67f52c0a37cba9 Mon Sep 17 00:00:00 2001
From: Besmir Beqiri <bb@sandec.de>
Date: Thu, 17 Oct 2024 19:46:46 +0200
Subject: [PATCH] Install `GStreamer and Plugins` (for Linux) and setup a
 Virtual Audio Device (for Linux)

---
 .github/workflows/main.yml | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index e021736e..79a0d350 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -3,6 +3,8 @@ name: CI build
 on: [push]
 
 env:
+  DISPLAY: ":99"
+  XVFB_PARAMS: "-screen 0 1920x1080x24"
   RUNNING_ON_CI: true
 
 jobs:
@@ -11,8 +13,8 @@ jobs:
     runs-on: ${{ matrix.os }}
     strategy:
       matrix:
-        jdk: [21, 23]
-        os: [ubuntu-latest, windows-latest] #, macos-13]
+        jdk: [17, 21, 23]
+        os: [ubuntu-latest, windows-latest]
       fail-fast: false
       max-parallel: 6
     timeout-minutes: 30
@@ -27,19 +29,40 @@ jobs:
           distribution: 'temurin'
           java-version: ${{ matrix.jdk }}
 
+      - name: Install GStreamer and Plugins (Linux)
+        if: runner.os == 'Linux'
+        run: |
+          sudo apt-get update
+          sudo apt-get install -y \
+            libgstreamer1.0-0 \
+            gstreamer1.0-libav \
+            gstreamer1.0-plugins-base \
+            gstreamer1.0-plugins-good \
+            gstreamer1.0-plugins-bad \
+            gstreamer1.0-plugins-ugly
+
+      - name: Set up Virtual Audio Device (Linux)
+        if: runner.os == 'Linux'
+        run: |
+          sudo apt-get install -y pulseaudio
+          pulseaudio --start --exit-idle-time=-1
+          pacmd load-module module-null-sink sink_name=DummyOutput
+
       - name: Compile
         run: |
           ./gradlew jar
           ./gradlew example:jar
 
+      - name: Set up Virtual Display (for Linux)
+        if: runner.os == 'Linux'
+        run: |
+          Xvfb ${{env.DISPLAY}} ${{env.XVFB_PARAMS}} &
+
       - name: Test
         run: |
-          if [[ "$RUNNER_OS" == "Linux" ]]; then
-            export DISPLAY=:99.0 && /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16;
-          fi
           ./gradlew test
         shell: bash
 
       - name: Javadoc
         run: |
-          ./gradlew javadoc
\ No newline at end of file
+          ./gradlew javadoc