ファイル
YMM4-ProxyForge/ZeroDiskProxy/Plugin/ZeroDiskProxyVideoSource.cs
T
routersys b9b0e1c2de 全UIテキストの多言語対応とYukkuriMovieMaker.Generatorサブモジュール導入による国際化基盤整備
全UIテキストをハードコードされた日本語文字列からTranslateクラス経由の多言語対応リソースへ完全移行しました。
YukkuriMovieMaker.Generatorをgitサブモジュールとして追加しソリューションファイルに組み込み、ソースジェネレータによるローカライズクラス自動生成の基盤を整えました。
ZeroDiskProxy/Localization/ディレクトリを新設し、[AutoGenLocalizer]属性を持つpartialクラスTranslateをTexts.csに定義しました。
.gitmodulesにYukkuriMovieMaker.GeneratorのGitHubリポジトリURLを登録し、サブモジュールとして管理します。
ZeroDiskProxy.slnxにYukkuriMovieMaker.Generatorプロジェクトを追加しました。
ProxyCacheManagerのプロキシ生成完了・キャンセル・失敗時のステータスメッセージをそれぞれTranslate.ProxyGenerationStatusCompleted・Translate.ProxyGenerationStatusCanceled・Translate.ProxyGenerationStatusFailedPrefixに置換しました。
ProxyGenerationItemの初期ステータス文字列をTranslate.ProxyGenerationStatusGeneratingに、格納先表示をTranslate.StorageMemory・Translate.StorageDiskに置換しました。
ZeroDiskProxySettings.NameプロパティをリテラルからTranslate.SettingsNameに変更しました。
SettingsViewModelの初期キャッシュ概要テキストをTranslate.CacheSummaryLoadingに変更しました。
キャッシュ削除ダイアログのメッセージをstring.Concatからstring.Format(Translate.CacheNoEntriesToDelete)およびstring.Format(Translate.CacheDeleteSummaryFormat, ...)に変更しました。
ダイアログタイトルをリテラルからTranslate.AppNameに変更しました。
プラグイン未初期化メッセージ・キャッシュ件数表示・メモリおよびディスク使用量表示・割当済メモリ表示をいずれもstring.FormatとTranslateキーに置き換えました。
CacheEntryViewModelのストレージ種別表示をTranslate.StorageMemory・Translate.StorageDiskに置換しました。
GenerationPopupView.xamlにxmlns:local名前空間宣言を追加し、ウィンドウタイトル・ヘッダ文言・空状態メッセージをすべて{x:Static local:Translate.XXX}バインディングに変更しました。
ZeroDiskProxySettingsView.xamlにxmlns:local名前空間宣言を追加し、設定カード説明文・全Expanderヘッダ・全ラベル・全ツールチップ・全ボタン文言・キャッシュ一覧ヘッダおよび空状態メッセージをすべて{x:Static local:Translate.XXX}バインディングに変更しました。
2026-03-24 09:56:03 +09:00

108 行
3.1 KiB
C#

using System.Numerics;
using Vortice.Direct2D1;
using Vortice.Direct2D1.Effects;
using YukkuriMovieMaker.Commons;
using YukkuriMovieMaker.Plugin.FileSource;
namespace ZeroDiskProxy.Plugin;
internal sealed class ZeroDiskProxyVideoSource : IVideoFileSource
{
private IVideoFileSource _inner;
private readonly Func<IVideoFileSource?>? _tryUpgradeSource;
private readonly AffineTransform2D _switchEffect;
private readonly ID2D1Image _output;
private readonly List<IVideoFileSource> _retiredSources = [];
private readonly object _gate = new();
private volatile bool _upgraded;
private int _disposed;
public TimeSpan Duration
{
get
{
lock (_gate)
return _inner.Duration;
}
}
public ID2D1Image Output => _output;
internal ZeroDiskProxyVideoSource(IVideoFileSource inner, IGraphicsDevicesAndContext devices)
{
_inner = inner;
_switchEffect = new AffineTransform2D(devices.DeviceContext);
_switchEffect.SetInput(0, inner.Output, true);
_switchEffect.TransformMatrix = Matrix3x2.Identity;
_output = _switchEffect.Output;
}
internal ZeroDiskProxyVideoSource(IVideoFileSource inner, IGraphicsDevicesAndContext devices, Func<IVideoFileSource?> tryUpgradeSource)
{
_inner = inner;
_switchEffect = new AffineTransform2D(devices.DeviceContext);
_switchEffect.SetInput(0, inner.Output, true);
_switchEffect.TransformMatrix = Matrix3x2.Identity;
_output = _switchEffect.Output;
_tryUpgradeSource = tryUpgradeSource;
}
public void Update(TimeSpan time)
{
if (!_upgraded && _tryUpgradeSource is not null)
{
try
{
var upgraded = _tryUpgradeSource();
if (upgraded is not null)
{
lock (_gate)
{
if (!_upgraded && Volatile.Read(ref _disposed) == 0)
{
_retiredSources.Add(_inner);
_inner = upgraded;
_switchEffect.SetInput(0, upgraded.Output, true);
_upgraded = true;
}
else
{
upgraded.Dispose();
}
}
}
}
catch { }
}
lock (_gate)
_inner.Update(time);
}
public int GetFrameIndex(TimeSpan time)
{
lock (_gate)
return _inner.GetFrameIndex(time);
}
public void Dispose()
{
if (Interlocked.Exchange(ref _disposed, 1) != 0)
return;
lock (_gate)
{
_output.Dispose();
_switchEffect.SetInput(0, null, true);
_switchEffect.Dispose();
_inner.Dispose();
foreach (var source in _retiredSources)
source.Dispose();
_retiredSources.Clear();
}
GC.SuppressFinalize(this);
}
}