mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-09-27 14:30:27 +00:00
livesync: Use fallback_duration for audio repeat buffers as well
Don't depend on upstream giving us sanely-sized buffers if we want to repeat. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1387>
This commit is contained in:
parent
474f00f8d6
commit
b8e891b5b7
1 changed files with 24 additions and 9 deletions
|
@ -1316,19 +1316,34 @@ impl LiveSync {
|
||||||
let buffer = out_buffer.make_mut();
|
let buffer = out_buffer.make_mut();
|
||||||
|
|
||||||
if !duplicate {
|
if !duplicate {
|
||||||
|
let duration = state.fallback_duration;
|
||||||
|
|
||||||
if let Some(audio_info) = &state.out_audio_info {
|
if let Some(audio_info) = &state.out_audio_info {
|
||||||
let mut map_info = buffer.map_writable().map_err(|e| {
|
let Some(size) = audio_info
|
||||||
gst::error!(CAT, imp: self, "Failed to map buffer: {}", e);
|
.convert::<Option<gst::format::Bytes>>(duration)
|
||||||
gst::FlowError::Error
|
.flatten()
|
||||||
})?;
|
.and_then(|bytes| usize::try_from(bytes).ok())
|
||||||
|
else {
|
||||||
|
gst::error!(CAT, imp: self, "Failed to calculate size of repeat buffer");
|
||||||
|
return Err(gst::FlowError::Error);
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut mapped_memory = gst::Memory::with_size(size)
|
||||||
|
.into_mapped_memory_writable()
|
||||||
|
.map_err(|_| {
|
||||||
|
gst::error!(CAT, imp: self, "Failed to map memory");
|
||||||
|
gst::FlowError::Error
|
||||||
|
})?;
|
||||||
|
|
||||||
audio_info
|
audio_info
|
||||||
.format_info()
|
.format_info()
|
||||||
.fill_silence(map_info.as_mut_slice());
|
.fill_silence(mapped_memory.as_mut_slice());
|
||||||
} else {
|
|
||||||
let duration = state.fallback_duration;
|
buffer.replace_all_memory(mapped_memory.into_memory());
|
||||||
buffer.set_duration(duration);
|
|
||||||
gst::debug!(CAT, imp: self, "Patched output buffer duration to {duration}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buffer.set_duration(duration);
|
||||||
|
gst::debug!(CAT, imp: self, "Patched output buffer duration to {duration}");
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.set_dts(dts);
|
buffer.set_dts(dts);
|
||||||
|
|
Loading…
Reference in a new issue