001package jmri.jmrit.audio;
002
003import java.io.InputStream;
004import org.slf4j.Logger;
005import org.slf4j.LoggerFactory;
006
007/**
008 * Null implementation of the Audio Buffer sub-class.
009 * <p>
010 * For now, no system-specific implementations are forseen - this will remain
011 * internal-only
012 *
013 * <hr>
014 * This file is part of JMRI.
015 * <p>
016 * JMRI is free software; you can redistribute it and/or modify it under the
017 * terms of version 2 of the GNU General Public License as published by the Free
018 * Software Foundation. See the "COPYING" file for a copy of this license.
019 * <p>
020 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY
021 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
022 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
023 *
024 * @author Matthew Harris copyright (c) 2009, 2011
025 */
026public class NullAudioBuffer extends AbstractAudioBuffer {
027
028    /**
029     * Constructor for new NullAudioBuffer with system name
030     *
031     * @param systemName AudioBuffer object system name (e.g. IAB4)
032     */
033    public NullAudioBuffer(String systemName) {
034        super(systemName);
035        if (log.isDebugEnabled()) {
036            log.debug("New NullAudioBuffer: {}", systemName);
037        }
038    }
039
040    /**
041     * Constructor for new NullAudioBuffer with system name and user name
042     *
043     * @param systemName AudioBuffer object system name (e.g. IAB4)
044     * @param userName   AudioBuffer object user name
045     */
046    public NullAudioBuffer(String systemName, String userName) {
047        super(systemName, userName);
048        if (log.isDebugEnabled()) {
049            log.debug("New NullAudioBuffer: {} ({})", userName, systemName);
050        }
051    }
052
053    @Override
054    protected boolean loadBuffer(InputStream stream) {
055        // No need to do this for the NullAudioBuffer - it's always successful ;-)
056        return true;
057    }
058
059    @Override
060    protected boolean loadBuffer() {
061        // No need to do this for the NullAudioBuffer - it's always successful ;-)
062        return true;
063    }
064
065    @Override
066    protected void generateLoopBuffers(int which) {
067        // No need to do anything for the NullAudioBuffer
068    }
069
070    @Override
071    protected boolean generateStreamingBuffers() {
072        // No need to do this for the NullAudioBuffer - it's always successful ;-)
073        return true;
074    }
075
076    @Override
077    protected void removeStreamingBuffers() {
078        // No need to do anything for the NullAudioBuffer
079    }
080
081    @Override
082    public int getFormat() {
083        return FORMAT_UNKNOWN;
084    }
085
086    @Override
087    public long getLength() {
088        // Nothing stored for the NullAudioBuffer - always zero
089        return 0;
090    }
091
092    @Override
093    public int getFrequency() {
094        // Nothing stored for the NullAudioBuffer - always zero
095        return 0;
096    }
097
098    @Override
099    protected void cleanup() {
100        if (log.isDebugEnabled()) {
101            log.debug("Cleanup NullAudioBuffer ({})", this.getSystemName());
102        }
103    }
104
105    private static final Logger log = LoggerFactory.getLogger(NullAudioBuffer.class);
106
107}