In Reading mode, will close the underlying ogg file and free its resources. In Writing mode, will write out the Info and Tags objects, and then the audio data.
()
| 192 | * Tags objects, and then the audio data. |
| 193 | */ |
| 194 | public void close() throws IOException { |
| 195 | if(r != null) { |
| 196 | r = null; |
| 197 | ogg.close(); |
| 198 | ogg = null; |
| 199 | } |
| 200 | if(w != null) { |
| 201 | w.bufferPacket(info.write(), true); |
| 202 | w.bufferPacket(tags.write(), false); |
| 203 | |
| 204 | long lastGranule = 0; |
| 205 | for(SpeexAudioData vd : writtenPackets) { |
| 206 | // Update the granule position as we go |
| 207 | if(vd.getGranulePosition() >= 0 && |
| 208 | lastGranule != vd.getGranulePosition()) { |
| 209 | w.flush(); |
| 210 | lastGranule = vd.getGranulePosition(); |
| 211 | w.setGranulePosition(lastGranule); |
| 212 | } |
| 213 | |
| 214 | // Write the data, flushing if needed |
| 215 | w.bufferPacket(vd.write()); |
| 216 | if(w.getSizePendingFlush() > 16384) { |
| 217 | w.flush(); |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | w.close(); |
| 222 | w = null; |
| 223 | ogg.close(); |
| 224 | ogg = null; |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * Returns the underlying Ogg File instance |