MCPcopy Create free account
hub / github.com/Aloshi/EmulationStation / init

Method init

src/VolumeControl.cpp:67–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67void VolumeControl::init()
68{
69 //initialize audio mixer interface
70#if defined (__APPLE__)
71 #error TODO: Not implemented for MacOS yet!!!
72#elif defined(__linux__)
73 //try to open mixer device
74 if (mixerHandle == nullptr)
75 {
76 snd_mixer_selem_id_alloca(&mixerSelemId);
77 //sets simple-mixer index and name
78 snd_mixer_selem_id_set_index(mixerSelemId, mixerIndex);
79 snd_mixer_selem_id_set_name(mixerSelemId, mixerName);
80 //open mixer
81 if (snd_mixer_open(&mixerHandle, 0) >= 0)
82 {
83 LOG(LogDebug) << "VolumeControl::init() - Opened ALSA mixer";
84 //ok. attach to defualt card
85 if (snd_mixer_attach(mixerHandle, mixerCard) >= 0)
86 {
87 LOG(LogDebug) << "VolumeControl::init() - Attached to default card";
88 //ok. register simple element class
89 if (snd_mixer_selem_register(mixerHandle, NULL, NULL) >= 0)
90 {
91 LOG(LogDebug) << "VolumeControl::init() - Registered simple element class";
92 //ok. load registered elements
93 if (snd_mixer_load(mixerHandle) >= 0)
94 {
95 LOG(LogDebug) << "VolumeControl::init() - Loaded mixer elements";
96 //ok. find elements now
97 mixerElem = snd_mixer_find_selem(mixerHandle, mixerSelemId);
98 if (mixerElem != nullptr)
99 {
100 //wohoo. good to go...
101 LOG(LogDebug) << "VolumeControl::init() - Mixer initialized";
102 }
103 else
104 {
105 LOG(LogError) << "VolumeControl::init() - Failed to find mixer elements!";
106 snd_mixer_close(mixerHandle);
107 mixerHandle = nullptr;
108 }
109 }
110 else
111 {
112 LOG(LogError) << "VolumeControl::init() - Failed to load mixer elements!";
113 snd_mixer_close(mixerHandle);
114 mixerHandle = nullptr;
115 }
116 }
117 else
118 {
119 LOG(LogError) << "VolumeControl::init() - Failed to register simple element class!";
120 snd_mixer_close(mixerHandle);
121 mixerHandle = nullptr;
122 }
123 }
124 else

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected