media-converter: Create a tag file when placeholder media are used.

CW-Bug-Id: #21473
This commit is contained in:
Arkadiusz Hiler 2022-11-03 21:42:12 +02:00
parent f053d6da15
commit babce20fc2
5 changed files with 124 additions and 0 deletions

View file

@ -31,6 +31,8 @@
use crate::format_hash;
use crate::HASH_SEED;
use crate::discarding_disabled;
use crate::steam_compat_shader_path;
use crate::touch_file;
use gst::glib;
use gst::prelude::*;
@ -633,6 +635,14 @@ impl AudioConvState {
let buf = Box::new(*include_bytes!("../../blank.ptna"));
match steam_compat_shader_path() {
None => gst::log!(CAT, "env STEAM_COMPAT_SHADER_PATH not set"),
Some(mut path) => {
path.push("placeholder-audio-used");
if let Err(e) = touch_file(path) { gst::log!(CAT, "Failed to touch placeholder-audio-used file: {:?}", e) }
},
};
Ok(buf)
}
}

View file

@ -35,8 +35,14 @@ extern crate gstreamer_video as gst_video;
extern crate gstreamer_audio as gst_audio;
extern crate once_cell;
use std::fs::File;
use std::io;
use std::io::Read;
use std::path::Path;
use std::path::PathBuf;
use filetime::FileTime;
use filetime::set_file_handle_times;
#[cfg(target_arch = "x86")]
mod murmur3_x86_128;
@ -76,6 +82,24 @@ where
a
}
fn touch_file<P>(p: P) -> io::Result<()>
where
P: AsRef<Path> + std::fmt::Debug
{
let f = File::create(p)?;
let now = FileTime::now();
set_file_handle_times(&f, Some(now), Some(now))?;
Ok(())
}
fn steam_compat_shader_path() -> Option<PathBuf>
{
match std::env::var("STEAM_COMPAT_SHADER_PATH") {
Err(_) => None,
Ok(c) => Some(Path::new(&c).to_path_buf()),
}
}
/* rust has a hard time with large heap allocations. below macro works around that.
*
* by @simias from https://github.com/rust-lang/rust/issues/53827 */

View file

@ -34,6 +34,8 @@ use crate::box_array;
use crate::copy_into_array;
use crate::BufferedReader;
use crate::discarding_disabled;
use crate::steam_compat_shader_path;
use crate::touch_file;
use gst::glib;
use gst::prelude::*;
@ -346,6 +348,14 @@ impl VideoConvState {
self.transcode_hash = None;
self.our_duration = Some(include_bytes!("../../blank.mkv").len() as u64);
match steam_compat_shader_path() {
None => gst::log!(CAT, "env STEAM_COMPAT_SHADER_PATH not set"),
Some(mut path) => {
path.push("placeholder-video-used");
if let Err(e) = touch_file(path) { gst::log!(CAT, "Failed to touch placeholder-video-used file: {:?}", e) }
},
};
false
}