Skip to content

Commit 0cdd912

Browse files
committed
Updates to v3.7.10 (FlyleafLib) / v1.2.20 (FlyleafME) / v1.0.6 (FlyleafHost.WinUI)
- AudioDecoder: Fixes an issue with audio filters when the audio input channel layout is unspecified (mainly noticed with ffmpeg devices and microphones) - AudioDecoder: Improves speed quality and adds atempo only if required (up to 3 atempo and supports lower speeds) - DecoderContext: Fixes a race condition between Open/Dispose which could cause memory leaks - Player: Brings back support for lower speeds (down limit to 0.125) - Player: Adds Config.Player.SpeedOffset (1-2), Commands and extra Keybindings (shift +-) - Player: Adds an extra SeekOffset3 and Commands - Player: Fixes a race condition during OpenAsync/Stop/OpenAsync - FlyleafHost(All): Fixes a critical issue with resize and rendering after Player.Stop/Renderer.Flush from a non-UI thread (SetWindowSubclass requires UI thread) - FlyleafMe: Adds Use Filters in Audio Settings
1 parent d7257c0 commit 0cdd912

9 files changed

Lines changed: 72 additions & 29 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
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.19</Version>
7+
<Version>1.2.20</Version>
88
<Authors>SuRGeoNix</Authors>
99
<Copyright>SuRGeoNix © 2023</Copyright>
1010
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
@@ -14,6 +14,7 @@
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
1718
Updates FlyleafLib
1819
</PackageReleaseNotes>
1920
</PropertyGroup>

FlyleafLib.Controls.WPF/Settings.xaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,15 @@
271271

272272
<TextBlock Text="Enabled" VerticalAlignment="Center"/>
273273
<ToggleButton Grid.Column="1" Tag="_save" IsChecked="{Binding Config.Audio.Enabled, UpdateSourceTrigger=Explicit}" HorizontalAlignment="Left" Style="{StaticResource MaterialDesignSwitchDarkToggleButton}"/>
274+
275+
<TextBlock Grid.Row="1" Text="Use Filters" VerticalAlignment="Center"/>
276+
<ToggleButton Grid.Row="1" Grid.Column="1" Tag="_save" IsChecked="{Binding Config.Audio.FiltersEnabled, UpdateSourceTrigger=Explicit}" HorizontalAlignment="Left" Style="{StaticResource MaterialDesignSwitchDarkToggleButton}"/>
274277

275-
<TextBlock Grid.Row="1" Text="Delay (ms)" VerticalAlignment="Center"/>
276-
<TextBox Grid.Row="1" Grid.Column="1" Style="{StaticResource FLTextboxN}" Text="{Binding Config.Audio.Delay, UpdateSourceTrigger=Explicit, Converter={StaticResource TicksToMilliSeconds}}"/>
278+
<TextBlock Grid.Row="2" Text="Delay (ms)" VerticalAlignment="Center"/>
279+
<TextBox Grid.Row="2" Grid.Column="1" Style="{StaticResource FLTextboxN}" Text="{Binding Config.Audio.Delay, UpdateSourceTrigger=Explicit, Converter={StaticResource TicksToMilliSeconds}}"/>
277280

278-
<TextBlock Grid.Row="2" Text="Device" VerticalAlignment="Center"/>
279-
<ComboBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" x:Name="cmbAudioDevice" Tag="_save" ItemsSource="{Binding AudioEngine.Devices}" SelectedItem="{Binding Player.Audio.Device, UpdateSourceTrigger=Explicit}" />
281+
<TextBlock Grid.Row="3" Text="Device" VerticalAlignment="Center"/>
282+
<ComboBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" x:Name="cmbAudioDevice" Tag="_save" ItemsSource="{Binding AudioEngine.Devices}" SelectedItem="{Binding Player.Audio.Device, UpdateSourceTrigger=Explicit}" />
280283
</Grid>
281284
<StackPanel Margin="0, 0, 0, 10" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Bottom">
282285
<Button Style="{StaticResource SaveButton}"/>

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.5</Version>
10+
<Version>1.0.6</Version>
1111
<Copyright>SuRGeoNix © 2023</Copyright>
1212
<PackageProjectUrl>https://github.com/SuRGeoNix/Flyleaf</PackageProjectUrl>
1313
<PackageIcon>Flyleaf.png</PackageIcon>

FlyleafLib/Engine/Config.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ public AudioConfig Clone()
647647
/// 2. Currently SWR performs better if you dont need filters
648648
/// </para>
649649
/// </summary>
650-
public bool FiltersEnabled { get => _FiltersEnabled; set => _FiltersEnabled = value && Engine.FFmpeg.FiltersLoaded; }
650+
public bool FiltersEnabled { get => _FiltersEnabled; set { if (Set(ref _FiltersEnabled, value && Engine.FFmpeg.FiltersLoaded)) player?.AudioDecoder.SetupFiltersOrSwr(); } }
651651
bool _FiltersEnabled = false;
652652

653653
/// <summary>

FlyleafLib/FlyleafLib.csproj

Lines changed: 9 additions & 6 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.9</Version>
11+
<Version>3.7.10</Version>
1212
<Authors>SuRGeoNix</Authors>
1313
<Copyright>SuRGeoNix © 2023</Copyright>
1414
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
@@ -17,11 +17,14 @@
1717
<IncludeSymbols>true</IncludeSymbols>
1818
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1919
<PackageReleaseNotes>
20-
- AudioDecoder: Fixes audio filters desync issues and improves quality on speed change
21-
- Player: Introduces Config.Player.LatencySpeedChangeInterval to prevent frequent speed changes on MaxLatency (adds speed support with audio filters)
22-
- FlyleafHost.Wpf: Fixes issues with resize and DPI
23-
- FlyleafHost.Wpf: Fixes an issue with multiple screens and fullscreen
24-
- FlyleafHost.Wpf: Fixes an issue with standalone and show in taskbar when initialized
20+
- AudioDecoder: Fixes an issue with audio filters when the input channel layout is unspecified (mainly noticed with ffmpeg devices and microphones)
21+
- AudioDecoder: Improves speed quality and adds atempo only if required (up to 3 atempo and supports lower speeds)
22+
- DecoderContext: Fixes a race condition between Open/Dispose which could cause memory leaks
23+
- Player: Brings back support for lower speeds (down limit to 0.125)
24+
- Player: Adds Config.Player.SpeedOffset (1-2), Commands and extra Keybindings (shift +-)
25+
- Player: Adds an extra SeekOffset3 and Commands
26+
- Player: Fixes a race condition during OpenAsync/Stop/OpenAsync
27+
- FlyleafHost(All): Fixes a critical issue with resize and rendering after Player.Stop/Renderer.Flush from a non-UI thread (SetWindowSubclass requires UI thread)
2528
</PackageReleaseNotes>
2629
</PropertyGroup>
2730

FlyleafLib/MediaFramework/MediaDecoder/AudioDecoder.Filters.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,36 @@ private int UpdateFilterInternal(string filterId, string key, string value)
189189

190190
return ret;
191191
}
192+
internal int SetupFiltersOrSwr()
193+
{
194+
lock (lockSpeed)
195+
{
196+
int ret = -1;
197+
198+
if (Disposed)
199+
return ret;
200+
201+
if (Config.Audio.FiltersEnabled && Engine.FFmpeg.FiltersLoaded)
202+
{
203+
ret = SetupFilters();
204+
205+
if (ret != 0)
206+
{
207+
Log.Error($"Setup filters failed. Fallback to Swr.");
208+
ret = SetupSwr();
209+
}
210+
else
211+
DisposeSwr();
212+
}
213+
else
214+
{
215+
DisposeFilters();
216+
ret = SetupSwr();
217+
}
218+
219+
return ret;
220+
}
221+
}
192222

193223
public int UpdateFilter(string filterId, string key, string value)
194224
{

FlyleafLib/MediaFramework/MediaDecoder/AudioDecoder.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ private int SetupSwr()
6161
{
6262
int ret;
6363

64-
if (swrCtx == null)
65-
swrCtx = swr_alloc();
64+
DisposeSwr();
65+
swrCtx = swr_alloc();
6666

6767
av_opt_set_chlayout(swrCtx, "in_chlayout", &codecCtx->ch_layout, 0);
6868
av_opt_set_int(swrCtx, "in_sample_rate", codecCtx->sample_rate, 0);
@@ -301,18 +301,7 @@ protected override void RunInternal()
301301
AudioStream.Refresh();
302302
resyncWithVideoRequired = !VideoDecoder.Disposed;
303303

304-
if (Config.Audio.FiltersEnabled)
305-
{
306-
ret = SetupFilters();
307-
308-
if (ret != 0)
309-
{
310-
Log.Error($"Setup filters failed. Fallback to Swr.");
311-
ret = SetupSwr();
312-
}
313-
}
314-
else
315-
ret = SetupSwr();
304+
ret = SetupFiltersOrSwr();
316305

317306
CodecChanged?.Invoke(this);
318307

Samples/FlyleafPlayer (WPF Control) (WPF)/MainWindow.xaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
xmlns:flwpf="clr-namespace:FlyleafLib.Controls.WPF;assembly=FlyleafLib.Controls.WPF"
1010
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
1111
mc:Ignorable="d"
12+
FontFamily="{materialDesign:MaterialDesignFont}"
1213
TextElement.FontWeight="Regular"
1314
TextElement.FontSize="13"
1415
TextOptions.TextFormattingMode="Ideal"
@@ -130,7 +131,7 @@
130131

131132
<Grid Grid.Row="1" x:Name="PART_ContextMenuOwner" ContextMenu="{StaticResource PopUpMenu}">
132133

133-
<TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Padding="4" Margin="10 -40 0 0" d:Text="00:00:00.000 / 01:42:23.913" FontWeight="Bold" FontSize="18" Foreground="{DynamicResource SecondaryHueMidBrush}">
134+
<TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Padding="4" Margin="10 -40 0 0" d:Text="00:00:00.000 / 01:42:23.913" FontWeight="Bold" FontSize="14" Foreground="{DynamicResource SecondaryHueMidBrush}">
134135
<TextBlock.Background>
135136
<SolidColorBrush Color="{Binding Player.Config.Video.BackgroundColor}" Opacity="0.15"/>
136137
</TextBlock.Background>
@@ -149,14 +150,17 @@
149150
<Run Text="{Binding Player.Duration, Mode=OneWay, Converter={StaticResource TicksToTimeSpan}, StringFormat={}{0:hh\\:mm\\:ss\\.fff}}"/>
150151
</TextBlock>
151152

152-
<TextBlock VerticalAlignment="Top" HorizontalAlignment="Right" Padding="4" Margin="0 10 10 0" FontWeight="Bold" d:Text="Volume 50%" FontSize="16" Text="{Binding Tag.Msg}" Foreground="{DynamicResource SecondaryHueMidBrush}">
153+
<TextBlock VerticalAlignment="Top" HorizontalAlignment="Right" Padding="4" Margin="0 10 10 0" FontWeight="Bold" d:Text="Volume 50%" FontSize="14" Text="{Binding Tag.Msg}" Foreground="{DynamicResource SecondaryHueMidBrush}">
153154
<TextBlock.Background>
154155
<SolidColorBrush Color="{Binding Player.Config.Video.BackgroundColor}" Opacity="0.15"/>
155156
</TextBlock.Background>
156157
<TextBlock.Style>
157158
<Style TargetType="{x:Type TextBlock}">
158159
<Setter Property="Visibility" Value="Visible"/>
159160
<Style.Triggers>
161+
<DataTrigger Binding="{Binding Player.Activity.Mode}" Value="Idle" d:Value="{x:Null}">
162+
<Setter Property="Visibility" Value="Collapsed"/>
163+
</DataTrigger>
160164
<Trigger Property="Text" Value="">
161165
<Setter Property="Visibility" Value="Collapsed"/>
162166
</Trigger>

Samples/FlyleafPlayer (WPF Control) (WPF)/MainWindow.xaml.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ private void LoadPlayer()
9090
playerConfig = DefaultConfig();
9191
#endif
9292

93+
#if DEBUG
94+
// Testing audio filters
95+
//playerConfig.Audio.Filters = new()
96+
//{
97+
////new() { Name = "loudnorm", Args = "I=-24:LRA=7:TP=-2", Id = "loudnorm1" },
98+
////new() { Name = "dynaudnorm", Args = "f=4150", Id = "dynaudnorm1" },
99+
////new() { Name ="afftfilt", Args = "real='hypot(re,im)*sin(0)':imag='hypot(re,im)*cos(0)':win_size=512:overlap=0.75" }, // robot
100+
////new() { Name ="tremolo", Args="f=5:d=0.5" },
101+
////new() { Name ="vibrato", Args="f=10:d=0.5" },
102+
////new() { Name ="rubberband", Args="pitch=1.5" }
103+
//};
104+
#endif
105+
93106
// Initializes the Player
94107
Player = new Player(playerConfig);
95108

0 commit comments

Comments
 (0)