jmri
Interface AudioManager

All Superinterfaces:
Manager
All Known Implementing Classes:
AbstractAudioManager, DefaultAudioManager

public interface AudioManager
extends Manager

Locate an Audio object representing some specific audio information.

Audo objects are obtained from an AudioManager, which in turn is generally located from the InstanceManager. A typical call sequence might be:

 Audio audio = InstanceManager.audioManagerInstance().provideAudio("myAudio");

Each Audio has two names. The "user" name is entirely free form, and can be used for any purpose. The "system" name is provided by the system-specific implementations, if any, and provides a unique mapping to the layout control system (e.g. LocoNet, NCE, etc) and address within that system. Note that most (all?) layout systems don't have anything corresponding to this, in which case the "Internal" Audio objects are still available with names like IAS23.

Much of the book-keeping is implemented in the AbstractAudioManager class, which can form the basis for a system-specific implementation.


This file is part of JMRI.

JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.

JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Author:
Matthew Harris Copyright (c) 2009

Field Summary
static int MAX_BUFFERS
          Define the maximum number of AudioBuffer objects that can be created
static int MAX_LISTENERS
          Define the maximum number of AudioListener objects that can be created
static int MAX_SOURCES
          Define the maximum number of AudioSource objects that can be created
 
Method Summary
 void cleanUp()
          Perform any clean-up operations
 AudioFactory getActiveAudioFactory()
          Returns the currently active AudioFactory object.
 Audio getAudio(String name)
          Locate via user name, then system name if needed.
 Audio getBySystemName(String systemName)
          Locate an instance based on a system name.
 Audio getByUserName(String userName)
          Locate an instance based on a user name.
 List<String> getSystemNameList()
          Get a list of all Audio objects' system names.
 List<String> getSystemNameList(int subType)
          Get a list of specified Audio sub-type objects' system names.
 void init()
          Perform any initialisation operations
 Audio newAudio(String systemName, String userName)
          Return an instance with the specified system and user names.
 Audio provideAudio(String name)
          Locate via user name, then system name if needed.
 
Methods inherited from interface jmri.Manager
addPropertyChangeListener, deregister, dispose, getSystemNameArray, makeSystemName, register, removePropertyChangeListener, systemLetter, typeLetter
 

Field Detail

MAX_LISTENERS

static final int MAX_LISTENERS
Define the maximum number of AudioListener objects that can be created

See Also:
Constant Field Values

MAX_SOURCES

static final int MAX_SOURCES
Define the maximum number of AudioSource objects that can be created

See Also:
Constant Field Values

MAX_BUFFERS

static final int MAX_BUFFERS
Define the maximum number of AudioBuffer objects that can be created

See Also:
Constant Field Values
Method Detail

provideAudio

Audio provideAudio(String name)
                   throws AudioException
Locate via user name, then system name if needed. If that fails, create a new Audio. If the name is a valid system name, it will be used for the new Audio. Otherwise, the makeSystemName method will attempt to turn it into a valid system name.

Parameters:
name -
Returns:
Never null under normal circumstances
Throws:
AudioException - if error occurs during creation

getAudio

Audio getAudio(String name)
Locate via user name, then system name if needed. If that fails, return null

Parameters:
name -
Returns:
null if no match found

getBySystemName

Audio getBySystemName(String systemName)
Locate an instance based on a system name. Returns null if no instance already exists.

Parameters:
systemName - Audio object system name (e.g. IAS1, IAB4)
Returns:
requested Audio object or null if none exists

getByUserName

Audio getByUserName(String userName)
Locate an instance based on a user name. Returns null if no instance already exists.

Parameters:
userName - Audio object user name
Returns:
requested Audio object or null if none exists

newAudio

Audio newAudio(String systemName,
               String userName)
               throws AudioException
Return an instance with the specified system and user names. Note that two calls with the same arguments will get the same instance; there is only one Audio object representing a given physical Audio and therefore only one with a specific system or user name.

This will always return a valid object reference; a new object will be created if necessary. In that case:

Note that it is possible to make an inconsistent request if both addresses are provided, but the given values are associated with different objects. This is a problem, and we don't have a good solution except to issue warnings. This will mostly happen if you're creating Audio objects when you should be looking them up.

Parameters:
systemName - Audio object system name (e.g. IAS1, IAB4)
userName - Audio object user name
Returns:
requested Audio object (never null)
Throws:
AudioException - if error occurs during creation

getActiveAudioFactory

AudioFactory getActiveAudioFactory()
Returns the currently active AudioFactory object.

An Audio factory is responsible for the creation of implementation specific audio objects.

Returns:
current active AudioFactory object

getSystemNameList

List<String> getSystemNameList()
Get a list of all Audio objects' system names.

Specified by:
getSystemNameList in interface Manager
Returns:
List of all Audio objects' system names

getSystemNameList

List<String> getSystemNameList(int subType)
Get a list of specified Audio sub-type objects' system names.

Parameters:
subType - sub-type to retrieve
Returns:
List of specified Audio sub-type objects' system names.

init

void init()
Perform any initialisation operations


cleanUp

void cleanUp()
Perform any clean-up operations



Copyright © 1997 - 2009 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads