Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorJan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>2023-10-25 13:11:01 +0300
committerJan Alexander Steffens (heftig) <jan.steffens@ltnglobal.com>2023-10-25 13:55:06 +0300
commit6633cc4046aa1f5a22ba8e1ee39a101b9b9559c5 (patch)
tree1ffcb3cbc09a667f8cd6160cb5cdf5447e1ba714 /utils
parent4ac7d0415bb7ff87aab625d92b5e6c568192730f (diff)
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/1369>
Diffstat (limited to 'utils')
-rw-r--r--utils/livesync/src/livesync/imp.rs33
1 files changed, 24 insertions, 9 deletions
diff --git a/utils/livesync/src/livesync/imp.rs b/utils/livesync/src/livesync/imp.rs
index 80730971b..f2732f639 100644
--- a/utils/livesync/src/livesync/imp.rs
+++ b/utils/livesync/src/livesync/imp.rs
@@ -1304,19 +1304,34 @@ impl LiveSync {
let buffer = out_buffer.make_mut();
if !duplicate {
+ let duration = state.fallback_duration;
+
if let Some(audio_info) = &state.out_audio_info {
- let mut map_info = buffer.map_writable().map_err(|e| {
- gst::error!(CAT, imp: self, "Failed to map buffer: {}", e);
- gst::FlowError::Error
- })?;
+ let Some(size) = audio_info
+ .convert::<Option<gst::format::Bytes>>(duration)
+ .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
.format_info()
- .fill_silence(map_info.as_mut_slice());
- } else {
- let duration = state.fallback_duration;
- buffer.set_duration(duration);
- gst::debug!(CAT, imp: self, "Patched output buffer duration to {duration}");
+ .fill_silence(mapped_memory.as_mut_slice());
+
+ 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_dts(dts);