Skip to content

Commit c900485

Browse files
committed
Removed AudioNode.Type in favor of AudioData.DataType, which is what we are using now.
1 parent 6f6e93e commit c900485

File tree

1 file changed

+18
-52
lines changed

1 file changed

+18
-52
lines changed

jme3-core/src/main/java/com/jme3/audio/AudioNode.java

+18-52
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import com.jme3.asset.AssetManager;
3535
import com.jme3.asset.AssetNotFoundException;
36+
import com.jme3.audio.AudioData.DataType;
3637
import com.jme3.export.InputCapsule;
3738
import com.jme3.export.JmeExporter;
3839
import com.jme3.export.JmeImporter;
@@ -86,7 +87,6 @@ public class AudioNode extends Node implements AudioSource {
8687
protected float innerAngle = 360;
8788
protected float outerAngle = 360;
8889
protected boolean positional = true;
89-
protected Type type = null;
9090

9191
/**
9292
* <code>Status</code> indicates the current status of the audio node.
@@ -113,26 +113,6 @@ public enum Status {
113113
Stopped,
114114
}
115115

116-
/**
117-
* <code>Type</code> indicates how to retrieve the audio data.
118-
* It replaced the old "stream" and "streamCache" parameters.
119-
* It defines whether the whole file is read and buffered or
120-
* if it is read gradually from disk.
121-
*/
122-
public enum Type {
123-
/**
124-
* The audio data will be loaded as whole and be buffered in memory.
125-
* Use this for short sounds.
126-
*/
127-
Buffered,
128-
129-
/**
130-
* The audio data will be streamed gradually from disk.
131-
* Use this for longer sounds.
132-
* Note: looping and seeking <b>is</b> supported.
133-
*/
134-
Streaming,
135-
}
136116
/**
137117
* Creates a new <code>AudioNode</code> without any audio data set.
138118
*/
@@ -147,22 +127,17 @@ public AudioNode() {
147127
*/
148128
public AudioNode(AudioData audioData, AudioKey audioKey) {
149129
setAudioData(audioData, audioKey);
150-
if (audioKey.isStream()) {
151-
type = Type.Streaming;
152-
} else {
153-
type = Type.Buffered;
154-
}
155130
}
156131

157132
/**
158133
* Creates a new <code>AudioNode</code> with the given audio file.
159134
* @param assetManager The asset manager to use to load the audio file
160135
* @param name The filename of the audio file
161-
* @param type The type. If <code>Type.Streaming</code>, the audio will be streamed gradually from disk,
162-
* otherwise it will be buffered (<code>Type.Buffered</code>)
136+
* @param type The type. If <code>{@link com.jme3.audio.AudioData.DataType}.Stream</code>, the audio will be streamed gradually from disk,
137+
* otherwise it will be buffered (<code>{@link com.jme3.audio.AudioData.DataType}.Buffer</code>)
163138
*/
164-
public AudioNode(AssetManager assetManager, String name, Type type) {
165-
this(assetManager, name, type == Type.Streaming, true);
139+
public AudioNode(AssetManager assetManager, String name, DataType type) {
140+
this(assetManager, name, type == DataType.Stream, true);
166141
}
167142

168143
/**
@@ -177,16 +152,11 @@ public AudioNode(AssetManager assetManager, String name, Type type) {
177152
* be read entirely but not decoded, allowing features such as
178153
* seeking, looping and determining duration.
179154
*
180-
* @deprecated Use {@link AudioNode#AudioNode(com.jme3.asset.AssetManager, java.lang.String, com.jme3.audio.AudioNode.Type)} instead
155+
* @deprecated Use {@link AudioNode#AudioNode(com.jme3.asset.AssetManager, java.lang.String, com.jme3.audio.AudioData.DataType)} instead
181156
*/
182157
public AudioNode(AssetManager assetManager, String name, boolean stream, boolean streamCache) {
183158
this.audioKey = new AudioKey(name, stream, streamCache);
184159
this.data = (AudioData) assetManager.loadAsset(audioKey);
185-
if (stream) {
186-
type = Type.Streaming;
187-
} else {
188-
type = Type.Buffered;
189-
}
190160
}
191161

192162
/**
@@ -197,7 +167,7 @@ public AudioNode(AssetManager assetManager, String name, boolean stream, boolean
197167
* @param stream If true, the audio will be streamed gradually from disk,
198168
* otherwise, it will be buffered.
199169
*
200-
* @deprecated Use {@link AudioNode#AudioNode(com.jme3.asset.AssetManager, java.lang.String, com.jme3.audio.AudioNode.Type)} instead
170+
* @deprecated Use {@link AudioNode#AudioNode(com.jme3.asset.AssetManager, java.lang.String, com.jme3.audio.AudioData.DataType)} instead
201171
*/
202172
public AudioNode(AssetManager assetManager, String name, boolean stream) {
203173
this(assetManager, name, stream, true); // Always streamCached
@@ -213,18 +183,18 @@ public AudioNode(AssetManager assetManager, String name, boolean stream) {
213183
* @deprecated AudioRenderer parameter is ignored.
214184
*/
215185
public AudioNode(AudioRenderer audioRenderer, AssetManager assetManager, String name) {
216-
this(assetManager, name, Type.Buffered);
186+
this(assetManager, name, DataType.Buffer);
217187
}
218188

219189
/**
220190
* Creates a new <code>AudioNode</code> with the given audio file.
221191
*
222192
* @param assetManager The asset manager to use to load the audio file
223193
* @param name The filename of the audio file
224-
* @deprecated Use {@link AudioNode#AudioNode(com.jme3.asset.AssetManager, java.lang.String, com.jme3.audio.AudioNode.Type)} instead
194+
* @deprecated Use {@link AudioNode#AudioNode(com.jme3.asset.AssetManager, java.lang.String, com.jme3.audio.AudioData.DataType) } instead
225195
*/
226196
public AudioNode(AssetManager assetManager, String name) {
227-
this(assetManager, name, Type.Buffered);
197+
this(assetManager, name, DataType.Buffer);
228198
}
229199

230200
protected AudioRenderer getRenderer() {
@@ -330,12 +300,6 @@ public void setAudioData(AudioData audioData, AudioKey audioKey) {
330300

331301
data = audioData;
332302
this.audioKey = audioKey;
333-
334-
if (audioKey.isStream()) {
335-
type = Type.Streaming;
336-
} else {
337-
type = Type.Buffered;
338-
}
339303
}
340304

341305
/**
@@ -364,14 +328,16 @@ public final void setStatus(AudioSource.Status status) {
364328
}
365329

366330
/**
367-
* This is set only once in the constructor.
368-
* It defines, whether the underlying Data is Buffered or
369-
* Streamed continuously.
331+
* Get the Type of the underlying AudioData to see if it's streamed or buffered.
332+
* This is a shortcut to getAudioData().getType()
370333
* <b>Warning</b>: Can return null!
371-
* @return The {@link Type} of the audio node.
334+
* @return The {@link com.jme3.audio.AudioData.DataType} of the audio node.
372335
*/
373-
public Type getType() {
374-
return type;
336+
public DataType getType() {
337+
if (data == null)
338+
return null;
339+
else
340+
return data.getDataType();
375341
}
376342

377343
/**

0 commit comments

Comments
 (0)