libGizmod/AlsaMixerElements.cpp

Go to the documentation of this file.
00001 
00012 /*
00013   
00014   Copyright (c) 2007, Tim Burrell
00015   Licensed under the Apache License, Version 2.0 (the "License");
00016   you may not use this file except in compliance with the License.
00017   You may obtain a copy of the License at 
00018 
00019         http://www.apache.org/licenses/LICENSE-2.0
00020 
00021   Unless required by applicable law or agreed to in writing, software
00022   distributed under the License is distributed on an "AS IS" BASIS,
00023   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00024   See the License for the specific language governing permissions and 
00025   limitations under the License. 
00026   
00027 */
00028 
00029 #include "AlsaMixerElements.hpp"
00030 #include "Alsa.hpp"
00031 #include "../libH/Debug.hpp"
00032 #include "../libH/Exception.hpp"
00033 
00034 using namespace std;
00035 using namespace H;
00036 using namespace Gizmod;
00037 
00039 // Construction
00041 
00045 AlsaMixerElements::AlsaMixerElements() {
00046         IsActive = false;
00047         HasCommonVolume = false;
00048         HasPlaybackVolume = false;
00049         HasPlaybackVolumeJoined = false;
00050         HasCaptureVolume = false;
00051         HasCaptureVolumeJoined = false;
00052         HasCommonSwitch = false;
00053         HasPlaybackSwitch = false;
00054         HasPlaybackSwitchJoined = false;
00055         HasCaptureSwitch = false;
00056         HasCaptureSwitchJoined = false;
00057         HasCaptureSwitchExclusive = false;
00058         
00059         VolumePlayback = 0;
00060         VolumePlaybackMin = 0;
00061         VolumePlaybackMax = 0;
00062         VolumePlaybackPercent = 0.0f;
00063 
00064         VolumeCapture = 0;
00065         VolumeCaptureMin = 0;
00066         VolumeCaptureMax = 0;
00067         VolumeCapturePercent = 0.0f;
00068         
00069         SwitchPlayback = false;
00070         SwitchCapture = false;
00071 }
00072 
00076 AlsaMixerElements::AlsaMixerElements(AlsaMixerElements const & Init) {
00077         IsActive = Init.IsActive;
00078         HasCommonVolume = Init.HasCommonVolume;
00079         HasPlaybackVolume = Init.HasPlaybackVolume;
00080         HasPlaybackVolumeJoined = Init.HasPlaybackVolumeJoined;
00081         HasCaptureVolume = Init.HasCommonVolume;
00082         HasCaptureVolumeJoined = Init.HasCaptureVolumeJoined;
00083         HasCommonSwitch = Init.HasCommonSwitch;
00084         HasPlaybackSwitch = Init.HasPlaybackSwitch;
00085         HasPlaybackSwitchJoined = Init.HasPlaybackSwitchJoined;
00086         HasCaptureSwitch = Init.HasCaptureSwitch;
00087         HasCaptureSwitchJoined = Init.HasCaptureSwitchJoined;
00088         HasCaptureSwitchExclusive = Init.HasCaptureSwitchExclusive;
00089         
00090         VolumePlayback = Init.VolumePlayback;
00091         VolumePlaybackMin = Init.VolumePlaybackMin;
00092         VolumePlaybackMax = Init.VolumePlaybackMax;
00093         VolumePlaybackPercent = Init.VolumePlaybackPercent;
00094 
00095         VolumeCapture = Init.VolumeCapture;
00096         VolumeCaptureMin = Init.VolumeCaptureMin;
00097         VolumeCaptureMax = Init.VolumeCaptureMax;
00098         VolumeCapturePercent = Init.VolumeCapturePercent;
00099 
00100         SwitchPlayback = Init.SwitchPlayback;
00101         SwitchCapture = Init.SwitchCapture;
00102 }
00103 
00107 AlsaMixerElements::~AlsaMixerElements() {
00108 }
00109 
00111 // Class Body
00113 
00120 void AlsaMixerElements::buildEventFromMixerStates(AlsaEvent & Event, AlsaMixerElements const & OldElements, AlsaMixerElements const & NewElements) {
00121         Event.IsActiveChanged = false;
00122         Event.ElementsChanged = false;
00123         Event.VolumePlaybackChanged = false;
00124         Event.SwitchCaptureChanged = false;
00125         Event.SwitchPlaybackChanged = false;
00126         
00127         if (OldElements.IsActive != NewElements.IsActive)
00128                 Event.IsActiveChanged = true;
00129         
00130         if ( (OldElements.HasCommonVolume != NewElements.HasCommonVolume) ||
00131              (OldElements.HasPlaybackVolume != NewElements.HasPlaybackVolume) ||
00132              (OldElements.HasPlaybackVolumeJoined != NewElements.HasPlaybackVolumeJoined) ||
00133              (OldElements.HasCaptureVolume != NewElements.HasCommonVolume) ||
00134              (OldElements.HasCaptureVolumeJoined != NewElements.HasCaptureVolumeJoined) ||
00135              (OldElements.HasCommonSwitch != NewElements.HasCommonSwitch) ||
00136              (OldElements.HasPlaybackSwitch != NewElements.HasPlaybackSwitch) ||
00137              (OldElements.HasPlaybackSwitchJoined != NewElements.HasPlaybackSwitchJoined) ||
00138              (OldElements.HasCaptureSwitch != NewElements.HasCaptureSwitch) ||
00139              (OldElements.HasCaptureSwitchJoined != NewElements.HasCaptureSwitchJoined) ||
00140              (OldElements.HasCaptureSwitchExclusive != NewElements.HasCaptureSwitchExclusive) ) {
00141                 Event.ElementsChanged = true;
00142         }
00143                 
00144         if ( (OldElements.VolumePlayback != NewElements.VolumePlayback) ||
00145              (OldElements.VolumePlaybackMin != NewElements.VolumePlaybackMin) ||
00146              (OldElements.VolumePlaybackMax != NewElements.VolumePlaybackMax) ) {
00147                 Event.VolumePlaybackChanged = true;
00148         }
00149 
00150         if ( (OldElements.VolumeCapture != NewElements.VolumeCapture) ||
00151              (OldElements.VolumeCaptureMin != NewElements.VolumeCaptureMin) ||
00152              (OldElements.VolumeCaptureMax != NewElements.VolumeCaptureMax) ) {
00153                 Event.VolumeCaptureChanged = true;
00154         }
00155 
00156         if (OldElements.SwitchCapture != NewElements.SwitchCapture)
00157                 Event.SwitchCaptureChanged = true;
00158         
00159         if (OldElements.SwitchPlayback != NewElements.SwitchPlayback)
00160                 Event.SwitchPlaybackChanged = true;
00161 }

Generated on Wed Nov 7 10:04:16 2007 for gizmod by  doxygen 1.5.3