如何在 udev 规则调用的脚本内在后台运行 gstreamer 应用程序

问题描述

UDEV 规则 ( /etc/udev/rules.d/99-monitor-hotplug.rules )

KERNEL=="card4",ACTION=="change",SUBSYstem=="drm",ENV{HOTPLUG}=="1",RUN+="/usr/bin/hdmi-hotplug.sh"

下面是脚本,我在连接 HDMI TX 后立即运行,这里我通过 gstreamer 命令进行流式传输

#!/bin/sh

for i in /sys/class/drm/card4-HDMI-A-2/status ; do
status=$(cat $i);
connector=${i%/status*};
connector=${connector#*-};
if [ "$status" == "disconnected" ];
then
    echo $connector" disconnected" >>/dev/ttyPS0
    killall gst-launch-1.0
elif [ "$status" == "connected" ];
then
    modes=${i//status/modes}
    echo $connector" connected" >>/dev/ttyPS0
    modetest -D amba_pl@0:hdmitx_disp_0
    echo $modes >>/dev/ttyPS0
    resolution=$(cat $modes | head -n 1)
    echo $resolution >>/file.txt
    if [ "$resolution" = "1920x1080" ]; then
        echo "Full HD Monitor Connected" >>/dev/ttyPS0
        killall gst-launch-1.0
        modetest -D amba_pl@0:hdmitx_disp_1 -s 31:1920x1080-60@YUYV
    gst-launch-1.0 -v v4l2src device=/dev/video1 ! "video/x-raw,width=1920,height=1080,interlace-mode=(string)progressive,framerate=60/1" ! \
          kmssink bus-id="amba_pl@0:hdmitx_disp_1" force-modesetting=true sync=false &
    fi
fi
done
echo "TASK COMPLETED" >> /dev/ttyPS0

但我面临以下问题

[  805.103502] udevd[1935]: worker [1944] /devices/platform/amba_pl@0/amba_pl@0:hdmitx_disp_1/drm/card4 is taking a long time
[  925.251937] udevd[1935]: worker [1944] /devices/platform/amba_pl@0/amba_pl@0:hdmitx_disp_1/drm/card4 timeout; kill it
[  925.262577] udevd[1935]: seq 2856 '/devices/platform/amba_pl@0/amba_pl@0:hdmitx_disp_1/drm/card4' killed

如何在不阻塞 udev 的情况下运行 gstreamer 命令

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)