我正在尝试运行媒体渲染器UPnP 媒体渲染器作为 upstart 作业。当我以自己的身份从命令行运行它时,一切都运行正常。当它作为 upstart 作业运行时,我收到错误消息/var/log/upstart/gmediarender
并且没有声音。错误消息因我使用的 audiosink 选项而异。如果我使用该--gstout-audiosink=pulsesink
选项,错误消息如下所示:
Assertion 'm' failed at pulse/thread-mainloop.c:166, function pa_threaded_mainloop_lock(). Aborting.
如果没有这个选项,消息看起来如下:
AL lib: alsa_open_playback: Could not open playback device 'default': Connection refused
ERROR [2014-03-23 20:57:12.621940 | gstreamer] playsink2: Error: The autoaudiosink element is not working. (Debug: gstplaysink.c(1906): gen_audio_chain (): /GstPlayBin2:play/GstPlaySink:playsink2)
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
无论我使用哪种接收器,也无论它是否是新贵的工作,我都会收到以下消息:
(gmediarender:1146): GStreamer-CRITICAL **: gst_pad_new_from_template: assertion 'GST_IS_PAD_TEMPLATE (templ)' failed
(gmediarender:1146): GStreamer-CRITICAL **: gst_pad_template_get_caps: assertion 'GST_IS_PAD_TEMPLATE (templ)' failed
(gmediarender:1146): GStreamer-CRITICAL **: gst_pad_set_caps: assertion 'GST_IS_PAD (pad)' failed
(gmediarender:1146): GStreamer-CRITICAL **: gst_element_add_pad: assertion 'GST_IS_PAD (pad)' failed
我猜我的 pulseaudio 设置可能会更好,但我想知道 upstart 在命令行上有什么不同。既然它可以在命令行上运行,我不明白为什么它不能在 upstart 上运行。我尝试在 upstart 配置中使用setuid
和节:setgid
# gmediarender - gmediarender job file
description "UPnP renderer"
author "John Reid <[email protected]>"
# Stanzas
#
# Stanzas control when and how a process is started and stopped
# See a list of stanzas here: http://upstart.ubuntu.com/wiki/Stanzas#respawn
# When to start the service
start on runlevel [2345]
# When to stop the service
stop on runlevel [016]
# Automatically restart process if crashed
respawn
# Expect gmediarender to run as a daemon
#expect daemon
# Run as john
setuid john
setgid pulse
# Start after pulseaudio
#start on started pulseaudio RESULT=ok
# Start the process
exec /usr/local/bin/gmediarender -f HTPC -u 099519151638c684ee01135a43d427ea
#exec /usr/local/bin/gmediarender -f HTPC -u 099519151638c684ee01135a43d427ea --gstout-audiosink=pulsesink
lsb_release -a
给出:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 13.10
Release: 13.10
Codename: saucy
该盒子是 mythbuntu 设置的。我收到以下消息syslog
:
Mar 23 20:57:12 htpc pulseaudio[4224]: [pulseaudio] main.c: Module load failed.
Mar 23 20:57:12 htpc pulseaudio[4224]: [pulseaudio] main.c: Failed to initialize daemon.
Mar 23 20:57:12 htpc pulseaudio[4221]: [pulseaudio] main.c: Daemon startup failed.
Mar 23 21:03:38 htpc pulseaudio[4430]: [pulseaudio] socket-server.c: bind(): Address already in use
Mar 23 21:03:38 htpc pulseaudio[4430]: [pulseaudio] module.c: Failed to load module "module-esound-protocol-unix" (argument: ""): initialization failed.
任何帮助,将不胜感激!
答案1
您无法从 upstart 作业访问 pulseaudio 接收器的原因是 pulseaudio 尚未运行。默认情况下,pulseaudio 是从用户会话启动的(也应该是)。因此,登录后运行时不会出现任何问题。
为了解决这个问题,我们应该在会话中运行依赖于正在运行的 pulseaudio 服务器的应用程序用户登录后。
或者我们可以尝试运行 pulseaudio系统范围模式,但由于这可能会导致不良的副作用,因此不建议这样做:
- 系统模式出了什么问题? 脉冲音频