]> git.basschouten.com Git - openhab-addons.git/blob
68a842f2fe1367efc519c5296c2a136b6f9d1268
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.pulseaudio.internal.items;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 /**
19  * GenericAudioItems are any kind of items that deal with audio data and can be
20  * muted or their volume can be changed.
21  *
22  * @author Tobias Bräutigam - Initial contribution
23  */
24 @NonNullByDefault
25 public abstract class AbstractAudioDeviceConfig extends AbstractDeviceConfig {
26
27     public enum State {
28         SUSPENDED,
29         IDLE,
30         RUNNING,
31         CORKED,
32         DRAINED
33     }
34
35     protected @Nullable State state;
36     protected boolean muted;
37     protected int volume;
38     protected @Nullable Module module;
39
40     public AbstractAudioDeviceConfig(int id, String name, @Nullable Module module) {
41         super(id, name);
42         this.module = module;
43     }
44
45     public @Nullable Module getModule() {
46         return module;
47     }
48
49     public @Nullable State getState() {
50         return state;
51     }
52
53     public void setState(State state) {
54         this.state = state;
55     }
56
57     public boolean isMuted() {
58         return muted;
59     }
60
61     public void setMuted(boolean muted) {
62         this.muted = muted;
63     }
64
65     public int getVolume() {
66         return volume;
67     }
68
69     public void setVolume(int volume) {
70         this.volume = volume;
71     }
72
73     @Override
74     public String toString() {
75         return this.getClass().getSimpleName() + " #" + id + " (Module: " + module + ") " + name + ", muted: " + muted
76                 + ", state: " + state + ", volume: " + volume;
77     }
78 }