Skip to content

Commit

Permalink
Fixes #178
Browse files Browse the repository at this point in the history
  • Loading branch information
SuRGeoNix committed Aug 30, 2022
1 parent 830e82e commit e2ea643
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
3 changes: 3 additions & 0 deletions FlyleafLib/Engine/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ internal static void MasterThread()
if (player.IsPlaying)
{
player.Audio.FramesDisplayed= player.Audio.FramesDisplayed;
player.Audio.FramesDropped = player.Audio.FramesDropped;
player.Video.FramesDisplayed= player.Video.FramesDisplayed;
player.Video.FramesDropped = player.Video.FramesDropped;
player.Video.FPSCurrent = player.Video.FPSCurrent;
Expand Down
27 changes: 21 additions & 6 deletions FlyleafLib/MediaPlayer/Audio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ public ObservableCollection<AudioStream>
public string ChannelLayout { get => channelLayout; internal set => Set(ref _ChannelLayout, value); }
internal string _ChannelLayout, channelLayout;

///// <summary>
///// Total Dropped Frames
///// </summary>
public int FramesDropped { get => framesDropped; internal set => Set(ref _FramesDropped, value); }
internal int _FramesDropped, framesDropped;

public int FramesDisplayed { get => framesDisplayed; internal set => Set(ref _FramesDisplayed, value); }
internal int _FramesDisplayed, framesDisplayed;

public string SampleFormat { get => sampleFormat; internal set => Set(ref _SampleFormat, value); }
internal string _SampleFormat, sampleFormat;

Expand Down Expand Up @@ -200,6 +209,9 @@ public Audio(Player player)
ChannelLayout = ChannelLayout;
SampleFormat = SampleFormat;
SampleRate = SampleRate;
FramesDisplayed = FramesDisplayed;
FramesDropped = FramesDropped;
};

Volume = Config.Player.VolumeMax / 2;
Expand Down Expand Up @@ -299,12 +311,15 @@ internal void Refresh()
{
if (decoder.AudioStream == null) { Reset(); return; }

codec = decoder.AudioStream.Codec;
bits = decoder.AudioStream.Bits;
channels = decoder.AudioStream.Channels;
channelLayout = decoder.AudioStream.ChannelLayoutStr;
sampleFormat = decoder.AudioStream.SampleFormatStr;
isOpened =!decoder.AudioDecoder.Disposed;
codec = decoder.AudioStream.Codec;
bits = decoder.AudioStream.Bits;
channels = decoder.AudioStream.Channels;
channelLayout = decoder.AudioStream.ChannelLayoutStr;
sampleFormat = decoder.AudioStream.SampleFormatStr;
isOpened =!decoder.AudioDecoder.Disposed;

framesDisplayed = 0;
framesDropped = 0;

if (SampleRate!= decoder.AudioStream.SampleRate)
Initialize();
Expand Down
4 changes: 4 additions & 0 deletions FlyleafLib/MediaPlayer/Player.Screamers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ private void Screamer()
{
if (CanTrace) Log.Trace($"[A] Presenting {TicksToTime(aFrame.timestamp)}");
Audio.AddSamples(aFrame);
Audio.framesDisplayed++;
AudioDecoder.Frames.TryDequeue(out aFrame);
if (aFrame != null)
aFrame.timestamp = (long)(aFrame.timestamp / Speed);
Expand All @@ -403,6 +404,7 @@ private void Screamer()
{
if (allowedLateAudioDrops > 0)
{
Audio.framesDropped++;
allowedLateAudioDrops--;
if (CanDebug) Log.Debug($"aDistanceMs 3 = {aDistanceMs}");
AudioDecoder.Frames.TryDequeue(out aFrame);
Expand All @@ -425,6 +427,7 @@ private void Screamer()
if (aDistanceMs < -600)
{
if (CanTrace) Log.Trace($"All audio frames disposed");
Audio.framesDropped += AudioDecoder.Frames.Count;
AudioDecoder.DisposeFrames();
aFrame = null;
}
Expand All @@ -434,6 +437,7 @@ private void Screamer()
for (int i=0; i<maxdrop; i++)
{
if (CanTrace) Log.Trace($"aDistanceMs 2 = {aDistanceMs}");
Audio.framesDropped++;
AudioDecoder.Frames.TryDequeue(out aFrame);
if (aFrame != null)
aFrame.timestamp = (long)(aFrame.timestamp / Speed);
Expand Down

0 comments on commit e2ea643

Please sign in to comment.