33
33
34
34
import com .jme3 .asset .AssetManager ;
35
35
import com .jme3 .asset .AssetNotFoundException ;
36
+ import com .jme3 .audio .AudioData .DataType ;
36
37
import com .jme3 .export .InputCapsule ;
37
38
import com .jme3 .export .JmeExporter ;
38
39
import com .jme3 .export .JmeImporter ;
@@ -86,7 +87,6 @@ public class AudioNode extends Node implements AudioSource {
86
87
protected float innerAngle = 360 ;
87
88
protected float outerAngle = 360 ;
88
89
protected boolean positional = true ;
89
- protected Type type = null ;
90
90
91
91
/**
92
92
* <code>Status</code> indicates the current status of the audio node.
@@ -113,26 +113,6 @@ public enum Status {
113
113
Stopped ,
114
114
}
115
115
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
- }
136
116
/**
137
117
* Creates a new <code>AudioNode</code> without any audio data set.
138
118
*/
@@ -147,22 +127,17 @@ public AudioNode() {
147
127
*/
148
128
public AudioNode (AudioData audioData , AudioKey audioKey ) {
149
129
setAudioData (audioData , audioKey );
150
- if (audioKey .isStream ()) {
151
- type = Type .Streaming ;
152
- } else {
153
- type = Type .Buffered ;
154
- }
155
130
}
156
131
157
132
/**
158
133
* Creates a new <code>AudioNode</code> with the given audio file.
159
134
* @param assetManager The asset manager to use to load the audio file
160
135
* @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>)
163
138
*/
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 );
166
141
}
167
142
168
143
/**
@@ -177,16 +152,11 @@ public AudioNode(AssetManager assetManager, String name, Type type) {
177
152
* be read entirely but not decoded, allowing features such as
178
153
* seeking, looping and determining duration.
179
154
*
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
181
156
*/
182
157
public AudioNode (AssetManager assetManager , String name , boolean stream , boolean streamCache ) {
183
158
this .audioKey = new AudioKey (name , stream , streamCache );
184
159
this .data = (AudioData ) assetManager .loadAsset (audioKey );
185
- if (stream ) {
186
- type = Type .Streaming ;
187
- } else {
188
- type = Type .Buffered ;
189
- }
190
160
}
191
161
192
162
/**
@@ -197,7 +167,7 @@ public AudioNode(AssetManager assetManager, String name, boolean stream, boolean
197
167
* @param stream If true, the audio will be streamed gradually from disk,
198
168
* otherwise, it will be buffered.
199
169
*
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
201
171
*/
202
172
public AudioNode (AssetManager assetManager , String name , boolean stream ) {
203
173
this (assetManager , name , stream , true ); // Always streamCached
@@ -213,18 +183,18 @@ public AudioNode(AssetManager assetManager, String name, boolean stream) {
213
183
* @deprecated AudioRenderer parameter is ignored.
214
184
*/
215
185
public AudioNode (AudioRenderer audioRenderer , AssetManager assetManager , String name ) {
216
- this (assetManager , name , Type . Buffered );
186
+ this (assetManager , name , DataType . Buffer );
217
187
}
218
188
219
189
/**
220
190
* Creates a new <code>AudioNode</code> with the given audio file.
221
191
*
222
192
* @param assetManager The asset manager to use to load the audio file
223
193
* @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
225
195
*/
226
196
public AudioNode (AssetManager assetManager , String name ) {
227
- this (assetManager , name , Type . Buffered );
197
+ this (assetManager , name , DataType . Buffer );
228
198
}
229
199
230
200
protected AudioRenderer getRenderer () {
@@ -330,12 +300,6 @@ public void setAudioData(AudioData audioData, AudioKey audioKey) {
330
300
331
301
data = audioData ;
332
302
this .audioKey = audioKey ;
333
-
334
- if (audioKey .isStream ()) {
335
- type = Type .Streaming ;
336
- } else {
337
- type = Type .Buffered ;
338
- }
339
303
}
340
304
341
305
/**
@@ -364,14 +328,16 @@ public final void setStatus(AudioSource.Status status) {
364
328
}
365
329
366
330
/**
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()
370
333
* <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.
372
335
*/
373
- public Type getType () {
374
- return type ;
336
+ public DataType getType () {
337
+ if (data == null )
338
+ return null ;
339
+ else
340
+ return data .getDataType ();
375
341
}
376
342
377
343
/**
0 commit comments