I was able to resolve my problem taking a slightly different approach, but I only found this solution after thinking about your solution.
I used glib::spawn_future_local
and async-channel to asynchronously await the spawned ffmpeg process until completion.
let (tx, rx) = async_channel::bounded(1);
glib::spawn_future_local(clone!(@strong tx => async move {
if let Ok(path) = generate_thumbnail_image(&absolute_path).await {
tx.send(path).await.expect("Async channel needs to be open.");
} else {
g_critical!("LibraryView", "FFmpeg failed to generate a thumbnail image.");
}
}));
glib::spawn_future_local(clone!(@weak image => async move {
while let Ok(path) = rx.recv().await {
image.clear();
image.set_file(Some(&path));
}
}));
Thank you again for your help!