Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Captura.Loc/LanguageFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ void Set(string Value, [CallerMemberName] string PropertyName = null)
RaisePropertyChanged(PropertyName);
}

/// <summary>
/// Fired when the language changes. This event is invoked by derived classes (e.g., LanguageManager).
/// </summary>
#pragma warning disable CS0067 // The event is never used - invoked by derived classes
public virtual event Action<CultureInfo> LanguageChanged;
#pragma warning restore CS0067

public string About
{
Expand Down
51 changes: 40 additions & 11 deletions src/Captura.MouseKeyHook/Steps/StepsRecorder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Reactive;
using System.Reactive.Linq;
using System.Reactive.Subjects;
Expand Down Expand Up @@ -167,23 +167,52 @@ public StepsRecorder(IMouseKeyHook Hook,

void DoRecord(IObservable<IRecordStep> StepsObservable, IObservable<Unit> ShotObservable)
{
var frames = ShotObservable.Select(M => _imageProvider.Capture())
.Zip(StepsObservable, (Frame, Step) =>
{
Step.Draw(Frame, _imageProvider.PointTransform);
try
{
var frames = ShotObservable.Select(M => _imageProvider.Capture())
.Zip(StepsObservable, (Frame, Step) =>
{
Step.Draw(Frame, _imageProvider.PointTransform);

return Frame.GenerateFrame(TimeSpan.Zero);
});
return Frame.GenerateFrame(TimeSpan.Zero);
});

foreach (var frame in frames.ToEnumerable())
foreach (var frame in frames.ToEnumerable())
{
_videoWriter.WriteFrame(frame);
}
}
catch (Exception e)
{
_videoWriter.WriteFrame(frame);
ErrorOccurred?.Invoke(e);
}
}

public void Start() => _recording = true;
public void Start()
{
try
{
_recording = true;
}
catch (Exception e)
{
ErrorOccurred?.Invoke(e);
throw;
}
}

public void Stop() => _recording = false;
public void Stop()
{
try
{
_recording = false;
}
catch (Exception e)
{
ErrorOccurred?.Invoke(e);
throw;
}
}

public event Action<Exception> ErrorOccurred;

Expand Down
41 changes: 32 additions & 9 deletions src/Screna/AudioRecorder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading;
using System.Threading.Tasks;

Expand Down Expand Up @@ -54,16 +54,32 @@ public void Dispose()

public void Start()
{
_audioProvider.Start();
try
{
_audioProvider.Start();

_continueEvent.Set();
_continueEvent.Set();
}
catch (Exception e)
{
ErrorOccurred?.Invoke(e);
throw;
}
}

public void Stop()
{
_continueEvent.Reset();
try
{
_continueEvent.Reset();

_audioProvider.Stop();
_audioProvider.Stop();
}
catch (Exception e)
{
ErrorOccurred?.Invoke(e);
throw;
}
}

void Loop()
Expand All @@ -80,13 +96,20 @@ bool CanContinue()
}
}

while (CanContinue())
try
{
var read = _audioProvider.Read(_buffer, 0, _buffer.Length);
while (CanContinue())
{
var read = _audioProvider.Read(_buffer, 0, _buffer.Length);

_audioWriter.Write(_buffer, 0, read);
_audioWriter.Write(_buffer, 0, read);

Thread.Sleep(ReadInterval);
Thread.Sleep(ReadInterval);
}
}
catch (Exception e)
{
ErrorOccurred?.Invoke(e);
}
}

Expand Down