From 378ff7aa119b3a5c9fe7cb7ddf06c714b013286e Mon Sep 17 00:00:00 2001 From: Victor Gaydov Date: Wed, 31 May 2023 17:31:36 +0400 Subject: [PATCH] Refine comments and validation for some config fields --- .../org/rocstreaming/roctoolkit/Check.java | 7 +++++ .../roctoolkit/RocContextConfig.java | 7 +++-- .../roctoolkit/RocReceiverConfig.java | 31 ++++++++++++++----- .../roctoolkit/RocSenderConfig.java | 29 +++++++++++------ .../org/rocstreaming/roctoolkit/Slot.java | 3 ++ 5 files changed, 58 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/rocstreaming/roctoolkit/Check.java b/src/main/java/org/rocstreaming/roctoolkit/Check.java index dddb8f58..1714f32c 100644 --- a/src/main/java/org/rocstreaming/roctoolkit/Check.java +++ b/src/main/java/org/rocstreaming/roctoolkit/Check.java @@ -24,4 +24,11 @@ static int notNegative(int value, String name) { } return value; } + + static long notNegative(long value, String name) { + if (value < 0) { + throw new IllegalArgumentException(name + " must not be negative"); + } + return value; + } } diff --git a/src/main/java/org/rocstreaming/roctoolkit/RocContextConfig.java b/src/main/java/org/rocstreaming/roctoolkit/RocContextConfig.java index 9d8e77fa..4b31fe8c 100644 --- a/src/main/java/org/rocstreaming/roctoolkit/RocContextConfig.java +++ b/src/main/java/org/rocstreaming/roctoolkit/RocContextConfig.java @@ -19,7 +19,8 @@ public class RocContextConfig { * Maximum size in bytes of a network packet. * Defines the amount of bytes allocated per network packet. * Sender and receiver won't handle packets larger than this. - * If zero, default value is used. + * If zero or unset, default value is used. + * Should not be negative. */ private int maxPacketSize; @@ -27,7 +28,9 @@ public class RocContextConfig { * Maximum size in bytes of an audio frame. * Defines the amount of bytes allocated per intermediate internal * frame in the pipeline. Does not limit the size of the frames - * provided by user. If zero, default value is used. + * provided by user. + * If zero or unset, default value is used. + * Should not be negative. */ private int maxFrameSize; diff --git a/src/main/java/org/rocstreaming/roctoolkit/RocReceiverConfig.java b/src/main/java/org/rocstreaming/roctoolkit/RocReceiverConfig.java index e4f1c03c..7b3fe524 100644 --- a/src/main/java/org/rocstreaming/roctoolkit/RocReceiverConfig.java +++ b/src/main/java/org/rocstreaming/roctoolkit/RocReceiverConfig.java @@ -18,34 +18,39 @@ public class RocReceiverConfig { /** * The rate of the samples in the frames returned to the user. * Number of samples per channel per second. + * Should be set to a positive value. */ private int frameSampleRate; /** * The channel set in the frames returned to the user. + * Should be set to a non-null value. */ private ChannelSet frameChannels; /** * The sample encoding in the frames returned to the user. + * Should be set to a non-null value. */ private FrameEncoding frameEncoding; /** * Clock source to use. * Defines whether read operation will be blocking or non-blocking. - * If zero, default value is used. + * If null or unset, default value is used. */ private ClockSource clockSource; /** * Resampler backend to use. + * If null or unset, default value is used. */ private ResamplerBackend resamplerBackend; /** * Resampler profile to use. - * If non-zero, the receiver employs resampler for two purposes: + * If null or unset, default value is used. + * If resampling is enabled, the receiver employs resampler for two purposes: *