From 6a74d16a805a4204093972bb91361b2aa633065c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 23 May 2023 01:37:01 +0200 Subject: AudioSink: Drop getMaxSupportedChannels(), use getNativeFormat(), getPreferredFormat() and isSupported(); Add setChannelLimit() impacting Add setChannelLimit() impacting getPreferredFormat() and isSupported(), i.e. to limit channels for e.g. JOAL/OpenAL spatial 3D sound usage. getNativeFormat() shall be unaffected. getMaxSupportedChannels() is redudandant -> getPreferredFormat() --- src/java/com/jogamp/common/av/AudioSink.java | 65 ++++++++++++++++++---------- 1 file changed, 41 insertions(+), 24 deletions(-) (limited to 'src/java/com/jogamp/common') diff --git a/src/java/com/jogamp/common/av/AudioSink.java b/src/java/com/jogamp/common/av/AudioSink.java index 9c31244..ac6441a 100644 --- a/src/java/com/jogamp/common/av/AudioSink.java +++ b/src/java/com/jogamp/common/av/AudioSink.java @@ -196,21 +196,6 @@ public interface AudioSink { */ public boolean setVolume(float v); - /** - * Returns the preferred sample-rate of this sink, i.e. mixer frequency in Hz, e.g. 41000 or 48000. - *

- * The preferred sample-rate is guaranteed to be supported - * and shall reflect this sinks most native format, - * i.e. best performance w/o data conversion. - *

- *

- * May return {@link AudioSink#DefaultFormat}'s 44100 default if undefined. - *

- * @see #init(AudioFormat, float, int, int, int) - * @see #isSupported(AudioFormat) - */ - public int getPreferredSampleRate(); - /** * Returns the number of sources the used device is capable to mix. *

@@ -236,32 +221,64 @@ public interface AudioSink { public float getDefaultLatency(); /** - * Returns the preferred {@link AudioFormat} by this sink. + * Returns the native {@link AudioFormat} by this sink. *

- * The preferred format is guaranteed to be supported + * The native format is guaranteed to be supported * and shall reflect this sinks most native format, * i.e. best performance w/o data conversion. *

*

+ * The native format is not impacted by {@link #setChannelLimit(int)}. + *

+ *

+ * May return {@link AudioSink#DefaultFormat} if undefined. + *

+ * @see #init(AudioFormat, float, int, int, int) + */ + public AudioFormat getNativeFormat(); + + /** + * Returns the preferred {@link AudioFormat} by this sink. + *

+ * The preferred format is a subset of {@link #getNativeFormat()}, + * impacted by {@link #setChannelLimit(int)}. + *

+ *

* Known {@link #AudioFormat} attributes considered by implementations: *

*

- *

- * May return {@link AudioSink#DefaultFormat} if undefined. - *

+ * @see #getNativeFormat() * @see #init(AudioFormat, float, int, int, int) + * @see #setChannelLimit(int) * @see #isSupported(AudioFormat) - * @see #getPreferredSampleRate() */ public AudioFormat getPreferredFormat(); - /** Return the maximum number of supported channels, e.g. 1 for mono, 2 for stereo, etc. */ - public int getMaxSupportedChannels(); + /** + * Limit maximum supported audio channels by user. + *

+ * Must be set before {@link #getPreferredFormat()}, {@link #isSupported(AudioFormat)} and naturally {@link #init(AudioFormat, int, int, int, int)}. + *

+ *

+ * May be utilized to enforce 1 channel (mono) downsampling + * in combination with JOAL/OpenAL to experience spatial 3D position effects. + *

+ * @param cc maximum supported audio channels, will be clipped [1..{@link #getNativeFormat()}.{@link AudioFormat#channelCount channelCount}] + * @see #getNativeFormat() + * @see #getPreferredFormat() + * @see #isSupported(AudioFormat) + * @see #init(AudioFormat, int, int, int, int) + */ + public void setChannelLimit(final int cc); /** * Returns true if the given format is supported by the sink, otherwise false. + *

+ * The {@link #getPreferredFormat()} is used to validate compatibility with the given format. + *

* @see #init(AudioFormat, float, int, int, int) * @see #getPreferredFormat() */ @@ -275,7 +292,7 @@ public interface AudioSink { *

* Caller shall validate requestedFormat via {@link #isSupported(AudioFormat)} * beforehand and try to find a suitable supported one. - * {@link #getPreferredFormat()} and {@link #getMaxSupportedChannels()} may help. + * {@link #getPreferredFormat()} may help. *

* @param requestedFormat the requested {@link AudioFormat}. * @param frameDurationHint average {@link AudioFrame} duration hint in milliseconds. -- cgit v1.2.3