mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-12-15 02:25:44 +00:00
Merge 85e7170fd9 into 70668ce623
This commit is contained in:
commit
7f85dcf593
2 changed files with 27 additions and 17 deletions
|
|
@ -15,7 +15,7 @@ public class FFMpegArgumentProcessorTest
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Processor_GlobalOptions_GetUsed()
|
public void Processor_GlobalOptions_GetUsed()
|
||||||
{
|
{
|
||||||
var globalWorkingDir = "Whatever";
|
var globalWorkingDir = "Whatever1";
|
||||||
var processor = CreateArgumentProcessor();
|
var processor = CreateArgumentProcessor();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -47,7 +47,7 @@ public class FFMpegArgumentProcessorTest
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Processor_Options_CanBeOverridden_And_Configured()
|
public void Processor_Options_CanBeOverridden_And_Configured()
|
||||||
{
|
{
|
||||||
var globalConfig = "Whatever";
|
var globalConfig = "Whatever2";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -59,14 +59,14 @@ public class FFMpegArgumentProcessorTest
|
||||||
var overrideOptions = new FFOptions { WorkingDirectory = "override" };
|
var overrideOptions = new FFOptions { WorkingDirectory = "override" };
|
||||||
|
|
||||||
GlobalFFOptions.Configure(new FFOptions { WorkingDirectory = globalConfig, TemporaryFilesFolder = globalConfig, BinaryFolder = globalConfig });
|
GlobalFFOptions.Configure(new FFOptions { WorkingDirectory = globalConfig, TemporaryFilesFolder = globalConfig, BinaryFolder = globalConfig });
|
||||||
var options = processor.GetConfiguredOptions(overrideOptions);
|
var configuredOptions = processor.GetConfiguredOptions(overrideOptions);
|
||||||
|
|
||||||
Assert.AreEqual(options.WorkingDirectory, overrideOptions.WorkingDirectory);
|
Assert.AreEqual(configuredOptions.WorkingDirectory, overrideOptions.WorkingDirectory);
|
||||||
Assert.AreEqual(options.TemporaryFilesFolder, overrideOptions.TemporaryFilesFolder);
|
Assert.AreEqual(configuredOptions.TemporaryFilesFolder, overrideOptions.TemporaryFilesFolder);
|
||||||
Assert.AreEqual(options.BinaryFolder, overrideOptions.BinaryFolder);
|
Assert.AreEqual(configuredOptions.BinaryFolder, overrideOptions.BinaryFolder);
|
||||||
|
|
||||||
Assert.AreEqual(sessionTempDir, options.TemporaryFilesFolder);
|
Assert.AreEqual(sessionTempDir, configuredOptions.TemporaryFilesFolder);
|
||||||
Assert.AreNotEqual(globalConfig, options.BinaryFolder);
|
Assert.AreNotEqual(globalConfig, configuredOptions.BinaryFolder);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
@ -77,7 +77,7 @@ public class FFMpegArgumentProcessorTest
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Options_Global_And_Session_Options_Can_Differ()
|
public void Options_Global_And_Session_Options_Can_Differ()
|
||||||
{
|
{
|
||||||
var globalWorkingDir = "Whatever";
|
var globalWorkingDir = "Whatever3";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ namespace FFMpegCore.Arguments;
|
||||||
public abstract class PipeArgument
|
public abstract class PipeArgument
|
||||||
{
|
{
|
||||||
private readonly PipeDirection _direction;
|
private readonly PipeDirection _direction;
|
||||||
|
private readonly object _pipeLock = new();
|
||||||
|
|
||||||
protected PipeArgument(PipeDirection direction)
|
protected PipeArgument(PipeDirection direction)
|
||||||
{
|
{
|
||||||
|
|
@ -22,19 +23,25 @@ public abstract class PipeArgument
|
||||||
|
|
||||||
public void Pre()
|
public void Pre()
|
||||||
{
|
{
|
||||||
if (Pipe != null)
|
lock (_pipeLock)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Pipe already has been opened");
|
if (Pipe != null)
|
||||||
}
|
{
|
||||||
|
throw new InvalidOperationException("Pipe already has been opened");
|
||||||
|
}
|
||||||
|
|
||||||
Pipe = new NamedPipeServerStream(PipeName, _direction, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
|
Pipe = new NamedPipeServerStream(PipeName, _direction, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Post()
|
public void Post()
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"Disposing NamedPipeServerStream on {GetType().Name}");
|
Debug.WriteLine($"Disposing NamedPipeServerStream on {GetType().Name}");
|
||||||
Pipe?.Dispose();
|
lock (_pipeLock)
|
||||||
Pipe = null!;
|
{
|
||||||
|
Pipe?.Dispose();
|
||||||
|
Pipe = null!;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task During(CancellationToken cancellationToken = default)
|
public async Task During(CancellationToken cancellationToken = default)
|
||||||
|
|
@ -50,9 +57,12 @@ public abstract class PipeArgument
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"Disconnecting NamedPipeServerStream on {GetType().Name}");
|
Debug.WriteLine($"Disconnecting NamedPipeServerStream on {GetType().Name}");
|
||||||
if (Pipe is { IsConnected: true })
|
lock (_pipeLock)
|
||||||
{
|
{
|
||||||
Pipe.Disconnect();
|
if (Pipe is { IsConnected: true })
|
||||||
|
{
|
||||||
|
Pipe.Disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue