Skip to content

Commit

Permalink
Updates to v3.7.10 (FlyleafLib) / v1.2.20 (FlyleafME) / v1.0.6 (Flyle…
Browse files Browse the repository at this point in the history
…afHost.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
  • Loading branch information
SuRGeoNix committed Apr 29, 2023
1 parent d7257c0 commit 0cdd912
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 29 deletions.
3 changes: 2 additions & 1 deletion FlyleafLib.Controls.WPF/FlyleafLib.Controls.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net7.0-windows;net6.0-windows;net472</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>
<Version>1.2.19</Version>
<Version>1.2.20</Version>
<Authors>SuRGeoNix</Authors>
<Copyright>SuRGeoNix © 2023</Copyright>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
Expand All @@ -14,6 +14,7 @@
<PackageTags>flyleaf flyleaflib flyleafme video audio wpf media player element control</PackageTags>
<Description>FlyleafME: A WPF Media Element Control (based on FlyleafLib)</Description>
<PackageReleaseNotes>
Adds Use Filters in Audio Settings
Updates FlyleafLib
</PackageReleaseNotes>
</PropertyGroup>
Expand Down
11 changes: 7 additions & 4 deletions FlyleafLib.Controls.WPF/Settings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,15 @@

<TextBlock Text="Enabled" VerticalAlignment="Center"/>
<ToggleButton Grid.Column="1" Tag="_save" IsChecked="{Binding Config.Audio.Enabled, UpdateSourceTrigger=Explicit}" HorizontalAlignment="Left" Style="{StaticResource MaterialDesignSwitchDarkToggleButton}"/>

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

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

<TextBlock Grid.Row="2" Text="Device" VerticalAlignment="Center"/>
<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}" />
<TextBlock Grid.Row="3" Text="Device" VerticalAlignment="Center"/>
<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}" />
</Grid>
<StackPanel Margin="0, 0, 0, 10" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Bottom">
<Button Style="{StaticResource SaveButton}"/>
Expand Down
2 changes: 1 addition & 1 deletion FlyleafLib.Controls.WinUI/FlyleafLib.Controls.WinUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<UseWinUI>true</UseWinUI>
<Nullable>enable</Nullable>
<Authors>SuRGeoNix</Authors>
<Version>1.0.5</Version>
<Version>1.0.6</Version>
<Copyright>SuRGeoNix © 2023</Copyright>
<PackageProjectUrl>https://github.com/SuRGeoNix/Flyleaf</PackageProjectUrl>
<PackageIcon>Flyleaf.png</PackageIcon>
Expand Down
2 changes: 1 addition & 1 deletion FlyleafLib/Engine/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ public AudioConfig Clone()
/// 2. Currently SWR performs better if you dont need filters
/// </para>
/// </summary>
public bool FiltersEnabled { get => _FiltersEnabled; set => _FiltersEnabled = value && Engine.FFmpeg.FiltersLoaded; }
public bool FiltersEnabled { get => _FiltersEnabled; set { if (Set(ref _FiltersEnabled, value && Engine.FFmpeg.FiltersLoaded)) player?.AudioDecoder.SetupFiltersOrSwr(); } }
bool _FiltersEnabled = false;

/// <summary>
Expand Down
15 changes: 9 additions & 6 deletions FlyleafLib/FlyleafLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageIconUrl />
<RepositoryUrl></RepositoryUrl>
<Description>Media Player .NET Library for WinUI 3/WPF/WinForms (based on FFmpeg/DirectX)</Description>
<Version>3.7.9</Version>
<Version>3.7.10</Version>
<Authors>SuRGeoNix</Authors>
<Copyright>SuRGeoNix © 2023</Copyright>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
Expand All @@ -17,11 +17,14 @@
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageReleaseNotes>
- AudioDecoder: Fixes audio filters desync issues and improves quality on speed change
- Player: Introduces Config.Player.LatencySpeedChangeInterval to prevent frequent speed changes on MaxLatency (adds speed support with audio filters)
- FlyleafHost.Wpf: Fixes issues with resize and DPI
- FlyleafHost.Wpf: Fixes an issue with multiple screens and fullscreen
- FlyleafHost.Wpf: Fixes an issue with standalone and show in taskbar when initialized
- AudioDecoder: Fixes an issue with audio filters when the 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)
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
30 changes: 30 additions & 0 deletions FlyleafLib/MediaFramework/MediaDecoder/AudioDecoder.Filters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,36 @@ private int UpdateFilterInternal(string filterId, string key, string value)

return ret;
}
internal int SetupFiltersOrSwr()
{
lock (lockSpeed)
{
int ret = -1;

if (Disposed)
return ret;

if (Config.Audio.FiltersEnabled && Engine.FFmpeg.FiltersLoaded)
{
ret = SetupFilters();

if (ret != 0)
{
Log.Error($"Setup filters failed. Fallback to Swr.");
ret = SetupSwr();
}
else
DisposeSwr();
}
else
{
DisposeFilters();
ret = SetupSwr();
}

return ret;
}
}

public int UpdateFilter(string filterId, string key, string value)
{
Expand Down
17 changes: 3 additions & 14 deletions FlyleafLib/MediaFramework/MediaDecoder/AudioDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ private int SetupSwr()
{
int ret;

if (swrCtx == null)
swrCtx = swr_alloc();
DisposeSwr();
swrCtx = swr_alloc();

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

if (Config.Audio.FiltersEnabled)
{
ret = SetupFilters();

if (ret != 0)
{
Log.Error($"Setup filters failed. Fallback to Swr.");
ret = SetupSwr();
}
}
else
ret = SetupSwr();
ret = SetupFiltersOrSwr();

CodecChanged?.Invoke(this);

Expand Down
8 changes: 6 additions & 2 deletions Samples/FlyleafPlayer (WPF Control) (WPF)/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
xmlns:flwpf="clr-namespace:FlyleafLib.Controls.WPF;assembly=FlyleafLib.Controls.WPF"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
FontFamily="{materialDesign:MaterialDesignFont}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
Expand Down Expand Up @@ -130,7 +131,7 @@

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

<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}">
<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}">
<TextBlock.Background>
<SolidColorBrush Color="{Binding Player.Config.Video.BackgroundColor}" Opacity="0.15"/>
</TextBlock.Background>
Expand All @@ -149,14 +150,17 @@
<Run Text="{Binding Player.Duration, Mode=OneWay, Converter={StaticResource TicksToTimeSpan}, StringFormat={}{0:hh\\:mm\\:ss\\.fff}}"/>
</TextBlock>

<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}">
<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}">
<TextBlock.Background>
<SolidColorBrush Color="{Binding Player.Config.Video.BackgroundColor}" Opacity="0.15"/>
</TextBlock.Background>
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Visibility" Value="Visible"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Player.Activity.Mode}" Value="Idle" d:Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
<Trigger Property="Text" Value="">
<Setter Property="Visibility" Value="Collapsed"/>
</Trigger>
Expand Down
13 changes: 13 additions & 0 deletions Samples/FlyleafPlayer (WPF Control) (WPF)/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ private void LoadPlayer()
playerConfig = DefaultConfig();
#endif

#if DEBUG
// Testing audio filters
//playerConfig.Audio.Filters = new()
//{
////new() { Name = "loudnorm", Args = "I=-24:LRA=7:TP=-2", Id = "loudnorm1" },
////new() { Name = "dynaudnorm", Args = "f=4150", Id = "dynaudnorm1" },
////new() { Name ="afftfilt", Args = "real='hypot(re,im)*sin(0)':imag='hypot(re,im)*cos(0)':win_size=512:overlap=0.75" }, // robot
////new() { Name ="tremolo", Args="f=5:d=0.5" },
////new() { Name ="vibrato", Args="f=10:d=0.5" },
////new() { Name ="rubberband", Args="pitch=1.5" }
//};
#endif

// Initializes the Player
Player = new Player(playerConfig);

Expand Down

0 comments on commit 0cdd912

Please sign in to comment.