[gst-devel] Audio playback resumes in the wrong place after pause
Thomas Okken
tokken at research.att.com
Fri Nov 19 17:07:25 CET 2010
I'm having a problem with audio playback using GStreamer: I can create
and run the pipeline, and the audio plays just fine, but when I pause
and then unpause the pipeline, playback does not resume where it was
interrupted, but somewhere (much) farther along.
This program demonstrates the problem:
#include <stdio.h>
#include <unistd.h>
#include <gst/gst.h>
int main(int argc, char *argv[]) {
int t1 = 0, t2 = 0;
GError *error = NULL;
GstElement *pipeline;
if (argc >= 2)
sscanf(argv[1], "%d", &t1);
if (argc >= 3)
sscanf(argv[2], "%d", &t2);
gst_init(NULL, NULL);
pipeline = gst_parse_launch("filesrc location=zero_to_twenty.au !
auparse ! autoaudiosink", &error);
if (pipeline == NULL) {
g_printerr("Build pipeline error: %s\n", error->message);
return 1;
}
gst_element_set_state(pipeline, GST_STATE_PLAYING);
if (t1 > 0) {
sleep(t1);
gst_element_set_state(pipeline, GST_STATE_PAUSED);
if (t2 > 0) {
sleep(t2);
gst_element_set_state(pipeline, GST_STATE_PLAYING);
}
}
sleep(22 - t1 - t2);
return 0;
}
The audio file I use for testing is
http://service.research.att.com/tokken/zero_to_twenty.au
I run the program like
./pausetest 4 2
which will start playback, wait 4 seconds, pause, wait 2 second,
unpause, then let playback run to the end.
When I do this on my PC, playback resumes a little over four seconds
after the place where it was paused; it should resume just before the
fourth beep, but instead it resumes just after the eighth. Different
timings for the pause/unpause calls cause somewhat different results;
even the starting point is somewhat erratic.
Is there a way to pause and resume a pipeline without losing data like
this? It seems strange that I can't control playback with any accuracy.
Am I doing something wrong or is my platform buggy?
I'm doing this on a Dell Optiplex 960 running a fully updated Ubuntu
10.04.1 LTS; the gstreamer packages on my system are
gstreamer0.10-alsa 0.10.28-1
gstreamer0.10-gnonlin 0.10.15-1
gstreamer0.10-nice 0.0.10-2build1
gstreamer0.10-plugins-base 0.10.28-1
gstreamer0.10-plugins-base-apps 0.10.28-1
gstreamer0.10-plugins-good 0.10.21-1ubuntu3
gstreamer0.10-pulseaudio 0.10.21-1ubuntu3
gstreamer0.10-tools 0.10.28-1
gstreamer0.10-x 0.10.28-1
- Thomas
More information about the gstreamer-devel
mailing list