Skip to content

Commit 8cd596a

Browse files
Merge pull request #5 from SineVector241/dev
Sync Dev to Master.
2 parents bd87600 + 2097c3d commit 8cd596a

File tree

11 files changed

+93
-12
lines changed

11 files changed

+93
-12
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: BuildTest
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- name: Setup Dotnet
9+
uses: actions/setup-dotnet@v3
10+
with:
11+
dotnet-version: '8.x'
12+
13+
- name: Install Dependencies
14+
run: dotnet workload restore ./OpusSharp.Core/OpusSharp.Core.csproj
15+
16+
- name: Build
17+
run: dotnet build ./OpusSharp.Core/OpusSharp.Core.csproj -f netstandard2.0 -p:TargetFrameworks=netstandard2.0

OpusSharp.Core/Disposable.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,24 @@ public abstract class Disposable : IDisposable
1717
{
1818
private int isDisposed; // 0 for false, 1 for true
1919

20+
/// <summary>
21+
/// Returns wether the object is disposed or not.
22+
/// </summary>
2023
public bool IsDisposed
2124
{
2225
get => Volatile.Read(ref this.isDisposed) != 0;
2326
}
2427

28+
/// <summary>
29+
/// Makes an object disposable.
30+
/// </summary>
2531
protected Disposable()
2632
{
2733
}
2834

35+
/// <summary>
36+
/// When the object is destructed and not disposed, it does not dispose.
37+
/// </summary>
2938
~Disposable()
3039
{
3140
int oldIsDisposed = Interlocked.Exchange(ref this.isDisposed, 1);
@@ -35,6 +44,9 @@ protected Disposable()
3544
}
3645
}
3746

47+
/// <summary>
48+
/// Disposes the object.
49+
/// </summary>
3850
public void Dispose()
3951
{
4052
int oldIsDisposed = Interlocked.Exchange(ref this.isDisposed, 1);
@@ -51,6 +63,10 @@ public void Dispose()
5163
}
5264
}
5365

66+
/// <summary>
67+
/// Disposes the object.
68+
/// </summary>
69+
/// <param name="disposing"></param>
5470
protected virtual void Dispose(bool disposing)
5571
{
5672
throw new NotImplementedException();

OpusSharp.Core/OpusDecoder.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,10 @@ public unsafe int Decode(byte[] input, int inputLength, short[] output, int fram
145145
/// Decodes an Opus frame.
146146
/// </summary>
147147
/// <param name="input">Input in float format (interleaved if 2 channels), with a normal range of +/-1.0. Samples with a range beyond +/-1.0 are supported but will be clipped by decoders using the integer API and should only be used if it is known that the far end supports extended dynamic range. length is frame_size*channels*sizeof(float)</param>
148-
/// <param name="frame_size">Number of samples per channel in the input signal. This must be an Opus frame size for the encoder's sampling rate. For example, at 48 kHz the permitted values are 120, 240, 480, 960, 1920, and 2880. Passing in a duration of less than 10 ms (480 samples at 48 kHz) will prevent the encoder from using the LPC or hybrid modes.</param>
148+
/// <param name="inputLength">Number of samples per channel in the input signal. This must be an Opus frame size for the encoder's sampling rate. For example, at 48 kHz the permitted values are 120, 240, 480, 960, 1920, and 2880. Passing in a duration of less than 10 ms (480 samples at 48 kHz) will prevent the encoder from using the LPC or hybrid modes.</param>
149149
/// <param name="output">Output payload</param>
150+
/// <param name="frame_size">The number of samples per channel of available space in pcm. If this is less than the maximum packet duration (120 ms; 5760 for 48kHz), this function will not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), then frame_size needs to be exactly the duration of audio that is missing, otherwise the decoder will not be in the optimal state to decode the next incoming packet. For the PLC and FEC cases, frame_size must be a multiple of 2.5 ms.</param>
151+
/// <param name="decodeFEC">Flag (false or true) to request that any in-band forward error correction data be decoded. If no such data is available, the frame is decoded as if it were lost.</param>
150152
/// <param name="inputOffset">Offset to start reading in the input.</param>
151153
/// <param name="outputOffset">Offset to start writing in the output.</param>
152154
/// <returns>The length of the decoded packet on success or a negative error code (see <see cref="Enums.OpusError"/>) on failure. Note: OpusSharp throws an error if there is a negative error code.</returns>
@@ -210,7 +212,6 @@ public void DecoderCtl(Enums.GenericCtl ctl, int value)
210212
/// Requests a CTL on the decoder.
211213
/// </summary>
212214
/// <param name="ctl">The decoder CTL to request.</param>
213-
/// <param name="value">The value that is outputted from the CTL.</param>
214215
/// <exception cref="ObjectDisposedException"></exception>
215216
/// <exception cref="OpusException"></exception>
216217
public int DecoderCtl(Enums.GenericCtl ctl)
@@ -238,6 +239,10 @@ public int GetNumberOfSamples(byte[] data)
238239
return result;
239240
}
240241

242+
/// <summary>
243+
/// Disposes the object.
244+
/// </summary>
245+
/// <param name="disposing"></param>
241246
protected override void Dispose(bool disposing)
242247
{
243248
if (disposing)

OpusSharp.Core/OpusEncoder.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ public void EncoderCtl(Enums.EncoderCtl ctl, int value)
260260
/// Requests a CTL on the encoder.
261261
/// </summary>
262262
/// <param name="ctl">The encoder CTL to request.</param>
263-
/// <param name="value">The value that is outputted from the CTL.</param>
264263
/// <exception cref="ObjectDisposedException"></exception>
265264
/// <exception cref="OpusException"></exception>
266265
public int EncoderCtl(Enums.EncoderCtl ctl)
@@ -299,6 +298,10 @@ public int EncoderCtl(Enums.GenericCtl ctl)
299298
return val;
300299
}
301300

301+
/// <summary>
302+
/// Disposes the object.
303+
/// </summary>
304+
/// <param name="disposing"></param>
302305
protected override void Dispose(bool disposing)
303306
{
304307
if (disposing)

OpusSharp.Core/OpusException.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,27 @@
22

33
namespace OpusSharp.Core
44
{
5+
/// <summary>
6+
/// An opus exception.
7+
/// </summary>
58
public class OpusException : Exception
69
{
10+
/// <summary>
11+
/// Contructs an opus exception.
12+
/// </summary>
713
public OpusException() { }
814

15+
/// <summary>
16+
/// Contructs an opus exception.
17+
/// </summary>
18+
/// <param name="message">The message of the exception.</param>
919
public OpusException(string message) : base(message) { }
1020

21+
/// <summary>
22+
/// Contructs an opus exception.
23+
/// </summary>
24+
/// <param name="message">The message of the exception.</param>
25+
/// <param name="innerException">The root exception.</param>
1126
public OpusException(string message, Exception innerException) : base(message, innerException) { }
1227
}
1328
}

OpusSharp.Core/OpusMSDecoder.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public int Pitch
7676
/// </summary>
7777
/// <param name="SampleRate">Sample rate to decode at (Hz). This must be one of 8000, 12000, 16000, 24000, or 48000.</param>
7878
/// <param name="Channels">Number of channels to decode.</param>
79+
/// <param name="Streams">The total number of streams coded in the input. This must be no more than 255.</param>
80+
/// <param name="CoupledStreams">Number of streams to decode as coupled (2 channel) streams. This must be no larger than the total number of streams. Additionally, The total number of coded channels (streams + coupled_streams) must be no more than 255.</param>
81+
/// <param name="mapping">Mapping from coded channels to output channels, as described in Opus Multistream API.</param>
7982
/// <exception cref="OpusException"></exception>
8083
public unsafe OpusMSDecoder(int SampleRate, int Channels, int Streams, int CoupledStreams, byte[] mapping)
8184
{
@@ -147,8 +150,10 @@ public unsafe int Decode(byte[] input, int inputLength, short[] output, int fram
147150
/// Decodes a multistream Opus frame.
148151
/// </summary>
149152
/// <param name="input">Input in float format (interleaved if 2 channels), with a normal range of +/-1.0. Samples with a range beyond +/-1.0 are supported but will be clipped by decoders using the integer API and should only be used if it is known that the far end supports extended dynamic range. length is frame_size*channels*sizeof(float)</param>
150-
/// <param name="frame_size">The number of samples per channel of available space in pcm. If this is less than the maximum packet duration (120 ms; 5760 for 48kHz), this function will not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), then frame_size needs to be exactly the duration of audio that is missing, otherwise the decoder will not be in the optimal state to decode the next incoming packet. For the PLC and FEC cases, frame_size must be a multiple of 2.5 ms.</param>
153+
/// <param name="inputLength">The number of samples per channel of available space in pcm. If this is less than the maximum packet duration (120 ms; 5760 for 48kHz), this function will not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), then frame_size needs to be exactly the duration of audio that is missing, otherwise the decoder will not be in the optimal state to decode the next incoming packet. For the PLC and FEC cases, frame_size must be a multiple of 2.5 ms.</param>
151154
/// <param name="output">Output signal, with interleaved samples. This must contain room for frame_size*channels samples.</param>
155+
/// <param name="frame_size"></param>
156+
/// <param name="decodeFEC">Flag (false or true) to request that any in-band forward error correction data be decoded. If no such data is available, the frame is decoded as if it were lost.</param>
152157
/// <param name="inputOffset">Offset to start reading in the input.</param>
153158
/// <param name="outputOffset">Offset to start writing in the output.</param>
154159
/// <returns>The length of the decoded packet on success or a negative error code (see <see cref="Enums.OpusError"/>) on failure. Note: OpusSharp throws an error if there is a negative error code.</returns>
@@ -184,7 +189,6 @@ public void DecoderCtl(Enums.DecoderCtl ctl, int value)
184189
/// Requests a CTL on the multistream decoder.
185190
/// </summary>
186191
/// <param name="ctl">The decoder CTL to request.</param>
187-
/// <param name="value">The value that is outputted from the CTL.</param>
188192
/// <exception cref="ObjectDisposedException"></exception>
189193
/// <exception cref="OpusException"></exception>
190194
public int DecoderCtl(Enums.DecoderCtl ctl)
@@ -223,6 +227,10 @@ public int DecoderCtl(Enums.GenericCtl ctl)
223227
return val;
224228
}
225229

230+
/// <summary>
231+
/// Disposes the object.
232+
/// </summary>
233+
/// <param name="disposing"></param>
226234
protected override void Dispose(bool disposing)
227235
{
228236
if (disposing)

OpusSharp.Core/OpusMSEncoder.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ public void EncoderCtl(Enums.EncoderCtl ctl, int value)
265265
/// Requests a CTL on the encoder.
266266
/// </summary>
267267
/// <param name="ctl">The encoder CTL to request.</param>
268-
/// <param name="value">The value that is outputted from the CTL.</param>
269268
/// <exception cref="ObjectDisposedException"></exception>
270269
/// <exception cref="OpusException"></exception>
271270
public int EncoderCtl(Enums.EncoderCtl ctl)
@@ -304,6 +303,10 @@ public int EncoderCtl(Enums.GenericCtl ctl)
304303
return val;
305304
}
306305

306+
/// <summary>
307+
/// Disposes the object.
308+
/// </summary>
309+
/// <param name="disposing"></param>
307310
protected override void Dispose(bool disposing)
308311
{
309312
if (disposing)

OpusSharp.Core/OpusSharp.Core.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<TargetFrameworks>netstandard2.0;net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
77
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
88
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
9+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
10+
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
911
</PropertyGroup>
1012

1113
<PropertyGroup Condition="'$(IsWindows)'=='true'">

OpusSharp.Core/OpusSharp.Core.nuspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
<files>
1818
<file src="bin/Release/netstandard2.0/OpusSharp.dll" target="lib/netstandard2.0/OpusSharp.dll" />
1919
<file src="bin/Release/netstandard2.0/OpusSharp.pdb" target="lib/netstandard2.0/OpusSharp.pdb" />
20+
<file src="bin/Release/netstandard2.0/OpusSharp.xml" target="lib/netstandard2.0" />
2021
</files>
2122
</package>

OpusSharp.Core/Repacketizer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ private void ThrowIfDisposed()
109109
}
110110
}
111111

112+
/// <summary>
113+
/// Disposes the object.
114+
/// </summary>
115+
/// <param name="disposing"></param>
112116
protected override void Dispose(bool disposing)
113117
{
114118
if (disposing)

0 commit comments

Comments
 (0)