Make Spotify work with gstreamer-1.0.

This commit is contained in:
David Sansome 2014-09-21 22:39:30 +10:00
parent a2408f7c0e
commit 3f0dc01b06
3 changed files with 7 additions and 20 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 14)
set(SPOTIFY_BLOB_VERSION 15)

View File

@ -111,6 +111,7 @@ bool MediaPipeline::Init(int sample_rate, int channels) {
"format", G_TYPE_STRING, format,
"rate", G_TYPE_INT, sample_rate,
"channels", G_TYPE_INT, channels,
"layout", G_TYPE_STRING, "interleaved",
nullptr);
gst_app_src_set_caps(appsrc_, caps);
@ -129,7 +130,7 @@ bool MediaPipeline::Init(int sample_rate, int channels) {
void MediaPipeline::WriteData(const char* data, qint64 length) {
if (!is_initialised()) return;
GstBuffer* buffer = gst_buffer_new_and_alloc(length);
GstBuffer* buffer = gst_buffer_new_allocate(nullptr, length, nullptr);
GstMapInfo map_info;
gst_buffer_map(buffer, &map_info, GST_MAP_WRITE);
@ -137,12 +138,10 @@ void MediaPipeline::WriteData(const char* data, qint64 length) {
gst_buffer_unmap(buffer, &map_info);
GST_BUFFER_OFFSET(buffer) = offset_bytes_;
GST_BUFFER_TIMESTAMP(buffer) = offset_bytes_ * kNsecPerSec / byte_rate_;
GST_BUFFER_PTS(buffer) = offset_bytes_ * kNsecPerSec / byte_rate_;
GST_BUFFER_DURATION(buffer) = length * kNsecPerSec / byte_rate_;
offset_bytes_ += length;
GST_BUFFER_OFFSET_END(buffer) = offset_bytes_;
gst_app_src_push_buffer(appsrc_, buffer);
}

View File

@ -367,27 +367,15 @@ bool GstEnginePipeline::Init() {
g_object_set(G_OBJECT(queue_), "use-buffering", true, nullptr);
}
gst_element_link(queue_, audioconvert_);
gst_element_link_many(queue_, audioconvert_, convert_sink, nullptr);
// Create the caps to put in each path in the tee. The scope path gets 16-bit
// ints and the audiosink path gets float32.
// Link the elements with special caps
// The scope path through the tee gets 16-bit ints.
GstCaps* caps16 = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "S16LE",
NULL);
GstCaps* caps32 = gst_caps_new_simple ("audio/x-raw",
"format", G_TYPE_STRING, "F32LE",
NULL);
if (mono_playback_) {
gst_caps_set_simple(caps32, "channels", G_TYPE_INT, 1, nullptr);
}
// Link the elements with special caps
gst_element_link_filtered(probe_converter, probe_sink, caps16);
gst_element_link_filtered(audioconvert_, convert_sink, caps32);
gst_caps_unref(caps16);
gst_caps_unref(caps32);
// Link the outputs of tee to the queues on each path.
gst_pad_link(gst_element_get_request_pad(tee, "src_%u"),