简体   繁体   English

Gstreamer Android更改管道状态问题

[英]Gstreamer Android changing pipeline state issue

I am working at a player based on gstreamer tutorials. 我正在根据gstreamer教程在播放器上工作。 For this I created a pipeline using: 为此,我使用以下方法创建了管道:

pipeline    = gst_pipeline_new("audio-player");

//adding also 3 gstreamer elements
appsrc      = gst_element_factory_make("appsrc", "source");
decoder     = gst_element_factory_make("faad", "aac-decoder");
sink        = gst_element_factory_make("autoaudiosink", "audio-output");

//adding and linking the elements to the pipeline
gst_bin_add_many (GST_BIN (pipeline), appsrc, decoder, sink, NULL);
gst_element_link_many(appsrc, decoder,sink, NULL);

//for appsrc was added a callback function need_data_cb
g_signal_connect(appsrc, "need-data", (GCallback)need_data_cb, data);

//state of pipeline is set to playing
gst_element_set_state(pipeline, GST_STATE_PLAYING);

In need_data_cb function I have a buffer that I want to be played: 在need_data_cb函数中,我有一个要播放的缓冲区:

g_signal_emit_by_name(appsrc, "push-buffer", buffer, &ret);

My poblem is this: I have the same code in Linux and in Android. 我的难题是:在Linux和Android中,我有相同的代码。 In Linux buffer is played well each time it enters the callback function need_data_cb. 在Linux中,缓冲区每次进入回调函数need_data_cb时都可以很好地播放。 In Android it plays the buffer just the first time it enters in need_data_cb and after that no sound. 在Android中,它只是在第一次进入need_data_cb时播放缓冲区,此后没有声音。 Why it happens this when I have same code in both versions. 当我在两个版本中都有相同的代码时,为什么会发生这种情况? If I add in need_data_cb Android version to change pipeline states to pause and play before adding buffer to appsrc, it plays each time buffer but with some interruptions between each call. 如果我在Android版本中添加了need_data_cb Android版本以将管道状态更改为暂停并播放,然后再将缓冲区添加到appsrc,则它将播放每个时间缓冲区,但每次调用之间都会有一些中断。

//the first 2 lines added in Android version to play each time buffer
gst_element_set_state(pipeline, GST_STATE_PAUSED);
gst_element_set_state(pipeline, GST_STATE_PLAYING);
g_signal_emit_by_name(appsrc, "push-buffer", buffer, &ret);

The question is why on Linux works fine without these lines and on Android not? 问题是为什么在没有这些限制的情况下在Linux上可以正常工作而在Android上则不能呢? On Linux I installed gstreamer 0.10 version, and on Android I used the libs from gstreamer sdk tutorials. 在Linux上,我安装了gstreamer 0.10版本,在Android上,我使用了gstreamer sdk教程中的库。 Do you have any hint for my problem? 您对我的问题有什么暗示吗?

Thanks, Radu 谢谢Radu

The problem was due to the emulator. 问题出在模拟器上。 On device everything was ok. 在设备上一切正常。 Do not use emulators try debugging directly on device!!! 不要使用模拟器尝试直接在设备上调试!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM