Skip to content

Commit 98a8f15

Browse files
committed
Updates to v3.7.14 (FlyleafLib) / v1.2.21 (FlyleafME) / v1.0.7 (FlyleafHost.WinUI)
- AudioDecoder: Fixes a possible AccessViolation issue during re-allocation of the Circular Buffer - AudioDecoder: Fixes a sync issue with audio filters and speed - FlyleafHost.WinForms: Fixes an issue with the designer (when using FFmpeg.Autogen v6) - FlyleafHost.Wpf: Adds support for grand childs and FlyleafHosts within other FlyleafHost's overlay - FlyleafHost.Wpf: Fixes issues with windows activation and mouse events (mainly for detached windows) - FlyleafHost.Wpf: Fixes issues and improves ratio resize - FlyleafHost.Wpf: Fixes an issue with CornerRadius and background color - Sample: Fixes issues when swapping players
1 parent 068953b commit 98a8f15

18 files changed

Lines changed: 270 additions & 115 deletions

File tree

FlyleafLib.Controls.WPF/FlyleafLib.Controls.WPF.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFrameworks>net7.0-windows;net6.0-windows;net472</TargetFrameworks>
55
<UseWindowsForms>true</UseWindowsForms>
66
<UseWPF>true</UseWPF>
7-
<Version>1.2.20</Version>
7+
<Version>1.2.21</Version>
88
<Authors>SuRGeoNix</Authors>
99
<Copyright>SuRGeoNix © 2023</Copyright>
1010
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
@@ -14,7 +14,6 @@
1414
<PackageTags>flyleaf flyleaflib flyleafme video audio wpf media player element control</PackageTags>
1515
<Description>FlyleafME: A WPF Media Element Control (based on FlyleafLib)</Description>
1616
<PackageReleaseNotes>
17-
Adds Use Filters in Audio Settings
1817
Updates FlyleafLib
1918
</PackageReleaseNotes>
2019
</PropertyGroup>

FlyleafLib.Controls.WinUI/FlyleafLib.Controls.WinUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<UseWinUI>true</UseWinUI>
88
<Nullable>enable</Nullable>
99
<Authors>SuRGeoNix</Authors>
10-
<Version>1.0.6</Version>
10+
<Version>1.0.7</Version>
1111
<Copyright>SuRGeoNix © 2023</Copyright>
1212
<PackageProjectUrl>https://github.com/SuRGeoNix/Flyleaf</PackageProjectUrl>
1313
<PackageIcon>Flyleaf.png</PackageIcon>

FlyleafLib/Controls/WPF/FlyleafHost.cs

Lines changed: 159 additions & 44 deletions
Large diffs are not rendered by default.

FlyleafLib/Controls/WinForms/FlyleafHost.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,9 @@ public void NormalScreen()
285285
// TBR: Related to Renderer's WndProc
286286
protected override void OnPaintBackground(PaintEventArgs pe)
287287
{
288-
if (Player != null && !Player.renderer.SCDisposed)
289-
Player.renderer.Present();
290-
else
288+
if (Player == null || (Player != null && !Player.WFPresent()))
291289
base.OnPaintBackground(pe);
292-
}
290+
}
293291
protected override void OnPaint(PaintEventArgs pe) { }
294292

295293
public event PropertyChangedEventHandler PropertyChanged;

FlyleafLib/Engine/Config.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ public VideoConfig Clone()
509509
/// Background color of the player's control
510510
/// </summary>
511511
public System.Windows.Media.Color
512-
BackgroundColor { get => Utils.VorticeToWPFColor(_BackgroundColor); set { Set(ref _BackgroundColor, Utils.WPFToVorticeColor(value)); player?.renderer?.UpdateBackgroundColor(); } }
512+
BackgroundColor { get => Utils.VorticeToWPFColor(_BackgroundColor); set { Set(ref _BackgroundColor, WPFToVorticeColor(value)); player?.renderer?.UpdateBackgroundColor(); } }
513513
internal Vortice.Mathematics.Color _BackgroundColor = (Vortice.Mathematics.Color)Vortice.Mathematics.Colors.Black;
514514

515515
/// <summary>

FlyleafLib/FlyleafLib.csproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageIconUrl />
99
<RepositoryUrl></RepositoryUrl>
1010
<Description>Media Player .NET Library for WinUI 3/WPF/WinForms (based on FFmpeg/DirectX)</Description>
11-
<Version>3.7.13</Version>
11+
<Version>3.7.14</Version>
1212
<Authors>SuRGeoNix</Authors>
1313
<Copyright>SuRGeoNix © 2023</Copyright>
1414
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
@@ -17,7 +17,13 @@
1717
<IncludeSymbols>true</IncludeSymbols>
1818
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1919
<PackageReleaseNotes>
20-
- FlyleafHost.WinForms: Another try to avoid designer issues
20+
- AudioDecoder: Fixes a possible AccessViolation issue during re-allocation of the Circular Buffer
21+
- AudioDecoder: Fixes a sync issue with audio filters and speed
22+
- FlyleafHost.WinForms: Fixes an issue with the designer (when using FFmpeg.Autogen v6)
23+
- FlyleafHost.Wpf: Adds support for grand childs and FlyleafHosts within other FlyleafHost's overlay
24+
- FlyleafHost.Wpf: Fixes issues with windows activation and mouse events (mainly for detached windows)
25+
- FlyleafHost.Wpf: Fixes issues and improves ratio resize
26+
- FlyleafHost.Wpf: Fixes an issue with CornerRadius and background color
2127
</PackageReleaseNotes>
2228
</PropertyGroup>
2329

FlyleafLib/MediaFramework/MediaDecoder/AudioDecoder.Filters.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,19 @@ private int SetupFilters()
8080
if (speed != 1)
8181
{
8282
if (speed >= 0.5 && speed <= 2)
83-
linkCtx = CreateFilter("atempo", $"tempo={speed.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)}", linkCtx);
83+
linkCtx = CreateFilter("atempo", $"tempo={speed.ToString("0.0000000000", System.Globalization.CultureInfo.InvariantCulture)}", linkCtx);
8484
else if ((speed > 2 & speed <= 4) || (speed >= 0.25 && speed < 0.5))
8585
{
86-
linkCtx = CreateFilter("atempo", $"tempo={Math.Sqrt(speed).ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)}", linkCtx);
87-
linkCtx = CreateFilter("atempo", $"tempo={Math.Sqrt(speed).ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)}", linkCtx);
86+
var singleAtempoSpeed = Math.Sqrt(speed);
87+
linkCtx = CreateFilter("atempo", $"tempo={singleAtempoSpeed.ToString("0.0000000000", System.Globalization.CultureInfo.InvariantCulture)}", linkCtx);
88+
linkCtx = CreateFilter("atempo", $"tempo={singleAtempoSpeed.ToString("0.0000000000", System.Globalization.CultureInfo.InvariantCulture)}", linkCtx);
8889
}
8990
else if (speed > 4 || speed >= 0.125 && speed < 0.25)
9091
{
91-
linkCtx = CreateFilter("atempo", $"tempo={Math.Pow(speed, 1.0 / 3).ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)}", linkCtx);
92-
linkCtx = CreateFilter("atempo", $"tempo={Math.Pow(speed, 1.0 / 3).ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)}", linkCtx);
93-
linkCtx = CreateFilter("atempo", $"tempo={Math.Pow(speed, 1.0 / 3).ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)}", linkCtx);
92+
var singleAtempoSpeed = Math.Pow(speed, 1.0 / 3);
93+
linkCtx = CreateFilter("atempo", $"tempo={singleAtempoSpeed.ToString("0.0000000000", System.Globalization.CultureInfo.InvariantCulture)}", linkCtx);
94+
linkCtx = CreateFilter("atempo", $"tempo={singleAtempoSpeed.ToString("0.0000000000", System.Globalization.CultureInfo.InvariantCulture)}", linkCtx);
95+
linkCtx = CreateFilter("atempo", $"tempo={singleAtempoSpeed.ToString("0.0000000000", System.Globalization.CultureInfo.InvariantCulture)}", linkCtx);
9496
}
9597
}
9698

@@ -326,7 +328,6 @@ private void ProcessFilter(AVFrame* frame)
326328
mFrame.dataLen = frame->nb_samples * ASampleBytes;
327329
if (CanTrace) Log.Trace($"Processes {Utils.TicksToTime(mFrame.timestamp)}");
328330

329-
// samples without speed (x1) - timestamps will be fixed during screaming
330331
var samplesSpeed1 = frame->nb_samples * speed;
331332
missedSamples += samplesSpeed1 - (int)samplesSpeed1;
332333
curSamples += (int)samplesSpeed1;

FlyleafLib/MediaFramework/MediaDecoder/AudioDecoder.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public ConcurrentQueue<AudioFrame>
4545
static int AOutChannels = AOutChannelLayout.nb_channels;
4646
static int ASampleBytes = av_get_bytes_per_sample(AOutSampleFormat) * AOutChannels;
4747

48+
internal Action CBufAlloc; // Informs Audio player to clear buffer pointers to avoid access violation
4849
static int cBufTimesSize = 4;
4950
int cBufTimesCur = 1;
5051
byte[] cBuf;
@@ -430,6 +431,8 @@ private void AllocateCircularBuffer(int samples)
430431
int size = Config.Decoder.MaxAudioFrames * samples * ASampleBytes * cBufTimesSize;
431432
Log.Debug($"Re-allocating circular buffer ({samples} > {cBufSamples}) with {size}bytes");
432433

434+
DisposeFrames(); // TODO: copy data
435+
CBufAlloc?.Invoke();
433436
cBuf = new byte[size];
434437
cBufPos = 0;
435438
cBufSamples = samples;

FlyleafLib/MediaFramework/MediaRenderer/Renderer.Present.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,6 @@ unsafe internal void PresentInternal(VideoFrame frame)
112112
vc.VideoProcessorBlt(vp, vpov, 0, 1, vpsa);
113113
swapChain.Present(Config.Video.VSync, PresentFlags.None);
114114

115-
if (dCompVisual != null)
116-
dCompDevice.Commit();
117-
118115
vpiv.Dispose();
119116
}
120117
else
@@ -125,9 +122,6 @@ unsafe internal void PresentInternal(VideoFrame frame)
125122
context.PSSetShaderResources(0, frame.srvs);
126123
context.Draw(6, 0);
127124
swapChain.Present(Config.Video.VSync, PresentFlags.None);
128-
129-
if (dCompVisual != null)
130-
dCompDevice.Commit();
131125
}
132126
}
133127

@@ -146,8 +140,6 @@ unsafe public void RefreshLayout()
146140
{
147141
context.ClearRenderTargetView(backBufferRtv, Config.Video._BackgroundColor);
148142
swapChain.Present(Config.Video.VSync, PresentFlags.None);
149-
if (dCompVisual != null)
150-
dCompDevice.Commit();
151143
}
152144
}
153145
catch (Exception e)

FlyleafLib/MediaFramework/MediaRenderer/Renderer.PresentOffline.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ unsafe internal void PresentOffline(VideoFrame frame, ID3D11RenderTargetView rtv
6363
context.RSSetViewport(viewport);
6464
context.PSSetShaderResources(0, frame.srvs);
6565
context.Draw(6, 0);
66-
67-
if (dCompVisual != null)
68-
dCompDevice.Commit();
6966
}
7067
}
7168

0 commit comments

Comments
 (0)