我正在开发基于gstreamer的音频应用程序。管道会将音频流传输到“ alsasink”设备。
appsrc->queue->audioconvert->audioresample->alsasink
代码如下:
...
pipeline.app_source = gst_element_factory_make ("appsrc", "audio_source");
pipeline.audio_queue = gst_element_factory_make ("queue", "audio_queue");
pipeline.audio_convert1 = gst_element_factory_make ("audioconvert", "audio_convert1");
pipeline.audio_resample = gst_element_factory_make ("audioresample", "audio_resample");
pipeline.audio_sink = gst_element_factory_make ("alsasink", "audio_sink");
g_object_set(pipeline.audio_sink, "device", "dawser:PROFILE=music", NULL);
pipeline.pipeline = gst_pipeline_new ("test-pipeline");
...
对于这个“ alsasink”元素,我想给用户一个界面来更改“ device”参数的内容,以在音频流传输时在运行时实现不同的声音效果。例如,将其值更改为“ dawser:PROFILE = game”。
当管道正在播放时,我尝试通过以下代码对其进行更改:
void change_profile() {
g_object_set(pipeline.audio_sink, "device", "dawser:PROFILE=game", NULL);
}
但是似乎没有生效。只有当我先停止管道,然后再重新启动它时,它才能起作用:
void change_profile() {
gst_element_set_state (pipeline.pipeline, GST_STATE_NULL);
g_object_set(pipeline.audio_sink, "device", "dawser:PROFILE=game", NULL);
gst_element_set_state (data.pipeline, GST_STATE_PLAYING);
}
但是它将停止音频几秒钟。我想使开关尽可能平滑。有没有更好的主意来实现这一目标?
谢谢