Skip to content

Commit 9bdaf75

Browse files
committed
v1.14: Added a new CPU Threads option.
1 parent c0674df commit 9bdaf75

8 files changed

Lines changed: 116 additions & 63 deletions

File tree

opus_gui/App.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
<setting name="EncFfmpeg2" serializeAs="String">
2929
<value>False</value>
3030
</setting>
31+
<setting name="CPUThreads" serializeAs="String">
32+
<value>0</value>
33+
</setting>
3134
</opus_gui.My.MySettings>
3235
</userSettings>
3336
<runtime>

opus_gui/Form1.Designer.vb

Lines changed: 76 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

opus_gui/Form1.vb

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Public Class Form1
3333
OutputBrowseBtn.Enabled = False
3434
BitrateNumberBox.Enabled = False
3535
enableMultithreading.Enabled = False
36+
CPUThreads.Enabled = False
3637
Running = True
3738
End Sub
3839
Private Sub StartBtn_Click(sender As Object, e As EventArgs) Handles StartBtn.Click
@@ -120,7 +121,7 @@ Public Class Form1
120121
FileAlreadyExist.Add(args(1))
121122
End If
122123
Next
123-
Parallel.Invoke(New ParallelOptions With {.MaxDegreeOfParallelism = Environment.ProcessorCount}, tasks.ToArray())
124+
Parallel.Invoke(New ParallelOptions With {.MaxDegreeOfParallelism = CPUThreads.Value}, tasks.ToArray())
124125
Else
125126
For Counter As Integer = 0 To ItemsToProcess.Count - 1
126127
Dim args As Array = {ItemsToProcess(Counter), GetOutputPath(OutputTxt.Text, ItemsToProcess(Counter)), My.Settings.Bitrate}
@@ -147,6 +148,7 @@ Public Class Form1
147148
StartBtn.Enabled = True
148149
BitrateNumberBox.Enabled = True
149150
enableMultithreading.Enabled = True
151+
CPUThreads.Enabled = True
150152
InputTxt.Enabled = True
151153
OutputTxt.Enabled = True
152154
InputBrowseBtn.Enabled = True
@@ -252,16 +254,21 @@ Public Class Form1
252254
InputPipe.WaitForConnection()
253255
Dim ChunkSize As Integer = 16384
254256
For Bytes As Long = 0 To Input.Length Step 16384
255-
If Input.Length - Bytes < ChunkSize Then
256-
ChunkSize = Input.Length - Bytes
257-
End If
258-
Await InputPipe.WriteAsync(Input, Bytes, ChunkSize)
257+
Try
258+
If Input.Length - Bytes < ChunkSize Then
259+
ChunkSize = Input.Length - Bytes
260+
End If
261+
Await InputPipe.WriteAsync(Input, Bytes, ChunkSize)
262+
Catch
263+
End Try
259264
Next
260265

261266
InputPipe.Flush()
262267
InputPipe.Dispose()
263268
End Sub
264269
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
270+
CPUThreads.Maximum = Environment.ProcessorCount
271+
If My.Settings.CPUThreads = 0 Then CPUThreads.Value = CPUThreads.Maximum Else CPUThreads.Value = My.Settings.CPUThreads
265272
BitrateNumberBox.Value = My.Settings.Bitrate
266273
enableMultithreading.Checked = My.Settings.Multithreading
267274
EncFfmpeg1.Checked = My.Settings.EncFfmpeg
@@ -394,4 +401,8 @@ Public Class Form1
394401
End If
395402
End Sub
396403

404+
Private Sub CPUThreads_ValueChanged(sender As Object, e As EventArgs) Handles CPUThreads.ValueChanged
405+
My.Settings.CPUThreads = CPUThreads.Value
406+
My.Settings.Save()
407+
End Sub
397408
End Class

opus_gui/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("1.13.3.0")>
35-
<Assembly: AssemblyFileVersion("1.13.3.0")>
34+
<Assembly: AssemblyVersion("1.14.0.0")>
35+
<Assembly: AssemblyFileVersion("1.14.0.0")>

0 commit comments

Comments
 (0)