Fix transition to next song in CUE files

Fixes #552
This commit is contained in:
Jonas Kvinge
2020-10-10 01:57:02 +02:00
parent 6dba40c6bb
commit b6ff7e6b47

View File

@@ -598,6 +598,10 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf
GstBuffer *buf = gst_pad_probe_info_get_buffer(info); GstBuffer *buf = gst_pad_probe_info_get_buffer(info);
GstBuffer *buf16 = nullptr; GstBuffer *buf16 = nullptr;
quint64 start_time = GST_BUFFER_TIMESTAMP(buf) - instance->segment_start_;
quint64 duration = GST_BUFFER_DURATION(buf);
qint64 end_time = start_time + duration;
if (format.startsWith("S16LE")) { if (format.startsWith("S16LE")) {
instance->unsupported_analyzer_ = false; instance->unsupported_analyzer_ = false;
} }
@@ -687,12 +691,7 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf
} }
// Calculate the end time of this buffer so we can stop playback if it's after the end time of this song. // Calculate the end time of this buffer so we can stop playback if it's after the end time of this song.
if (instance->end_offset_nanosec_ > 0) { if (instance->end_offset_nanosec_ > 0 && end_time > instance->end_offset_nanosec_) {
quint64 start_time = GST_BUFFER_TIMESTAMP(buf) - instance->segment_start_;
quint64 duration = GST_BUFFER_DURATION(buf);
qint64 end_time = start_time + duration;
if (end_time > instance->end_offset_nanosec_) {
if (instance->has_next_valid_url() && instance->next_stream_url_ == instance->stream_url_ && instance->next_beginning_offset_nanosec_ == instance->end_offset_nanosec_) { if (instance->has_next_valid_url() && instance->next_stream_url_ == instance->stream_url_ && instance->next_beginning_offset_nanosec_ == instance->end_offset_nanosec_) {
// The "next" song is actually the next segment of this file - so cheat and keep on playing, but just tell the Engine we've moved on. // The "next" song is actually the next segment of this file - so cheat and keep on playing, but just tell the Engine we've moved on.
instance->end_offset_nanosec_ = instance->next_end_offset_nanosec_; instance->end_offset_nanosec_ = instance->next_end_offset_nanosec_;
@@ -710,7 +709,6 @@ GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad *pad, GstPadProbeInf
emit instance->EndOfStreamReached(instance->id(), false); emit instance->EndOfStreamReached(instance->id(), false);
} }
} }
}
return GST_PAD_PROBE_OK; return GST_PAD_PROBE_OK;