Keep the appsrc half full to prevent tiny stalls when libspotify is waiting to send us audio data

This commit is contained in:
David Sansome 2011-11-29 11:10:04 +00:00
parent f0923857a1
commit 332aeadec0
2 changed files with 6 additions and 4 deletions

View File

@ -1,3 +1,3 @@
# Increment this whenever the user needs to download a new blob
# Remember to upload and sign the new version of the blob.
set(SPOTIFY_BLOB_VERSION 10)
set(SPOTIFY_BLOB_VERSION 11)

View File

@ -61,7 +61,7 @@ bool MediaPipeline::Init(int sample_rate, int channels) {
return false;
}
// Add elements to the pipelin and link them
// Add elements to the pipeline and link them
gst_bin_add(GST_BIN(pipeline_), GST_ELEMENT(appsrc_));
gst_bin_add(GST_BIN(pipeline_), gdppay);
gst_bin_add(GST_BIN(pipeline_), tcpsink_);
@ -74,6 +74,10 @@ bool MediaPipeline::Init(int sample_rate, int channels) {
// We know the time of each buffer
g_object_set(G_OBJECT(appsrc_), "format", GST_FORMAT_TIME, NULL);
// Spotify only pushes data to us every 100ms, so keep the appsrc half full
// to prevent tiny stalls.
g_object_set(G_OBJECT(appsrc_), "min-percent", 50, NULL);
// Set callbacks for when to start/stop pushing data
GstAppSrcCallbacks callbacks;
callbacks.enough_data = EnoughDataCallback;
@ -122,8 +126,6 @@ void MediaPipeline::WriteData(const char* data, qint64 length) {
GST_BUFFER_TIMESTAMP(buffer) = offset_bytes_ * kNsecPerSec / byte_rate_;
GST_BUFFER_DURATION(buffer) = length * kNsecPerSec / byte_rate_;
//qLog(Debug) << GST_BUFFER_OFFSET(buffer) << GST_BUFFER_TIMESTAMP(buffer) << GST_BUFFER_DURATION(buffer);
offset_bytes_ += length;
GST_BUFFER_OFFSET_END(buffer) = offset_bytes_;