Package jmri

Interface AudioManager

All Superinterfaces:
Manager<Audio>, PropertyChangeProvider, SilenceablePropertyChangeProvider, VetoableChangeProvider
All Known Implementing Classes:
AbstractAudioManager, DefaultAudioManager

public interface AudioManager
extends Manager<Audio>
Locate an Audio object representing some specific audio information.

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

 Audio audio = InstanceManager.getDefault(jmri.AudioManager.class).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 (for example LocoNet or NCE) 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.

  • Field Details

  • Method Details

    • provideAudio

      Get the Audio with the 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 - User name or system name to match, or which can be promoted to system name
      Returns:
      Never null under normal circumstances
      Throws:
      AudioException - if error occurs during creation
    • getAudio

      Get an existing Audio or return null if it doesn't exists. Locates via user name, then system name if needed.
      Parameters:
      name - User name or system name to match
      Returns:
      null if no match found
    • getBySystemName

      Get the Audio with the given system name or return null if no instance already exists.
      Specified by:
      getBySystemName in interface Manager<Audio>
      Parameters:
      systemName - Audio object system name (such as IAS1 or IAB4)
      Returns:
      requested Audio object or null if none exists
    • getByUserName

      Get the Audio with the given user name or return null if no instance already exists.
      Specified by:
      getByUserName in interface Manager<Audio>
      Parameters:
      userName - Audio object user name
      Returns:
      requested Audio object or null if none exists
    • newAudio

      @Nonnull Audio newAudio​(@Nonnull String systemName, String userName) throws AudioException
      Return an Audio 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:

      • If a null reference is given for user name, no user name will be associated with the Audio object created; a valid system name must be provided
      • If both names are provided, the system name defines the hardware access of the desired Audio, and the user address is associated with it. The system name must be valid.
      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 (such as IAS1 or IAB4)
      userName - Audio object user name
      Returns:
      requested Audio object (never null)
      Throws:
      AudioException - if error occurs during creation
    • 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

      Deprecated.
      4.17.6 use direct access via getNamedBeanSet(char)
      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.
    • getNamedBeanSet

      Get the specified Audio sub-type NamedBeans.
      Parameters:
      subType - sub-type to retrieve
      Returns:
      Unmodifiable access to a SortedSet of NamedBeans for the specified Audio sub-type .
      Since:
      4.17.6
    • init

      void init()
      Perform any initialisation operations
    • cleanup

      void cleanup()
      Perform any clean-up operations
    • isInitialised

      boolean isInitialised()
      Determine if this AudioManager is initialised
      Returns:
      true if initialised