From c4c0f6f125bdb9a31e84d5df9fe0e27ea14271c7 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 26 Mar 2014 08:14:08 -0700 Subject: [PATCH] Kill VideoContext::Get() --- src/ass_exporter.cpp | 3 ++- src/crash_writer.h | 2 +- src/dialog_style_manager.cpp | 2 +- src/main.cpp | 1 - src/main.h | 4 ++-- src/subs_controller.cpp | 6 +++--- src/subtitle_format.cpp | 19 ++++++++----------- src/subtitle_format.h | 11 +++-------- src/subtitle_format_ass.cpp | 4 ++-- src/subtitle_format_ass.h | 4 ++-- src/subtitle_format_ebu3264.cpp | 2 +- src/subtitle_format_ebu3264.h | 2 +- src/subtitle_format_encore.cpp | 4 ++-- src/subtitle_format_encore.h | 2 +- src/subtitle_format_microdvd.cpp | 8 ++++---- src/subtitle_format_microdvd.h | 4 ++-- src/subtitle_format_mkv.cpp | 2 +- src/subtitle_format_mkv.h | 2 +- src/subtitle_format_srt.cpp | 4 ++-- src/subtitle_format_srt.h | 4 ++-- src/subtitle_format_transtation.cpp | 4 ++-- src/subtitle_format_transtation.h | 2 +- src/subtitle_format_ttxt.cpp | 4 ++-- src/subtitle_format_ttxt.h | 4 ++-- src/subtitle_format_txt.cpp | 4 ++-- src/subtitle_format_txt.h | 4 ++-- src/subtitles_provider_csri.cpp | 3 ++- src/video_context.cpp | 7 ------- src/video_context.h | 2 -- 29 files changed, 54 insertions(+), 70 deletions(-) diff --git a/src/ass_exporter.cpp b/src/ass_exporter.cpp index fa2da55fe..ff8605ed2 100644 --- a/src/ass_exporter.cpp +++ b/src/ass_exporter.cpp @@ -41,6 +41,7 @@ #include "compat.h" #include "include/aegisub/context.h" #include "subtitle_format.h" +#include "video_context.h" #include #include @@ -93,7 +94,7 @@ void AssExporter::Export(agi::fs::path const& filename, std::string const& chars if (!writer) throw "Unknown file type."; - writer->WriteFile(&subs, filename, charset); + writer->WriteFile(&subs, filename, c->videoController->FPS(), charset); } wxSizer *AssExporter::GetSettingsSizer(std::string const& name) { diff --git a/src/crash_writer.h b/src/crash_writer.h index ab1c7e717..cf3a2e0a0 100644 --- a/src/crash_writer.h +++ b/src/crash_writer.h @@ -24,4 +24,4 @@ namespace crash_writer { void Write(); void Write(std::string const& error); -} \ No newline at end of file +} diff --git a/src/dialog_style_manager.cpp b/src/dialog_style_manager.cpp index d6ac56962..f4f633374 100644 --- a/src/dialog_style_manager.cpp +++ b/src/dialog_style_manager.cpp @@ -589,7 +589,7 @@ void DialogStyleManager::OnCurrentImport() { if (!reader) wxMessageBox("Unsupported subtitle format", "Error", wxOK | wxICON_ERROR | wxCENTER, this); else - reader->ReadFile(&temp, filename, charset); + reader->ReadFile(&temp, filename, 0, charset); } catch (agi::Exception const& err) { wxMessageBox(to_wx(err.GetChainedMessage()), "Error", wxOK | wxICON_ERROR | wxCENTER, this); diff --git a/src/main.cpp b/src/main.cpp index a14800891..a1806d256 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -206,7 +206,6 @@ bool AegisubApp::OnInit() { agi::util::SetThreadName("AegiMain"); StartupLog("Inside OnInit"); - frame = nullptr; try { // Initialize randomizer StartupLog("Initialize random generator"); diff --git a/src/main.h b/src/main.h index b28231e13..d8ba735cc 100644 --- a/src/main.h +++ b/src/main.h @@ -67,11 +67,11 @@ class AegisubApp : public wxApp { // our ticket to catch exceptions happening in event handlers. void HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const override; - FrameMain *frame; + FrameMain *frame = nullptr; public: AegisubApp(); AegisubLocale locale; - Automation4::AutoloadScriptManager *global_scripts; + Automation4::AutoloadScriptManager *global_scripts = nullptr; // Apple events void MacOpenFile(const wxString &filename); diff --git a/src/subs_controller.cpp b/src/subs_controller.cpp index 8a5085d6a..dabc511e9 100644 --- a/src/subs_controller.cpp +++ b/src/subs_controller.cpp @@ -186,7 +186,7 @@ void SubsController::Load(agi::fs::path const& filename, std::string charset) { const SubtitleFormat *reader = SubtitleFormat::GetReader(filename, charset); AssFile temp; - reader->ReadFile(&temp, filename, charset); + reader->ReadFile(&temp, filename, context->videoController->FPS(), charset); // Make sure the file has at least one style and one dialogue line if (temp.Styles.empty()) @@ -256,7 +256,7 @@ void SubsController::Save(agi::fs::path const& filename, std::string const& enco FileSave(); - writer->WriteFile(context->ass.get(), filename, encoding); + writer->WriteFile(context->ass.get(), filename, 0, encoding); } catch (...) { autosaved_commit_id = old_autosaved_commit_id; @@ -311,7 +311,7 @@ agi::fs::path SubsController::AutoSave() { path /= str(boost::format("%s.%s.AUTOSAVE.ass") % name.string() % agi::util::strftime("%Y-%m-%d-%H-%M-%S")); - SubtitleFormat::GetWriter(path)->WriteFile(context->ass.get(), path); + SubtitleFormat::GetWriter(path)->WriteFile(context->ass.get(), path, 0); autosaved_commit_id = commit_id; return path; diff --git a/src/subtitle_format.cpp b/src/subtitle_format.cpp index 9a1aa57bf..933c5b15c 100644 --- a/src/subtitle_format.cpp +++ b/src/subtitle_format.cpp @@ -106,15 +106,14 @@ bool SubtitleFormat::CanSave(const AssFile *subs) const { return true; } -agi::vfr::Framerate SubtitleFormat::AskForFPS(bool allow_vfr, bool show_smpte) { +agi::vfr::Framerate SubtitleFormat::AskForFPS(bool allow_vfr, bool show_smpte, agi::vfr::Framerate const& fps) { wxArrayString choices; - // Video FPS - VideoContext *context = VideoContext::Get(); - bool vidLoaded = context->TimecodesLoaded(); - if (vidLoaded) { - if (!context->FPS().IsVFR()) - choices.Add(wxString::Format(_("From video (%g)"), context->FPS().FPS())); + bool vidLoaded = false; + if (fps.IsLoaded()) { + vidLoaded = true; + if (!fps.IsVFR()) + choices.Add(wxString::Format(_("From video (%g)"), fps.FPS())); else if (allow_vfr) choices.Add(_("From video (VFR)")); else @@ -152,7 +151,7 @@ agi::vfr::Framerate SubtitleFormat::AskForFPS(bool allow_vfr, bool show_smpte) { --choice; switch (choice) { - case -1: return context->FPS(); break; // VIDEO + case -1: return fps; break; case 0: return Framerate(15, 1); break; case 1: return Framerate(24000, 1001); break; case 2: return Framerate(24, 1); break; @@ -166,9 +165,7 @@ agi::vfr::Framerate SubtitleFormat::AskForFPS(bool allow_vfr, bool show_smpte) { case 10: return Framerate(120000, 1001); break; case 11: return Framerate(120, 1); break; } - - assert(false); - return Framerate(); + throw agi::InternalError("Out of bounds result from wxGetSingleChoiceIndex?", nullptr); } void SubtitleFormat::StripTags(AssFile &file) { diff --git a/src/subtitle_format.h b/src/subtitle_format.h index c8e241743..6e64a9c2b 100644 --- a/src/subtitle_format.h +++ b/src/subtitle_format.h @@ -27,11 +27,6 @@ // // Aegisub Project http://www.aegisub.org/ -/// @file subtitle_format.h -/// @see subtitle_format.cpp -/// @ingroup subtitle_io -/// - #pragma once #include @@ -70,7 +65,7 @@ public: /// Prompt the user for a frame rate to use /// @param allow_vfr Include video frame rate as an option even if it's vfr /// @param show_smpte Show SMPTE drop frame option - static agi::vfr::Framerate AskForFPS(bool allow_vfr, bool show_smpte); + static agi::vfr::Framerate AskForFPS(bool allow_vfr, bool show_smpte, agi::vfr::Framerate const& fps); /// Constructor /// @param Subtitle format name @@ -103,13 +98,13 @@ public: /// @param[out] target Destination to read lines into /// @param filename File to load /// @param encoding Encoding to use. May be ignored by the reader. - virtual void ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& encoding) const { } + virtual void ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const { } /// Save a subtitle file /// @param src Data to write /// @param filename File to write to /// @param forceEncoding Encoding to use or empty string for default - virtual void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding="") const { } + virtual void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding="") const { } /// Get the wildcards for a save or load dialog /// @param mode 0: load 1: save diff --git a/src/subtitle_format_ass.cpp b/src/subtitle_format_ass.cpp index cda8c761b..b7d5303a1 100644 --- a/src/subtitle_format_ass.cpp +++ b/src/subtitle_format_ass.cpp @@ -45,7 +45,7 @@ std::vector AssSubtitleFormat::GetWriteWildcards() const { return {"ass", "ssa"}; } -void AssSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& encoding) const { +void AssSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const { TextFileReader file(filename, encoding); int version = !agi::fs::HasExtension(filename, "ssa"); AssParser parser(target, version); @@ -119,7 +119,7 @@ struct Writer { }; } -void AssSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const { +void AssSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const { Writer writer(filename, encoding); writer.Write(src->Info); diff --git a/src/subtitle_format_ass.h b/src/subtitle_format_ass.h index 536722fb4..5a69e7dfa 100644 --- a/src/subtitle_format_ass.h +++ b/src/subtitle_format_ass.h @@ -44,6 +44,6 @@ public: // Naturally the ASS subtitle format can save all Ass files bool CanSave(const AssFile*) const override { return true; } - void ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& forceEncoding) const override; - void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const override; + void ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& forceEncoding) const override; + void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const override; }; diff --git a/src/subtitle_format_ebu3264.cpp b/src/subtitle_format_ebu3264.cpp index ed6306134..cf5881c28 100644 --- a/src/subtitle_format_ebu3264.cpp +++ b/src/subtitle_format_ebu3264.cpp @@ -635,7 +635,7 @@ std::vector Ebu3264SubtitleFormat::GetWriteWildcards() const return formats; } -void Ebu3264SubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const&) const +void Ebu3264SubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const&) const { // collect data from user EbuExportSettings export_settings = get_export_config(nullptr); diff --git a/src/subtitle_format_ebu3264.h b/src/subtitle_format_ebu3264.h index 7cbfdb9df..c6b3b39b7 100644 --- a/src/subtitle_format_ebu3264.h +++ b/src/subtitle_format_ebu3264.h @@ -28,7 +28,7 @@ class Ebu3264SubtitleFormat final : public SubtitleFormat { public: Ebu3264SubtitleFormat(); std::vector GetWriteWildcards() const override; - void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const override; + void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const override; DEFINE_SIMPLE_EXCEPTION(ConversionFailed, agi::InvalidInputException, "subtitle_io/ebu3264/conversion_error") }; diff --git a/src/subtitle_format_encore.cpp b/src/subtitle_format_encore.cpp index aa2dc1f2f..0811850ac 100644 --- a/src/subtitle_format_encore.cpp +++ b/src/subtitle_format_encore.cpp @@ -55,8 +55,8 @@ std::vector EncoreSubtitleFormat::GetWriteWildcards() const { return formats; } -void EncoreSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const&) const { - agi::vfr::Framerate fps = AskForFPS(false, true); +void EncoreSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& video_fps, std::string const&) const { + agi::vfr::Framerate fps = AskForFPS(false, true, video_fps); if (!fps.IsLoaded()) return; // Convert to encore diff --git a/src/subtitle_format_encore.h b/src/subtitle_format_encore.h index 91e90609f..77827e8f6 100644 --- a/src/subtitle_format_encore.h +++ b/src/subtitle_format_encore.h @@ -38,5 +38,5 @@ class EncoreSubtitleFormat final : public SubtitleFormat { public: EncoreSubtitleFormat(); std::vector GetWriteWildcards() const override; - void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const&) const override; + void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const&) const override; }; diff --git a/src/subtitle_format_microdvd.cpp b/src/subtitle_format_microdvd.cpp index a579658b4..b64e16e5d 100644 --- a/src/subtitle_format_microdvd.cpp +++ b/src/subtitle_format_microdvd.cpp @@ -80,7 +80,7 @@ bool MicroDVDSubtitleFormat::CanReadFile(agi::fs::path const& filename, std::str return false; } -void MicroDVDSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& encoding) const { +void MicroDVDSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& vfps, std::string const& encoding) const { TextFileReader file(filename, encoding); target->LoadDefault(false); @@ -106,7 +106,7 @@ void MicroDVDSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& file } // If it wasn't an fps line, ask the user for it - fps = AskForFPS(true, false); + fps = AskForFPS(true, false, vfps); if (!fps.IsLoaded()) return; } @@ -123,8 +123,8 @@ void MicroDVDSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& file } } -void MicroDVDSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const { - agi::vfr::Framerate fps = AskForFPS(true, false); +void MicroDVDSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& vfps, std::string const& encoding) const { + agi::vfr::Framerate fps = AskForFPS(true, false, vfps); if (!fps.IsLoaded()) return; AssFile copy(*src); diff --git a/src/subtitle_format_microdvd.h b/src/subtitle_format_microdvd.h index a06d54db0..2ae7013d2 100644 --- a/src/subtitle_format_microdvd.h +++ b/src/subtitle_format_microdvd.h @@ -42,7 +42,7 @@ public: std::vector GetWriteWildcards() const override; bool CanReadFile(agi::fs::path const& filename, std::string const& encoding) const override; - void ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& forceEncoding) const override; + void ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& forceEncoding) const override; - void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const override; + void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const override; }; diff --git a/src/subtitle_format_mkv.cpp b/src/subtitle_format_mkv.cpp index a4f10a587..f56add910 100644 --- a/src/subtitle_format_mkv.cpp +++ b/src/subtitle_format_mkv.cpp @@ -51,6 +51,6 @@ std::vector MKVSubtitleFormat::GetReadWildcards() const { return formats; } -void MKVSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, std::string const&) const { +void MKVSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const&) const { MatroskaWrapper::GetSubtitles(filename, target); } diff --git a/src/subtitle_format_mkv.h b/src/subtitle_format_mkv.h index 8d58d35a2..207bd04f8 100644 --- a/src/subtitle_format_mkv.h +++ b/src/subtitle_format_mkv.h @@ -39,5 +39,5 @@ public: MKVSubtitleFormat(); std::vector GetReadWildcards() const override; - void ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& forceEncoding) const override; + void ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& forceEncoding) const override; }; diff --git a/src/subtitle_format_srt.cpp b/src/subtitle_format_srt.cpp index 1d8f0341e..db0cd9a47 100644 --- a/src/subtitle_format_srt.cpp +++ b/src/subtitle_format_srt.cpp @@ -351,7 +351,7 @@ enum ParseState { STATE_LAST_WAS_BLANK }; -void SRTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& encoding) const { +void SRTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const { using namespace std; TextFileReader file(filename, encoding); @@ -463,7 +463,7 @@ found_timestamps: line->Text = tag_parser.ToAss(text); } -void SRTSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const { +void SRTSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const { TextFileWriter file(filename, encoding); // Convert to SRT diff --git a/src/subtitle_format_srt.h b/src/subtitle_format_srt.h index f9d90b2a7..1947ed2ea 100644 --- a/src/subtitle_format_srt.h +++ b/src/subtitle_format_srt.h @@ -45,6 +45,6 @@ public: bool CanSave(const AssFile *file) const override; - void ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& forceEncoding) const override; - void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const override; + void ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& forceEncoding) const override; + void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const override; }; diff --git a/src/subtitle_format_transtation.cpp b/src/subtitle_format_transtation.cpp index 285551536..1c620103a 100644 --- a/src/subtitle_format_transtation.cpp +++ b/src/subtitle_format_transtation.cpp @@ -59,8 +59,8 @@ std::vector TranStationSubtitleFormat::GetWriteWildcards() const { return formats; } -void TranStationSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const { - agi::vfr::Framerate fps = AskForFPS(false, true); +void TranStationSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& vfps, std::string const& encoding) const { + agi::vfr::Framerate fps = AskForFPS(false, true, vfps); if (!fps.IsLoaded()) return; // Convert to TranStation diff --git a/src/subtitle_format_transtation.h b/src/subtitle_format_transtation.h index 831d6b2cd..02e51ceb5 100644 --- a/src/subtitle_format_transtation.h +++ b/src/subtitle_format_transtation.h @@ -43,5 +43,5 @@ class TranStationSubtitleFormat final : public SubtitleFormat { public: TranStationSubtitleFormat(); std::vector GetWriteWildcards() const override; - void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const override; + void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const override; }; diff --git a/src/subtitle_format_ttxt.cpp b/src/subtitle_format_ttxt.cpp index 0532adc57..de4c237a0 100644 --- a/src/subtitle_format_ttxt.cpp +++ b/src/subtitle_format_ttxt.cpp @@ -63,7 +63,7 @@ std::vector TTXTSubtitleFormat::GetWriteWildcards() const { return GetReadWildcards(); } -void TTXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& encoding) const { +void TTXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const { target->LoadDefault(false); // Load XML document @@ -160,7 +160,7 @@ void TTXTSubtitleFormat::ProcessHeader(wxXmlNode *node) const { // TODO } -void TTXTSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const { +void TTXTSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const { // Convert to TTXT AssFile copy(*src); ConvertToTTXT(copy); diff --git a/src/subtitle_format_ttxt.h b/src/subtitle_format_ttxt.h index 2b1e29511..cde1aaef9 100644 --- a/src/subtitle_format_ttxt.h +++ b/src/subtitle_format_ttxt.h @@ -51,6 +51,6 @@ public: std::vector GetReadWildcards() const override; std::vector GetWriteWildcards() const override; - void ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& forceEncoding) const override; - void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const override; + void ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& forceEncoding) const override; + void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const override; }; diff --git a/src/subtitle_format_txt.cpp b/src/subtitle_format_txt.cpp index 9e4d7c326..a7c2e0b91 100644 --- a/src/subtitle_format_txt.cpp +++ b/src/subtitle_format_txt.cpp @@ -68,7 +68,7 @@ bool TXTSubtitleFormat::CanWriteFile(agi::fs::path const& filename) const { return boost::iends_with(str, ".txt") && !(boost::iends_with(str, ".encore.txt") || boost::iends_with(str, ".transtation.txt")); } -void TXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& encoding) const { +void TXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const { DialogTextImport dlg; if (dlg.ShowModal() == wxID_CANCEL) return; @@ -125,7 +125,7 @@ void TXTSubtitleFormat::ReadFile(AssFile *target, agi::fs::path const& filename, } } -void TXTSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const { +void TXTSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const { size_t num_actor_names = 0, num_dialogue_lines = 0; // Detect number of lines with Actor field filled out diff --git a/src/subtitle_format_txt.h b/src/subtitle_format_txt.h index bcab95793..838fd9367 100644 --- a/src/subtitle_format_txt.h +++ b/src/subtitle_format_txt.h @@ -44,6 +44,6 @@ public: bool CanSave(const AssFile*) const override { return false; } bool CanWriteFile(agi::fs::path const& filename) const override; - void ReadFile(AssFile *target, agi::fs::path const& filename, std::string const& forceEncoding) const override; - void WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const override; + void ReadFile(AssFile *target, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& forceEncoding) const override; + void WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& fps, std::string const& encoding) const override; }; diff --git a/src/subtitles_provider_csri.cpp b/src/subtitles_provider_csri.cpp index 4d7b5fad1..245f710c5 100644 --- a/src/subtitles_provider_csri.cpp +++ b/src/subtitles_provider_csri.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -98,7 +99,7 @@ CSRISubtitlesProvider::~CSRISubtitlesProvider() { void CSRISubtitlesProvider::LoadSubtitles(AssFile *subs) { if (tempfile.empty()) tempfile = unique_path(config::path->Decode("?temp/csri-%%%%-%%%%-%%%%-%%%%.ass")); - SubtitleFormat::GetWriter(tempfile)->WriteFile(subs, tempfile, "utf-8"); + SubtitleFormat::GetWriter(tempfile)->WriteFile(subs, tempfile, 0, "utf-8"); std::lock_guard lock(csri_mutex); instance = csri_open_file(renderer, tempfile.string().c_str(), nullptr); diff --git a/src/video_context.cpp b/src/video_context.cpp index f06d5df27..4b3545dc4 100644 --- a/src/video_context.cpp +++ b/src/video_context.cpp @@ -60,14 +60,11 @@ #include -static VideoContext *instance; - VideoContext::VideoContext(agi::Context *c) : context(c) , playback(this) , playAudioOnStep(OPT_GET("Audio/Plays When Stepping Video")) { - instance = this; context->ass->AddCommitListener(&VideoContext::OnSubtitlesCommit, this); context->subsController->AddFileSaveListener(&VideoContext::OnSubtitlesSave, this); @@ -89,10 +86,6 @@ VideoContext::VideoContext(agi::Context *c) VideoContext::~VideoContext () { } -VideoContext *VideoContext::Get() { - return instance; -} - void VideoContext::Reset() { config::path->SetToken("?video", ""); diff --git a/src/video_context.h b/src/video_context.h index 280ff6aba..f4b648312 100644 --- a/src/video_context.h +++ b/src/video_context.h @@ -269,6 +269,4 @@ public: int TimeAtFrame(int frame, agi::vfr::Time type = agi::vfr::EXACT) const; int FrameAtTime(int time, agi::vfr::Time type = agi::vfr::EXACT) const; - - static VideoContext *Get(); };