【发布时间】:2018-06-06 18:44:55
【问题描述】:
我正在尝试使用 gstaudiomixer 从我动态添加和删除的两个源元素中混合音频。
+---------+ +------------+
| source1 |--->| |
+---------+ | | +-----------+
| audiomixer |--->| audiosink |
+---------+ | | +-----------+
| source2 |--->| |
+---------+ +------------+
动态添加元素(使用请求板和板模板)似乎可以按预期工作。 但是,当动态移除焊盘时,会导致管道冻结。
这是我用来删除元素的代码:
public void remove(Gst.Element? element)
{
/* Removes the element from the pipeline */
if (element == null) return;
element.set_state(Gst.State.NULL); // Stop it from streaming data
element.unlink(this.mixer);
this.pipeline.remove(element);
}
这是我第二次尝试,试图挡住垫子:
public void remove(Gst.Element? element)
{
/* Removes the element from the pipeline */
if (element == null) return;
element.get_static_pad("src").get_peer().add_probe(Gst.PadProbeType.IDLE, (pad, info) => {
element.set_state(Gst.State.NULL); // Stop it from streaming data
element.unlink(this.mixer);
this.pipeline.remove(element);
return Gst.PadProbeReturn.REMOVE;
});
}
这样做的正确方法是什么?
【问题讨论】: