From 032e91e4b44c77dbe1b646c4bca3aee244b275a9 Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Thu, 8 Aug 2019 03:31:57 +0200 Subject: [PATCH] mpv setting osd-scale-by-window added to config dialog --- Changelog.md | 11 +++++++++ mpv.net/Properties/AssemblyInfo.cs | 4 +-- mpv.net/Resources/inputConf.txt | 14 +++-------- mpv.net/Resources/mpvConfToml.txt | 22 +++++++++++------ mpv.net/WPF/ConfWindow.xaml.cs | 1 + mpv.net/WinForms/MainForm.Designer.cs | 2 +- mpv.net/WinForms/MainForm.cs | 35 ++++++++++++++------------- mpv.net/mpv/mp.cs | 35 +++++++++++++++------------ 8 files changed, 72 insertions(+), 52 deletions(-) diff --git a/Changelog.md b/Changelog.md index 3557625..348736f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,14 @@ +### 5.2.1.3 + +- in the config dialog the description for keep-open was corrected + because unlike mpv, mpv.net will never terminate automatically +- there was a rare occasion where the mpv.net logo wasn't shown +- mpv setting osd-scale-by-window added to config dialog + +### 5.2.1.2 + +- fix excessive memory usage using `osd-scale-by-window = no` + ### 5.2.1 - fixed race condition causing various features to fail diff --git a/mpv.net/Properties/AssemblyInfo.cs b/mpv.net/Properties/AssemblyInfo.cs index 251844b..0e62004 100644 --- a/mpv.net/Properties/AssemblyInfo.cs +++ b/mpv.net/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("5.2.1.0")] -[assembly: AssemblyFileVersion("5.2.1.0")] +[assembly: AssemblyVersion("5.2.1.3")] +[assembly: AssemblyFileVersion("5.2.1.3")] diff --git a/mpv.net/Resources/inputConf.txt b/mpv.net/Resources/inputConf.txt index f34d777..ff3444c 100644 --- a/mpv.net/Resources/inputConf.txt +++ b/mpv.net/Resources/inputConf.txt @@ -1,17 +1,11 @@ - # This file defines the input (keys and mouse) bindings of mpv and mpv.net - # and it also defines the context menu of mpv.net. mpv.net has an input - # editor and an config editor as alternative to editing conf text files. - # The input and config editor can be found in mpv.net's context menu at: - - # Settings > Show Config Editor - # Settings > Show Input Editor - - # The defaults of this file can be found at: + # This file defines the key and mouse bindings and the context menu + # of mpv.net. A input and config editor can be found in mpv.net's + # context menu under 'Settings'. The defaults of this file can be found at: # https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt - # the defaults of mpv can be found at: + # The defaults of mpv can be found at: # https://github.com/mpv-player/mpv/blob/master/etc/input.conf diff --git a/mpv.net/Resources/mpvConfToml.txt b/mpv.net/Resources/mpvConfToml.txt index 0df0091..ab19755 100644 --- a/mpv.net/Resources/mpvConfToml.txt +++ b/mpv.net/Resources/mpvConfToml.txt @@ -26,7 +26,7 @@ filter = "Video" help = "Controls which type of graphics APIs will be accepted. Auto uses d3d11, it should only be changed in case of problems." options = [{ name = "auto", help = "Use any available API" }, { name = "opengl", help = "Allow only OpenGL (requires OpenGL 2.1+ or GLES 2.0+)" }, - { name = "vulkan", help = "Allow only Vulkan (requires a valid/working spirv-compiler)" }, + { name = "vulkan", help = "Allow only Vulkan (requires a working spirv-compiler). " }, { name = "d3d11", help = "Allow only gpu-context=d3d11" }] [[settings]] @@ -241,6 +241,14 @@ default = "55" filter = "Screen" help = "Specify the OSD font size. See sub-font-size for details. Default: 55" +[[settings]] +name = "osd-scale-by-window" +default = "yes" +filter = "Screen" +help = "Whether to scale the OSD with the window size. If this is disabled, osd-font-size and other OSD options that use scaled pixels are always in actual pixels. The effect is that changing the window size won't change the OSD font size." +options = [{ name = "yes" }, + { name = "no" }] + [[settings]] name = "autofit" filter = "Screen" @@ -283,7 +291,7 @@ options = [{ name = "yes" }, name = "screenshot-high-bit-depth" default = "yes" filter = "Screen" -help = "If possible, write screenshots with a bit depth similar to the source video (default: yes). This is interesting in particular for PNG, as this sometimes triggers writing 16 bit PNGs with huge file sizes. This will also include an unused alpha channel in the resulting files if 16 bit is used." +help = "If possible, write screenshots with a bit depth similar to the source video. This is interesting in particular for PNG, as this sometimes triggers writing 16 bit PNGs with huge file sizes. This will also include an unused alpha channel in the resulting files if 16 bit is used." options = [{ name = "yes" }, { name = "no" }] @@ -291,7 +299,7 @@ options = [{ name = "yes" }, name = "screenshot-jpeg-source-chroma" default = "yes" filter = "Screen" -help = "Write JPEG files with the same chroma subsampling as the video (default: yes). If disabled, the libjpeg default is used." +help = "Write JPEG files with the same chroma subsampling as the video. If disabled, the libjpeg default is used." options = [{ name = "yes" }, { name = "no" }] @@ -329,10 +337,10 @@ options = [{ name = "yes" }, name = "keep-open" default = "no" filter = "Playback" -help = "Do not terminate when playing or seeking beyond the end of the file, and there is not next file to be played (and loop is not used). Instead, pause the player. When trying to seek beyond end of the file, the player will attempt to seek to the last frame.\n\nNormally, this will act like set pause yes on EOF, unless the keep-open-pause=no option is set." -options = [{ name = "yes", help = "Don't terminate if the current file is the last playlist entry. Equivalent to keep-open without arguments."}, - { name = "no", help = "If the current file ends, go to the next file or terminate." }, - { name = "always", help = "Like yes, but also applies to files before the last playlist entry. This means playback will never automatically advance to the next file."}] +help = "Unlike mpv, mpv.net never exits automatically." +options = [{ name = "yes", help = "Useless in mpv.net because mpv.net never terminates automatically."}, + { name = "no", help = "If the current file ends, go to the next file." }, + { name = "always", help = "Playback will never automatically advance to the next file."}] [[settings]] name = "loop-file" diff --git a/mpv.net/WPF/ConfWindow.xaml.cs b/mpv.net/WPF/ConfWindow.xaml.cs index ad5e792..c1011cf 100644 --- a/mpv.net/WPF/ConfWindow.xaml.cs +++ b/mpv.net/WPF/ConfWindow.xaml.cs @@ -193,6 +193,7 @@ namespace mpvnet { SearchControl.SearchTextBox.SelectAll(); Keyboard.Focus(SearchControl.SearchTextBox); + foreach (var i in MainStackPanel.Children.OfType()) i.Update(); } diff --git a/mpv.net/WinForms/MainForm.Designer.cs b/mpv.net/WinForms/MainForm.Designer.cs index d1bc08d..4ed320e 100644 --- a/mpv.net/WinForms/MainForm.Designer.cs +++ b/mpv.net/WinForms/MainForm.Designer.cs @@ -45,7 +45,7 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(288F, 288F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.BackColor = System.Drawing.Color.Black; - this.ClientSize = new System.Drawing.Size(542, 0); + this.ClientSize = new System.Drawing.Size(668, 345); this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); diff --git a/mpv.net/WinForms/MainForm.cs b/mpv.net/WinForms/MainForm.cs index 85c5f87..5d34ca4 100644 --- a/mpv.net/WinForms/MainForm.cs +++ b/mpv.net/WinForms/MainForm.cs @@ -33,6 +33,22 @@ namespace mpvnet Instance = this; Hwnd = Handle; mp.Init(); + + mp.Shutdown += Shutdown; + mp.VideoSizeChanged += VideoSizeChanged; + mp.FileLoaded += FileLoaded; + mp.Idle += Idle; + + mp.observe_property_bool("fullscreen", PropChangeFullscreen); + mp.observe_property_bool("ontop", PropChangeOnTop); + mp.observe_property_bool("border", PropChangeBorder); + mp.observe_property_string("sid", PropChangeSid); + mp.observe_property_string("aid", PropChangeAid); + mp.observe_property_string("vid", PropChangeVid); + mp.observe_property_int("edition", PropChangeEdition); + + if (mp.GPUAPI != "vulkan") mp.ProcessCommandLine(false); + AppDomain.CurrentDomain.UnhandledException += (sender, e) => Msg.ShowError(e.ExceptionObject.ToString()); Application.ThreadException += (sender, e) => Msg.ShowException(e.Exception); Msg.SupportURL = "https://github.com/stax76/mpv.net#support"; @@ -67,22 +83,6 @@ namespace mpvnet Left = posX - Width / 2; Top = posY - Height / 2; } - - mp.Shutdown += Shutdown; - mp.VideoSizeChanged += VideoSizeChanged; - mp.FileLoaded += FileLoaded; - mp.Idle += Idle; - - mp.observe_property_bool("fullscreen", PropChangeFullscreen); - mp.observe_property_bool("ontop", PropChangeOnTop); - mp.observe_property_bool("border", PropChangeBorder); - mp.observe_property_string("sid", PropChangeSid); - mp.observe_property_string("aid", PropChangeAid); - mp.observe_property_string("vid", PropChangeVid); - mp.observe_property_int("edition", PropChangeEdition); - - if (mp.GPUAPI != "vulkan") mp.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold); - if (Height < FontHeight * 4) SetFormPosAndSize(); } catch (Exception ex) { @@ -510,7 +510,8 @@ namespace mpvnet protected override void OnLoad(EventArgs e) { base.OnLoad(e); - if (mp.get_property_int("playlist-count") == 0) mp.ShowLogo(); + if (mp.GPUAPI != "vulkan") mp.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold); + SetFormPosAndSize(); } protected override void OnShown(EventArgs e) diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index 824e56b..9f1d7f0 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -113,7 +113,6 @@ namespace mpvnet mpv_initialize(Handle); Initialized?.Invoke(); LoadMpvScripts(); - if (GPUAPI != "vulkan") ProcessCommandLine(false); } public static void ProcessProperty(string name, string value) @@ -339,7 +338,7 @@ namespace mpvnet break; case mpv_event_id.MPV_EVENT_IDLE: Idle?.Invoke(); - if (get_property_int("playlist-count") == 0) ShowLogo(); + ShowLogo(); break; case mpv_event_id.MPV_EVENT_PAUSE: Pause?.Invoke(); @@ -377,19 +376,22 @@ namespace mpvnet var propData = (mpv_event_property)Marshal.PtrToStructure(evt.data, typeof(mpv_event_property)); if (propData.format == mpv_format.MPV_FORMAT_FLAG) - foreach (var i in BoolPropChangeActions) - if (i.Key== propData.name) - i.Value.Invoke(Marshal.PtrToStructure(propData.data) == 1); + lock (BoolPropChangeActions) + foreach (var i in BoolPropChangeActions) + if (i.Key== propData.name) + i.Value.Invoke(Marshal.PtrToStructure(propData.data) == 1); if (propData.format == mpv_format.MPV_FORMAT_STRING) - foreach (var i in StringPropChangeActions) - if (i.Key == propData.name) - i.Value.Invoke(StringFromNativeUtf8(Marshal.PtrToStructure(propData.data))); + lock (StringPropChangeActions) + foreach (var i in StringPropChangeActions) + if (i.Key == propData.name) + i.Value.Invoke(StringFromNativeUtf8(Marshal.PtrToStructure(propData.data))); if (propData.format == mpv_format.MPV_FORMAT_INT64) - foreach (var i in IntPropChangeActions) - if (i.Key == propData.name) - i.Value.Invoke(Marshal.PtrToStructure(propData.data)); + lock (IntPropChangeActions) + foreach (var i in IntPropChangeActions) + if (i.Key == propData.name) + i.Value.Invoke(Marshal.PtrToStructure(propData.data)); break; case mpv_event_id.MPV_EVENT_PLAYBACK_RESTART: PlaybackRestart?.Invoke(); @@ -548,7 +550,8 @@ namespace mpvnet if (err < 0) throw new Exception($"{name}: {(mpv_error)err}"); else - IntPropChangeActions.Add(new KeyValuePair>(name, action)); + lock (IntPropChangeActions) + IntPropChangeActions.Add(new KeyValuePair>(name, action)); } public static void observe_property_bool(string name, Action action) @@ -558,7 +561,8 @@ namespace mpvnet if (err < 0) throw new Exception($"{name}: {(mpv_error)err}"); else - BoolPropChangeActions.Add(new KeyValuePair>(name, action)); + lock (BoolPropChangeActions) + BoolPropChangeActions.Add(new KeyValuePair>(name, action)); } public static void observe_property_string(string name, Action action) @@ -568,7 +572,8 @@ namespace mpvnet if (err < 0) throw new Exception($"{name}: {(mpv_error)err}"); else - StringPropChangeActions.Add(new KeyValuePair>(name, action)); + lock (StringPropChangeActions) + StringPropChangeActions.Add(new KeyValuePair>(name, action)); } public static void ProcessCommandLine(bool preInit) @@ -631,8 +636,8 @@ namespace mpvnet if (files.Count == 0 || files[0].Contains("://")) { - VideoSizeAutoResetEvent.Set(); VideoSizeChanged?.Invoke(); + VideoSizeAutoResetEvent.Set(); } } }