Path: blob/main/src/lwjgl/java/tritonus/TAudioInputStream.java
8642 views
/*1* TAudioInputStream.java2*3* This file is part of Tritonus: http://www.tritonus.org/4*/56/*7* Copyright (c) 2003 by Matthias Pfisterer8* Copyright (c) 2012 by fireandfuel from Cuina Team (http://www.cuina.byethost12.com/)9*10* This program is free software; you can redistribute it and/or modify11* it under the terms of the GNU Library General Public License as published12* by the Free Software Foundation; either version 2 of the License, or13* (at your option) any later version.14*15* This program is distributed in the hope that it will be useful,16* but WITHOUT ANY WARRANTY; without even the implied warranty of17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the18* GNU Library General Public License for more details.19*20* You should have received a copy of the GNU Library General Public21* License along with this program; if not, write to the Free Software22* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.23*/2425package tritonus;2627import java.io.InputStream;2829import java.util.Collections;30import java.util.HashMap;31import java.util.Map;3233import javax.sound.sampled.AudioFormat;34import javax.sound.sampled.AudioInputStream;3536/**37* AudioInputStream base class. This class implements "dynamic" properties.38* "Dynamic" properties are properties that may change during the life time of39* the objects. This is typically used to pass information like the current40* frame number, volume of subbands and similar values. "Dynamic" properties are41* different from properties in AudioFormat and AudioFileFormat, which are42* considered "static", as they aren't allowed to change after creating of the43* object, thereby maintaining the immutable character of these classes.44*/4546public class TAudioInputStream extends AudioInputStream47{48private Map<String, Object> m_properties;49private Map<String, Object> m_unmodifiableProperties;5051/**52* Constructor without properties. Creates an empty properties map.53*/54public TAudioInputStream(InputStream inputStream, AudioFormat audioFormat, long lLengthInFrames)55{56super(inputStream, audioFormat, lLengthInFrames);57initMaps(new HashMap<String, Object>());58}5960/**61* Constructor with properties. The passed properties map is not copied.62* This allows subclasses to change values in the map after creation, and63* the changes are reflected in the map the application program can obtain.64*/65public TAudioInputStream(InputStream inputStream, AudioFormat audioFormat,66long lLengthInFrames, Map<String, Object> properties)67{68super(inputStream, audioFormat, lLengthInFrames);69initMaps(properties);70}7172private void initMaps(Map<String, Object> properties)73{74/*75* Here, we make a shallow copy of the map. It's unclear if this is76* sufficient (of if a deep copy should be made).77*/78m_properties = properties;79m_unmodifiableProperties = Collections.unmodifiableMap(m_properties);80}8182/**83* Obtain a Map containing the properties. This method returns a Map that84* cannot be modified by the application program, but reflects changes to85* the map made by the implementation.86*87* @return a map containing the properties.88*/89public Map<String, Object> properties()90{91return m_unmodifiableProperties;92}9394/**95* Set a property. Unlike in AudioFormat and AudioFileFormat, this method96* may be used anywhere by subclasses - it is not restricted to be used in97* the constructor.98*/99protected void setProperty(String key, Object value)100{101m_properties.put(key, value);102}103}104105/*** TAudioInputStream.java ***/106107108