@@ -217,40 +217,52 @@ bool LegacyAmixerControl::accessHW(bool receive, std::string &error)
217217
218218 return false ;
219219 }
220- // Go through all indexes
221- for (index = 0 ; index < elementCount; index++) {
222-
223- switch (eType) {
224- case SND_CTL_ELEM_TYPE_BOOLEAN:
225- value = snd_ctl_elem_value_get_boolean (control, index);
226- break ;
227- case SND_CTL_ELEM_TYPE_INTEGER:
228- value = snd_ctl_elem_value_get_integer (control, index);
229- break ;
230- case SND_CTL_ELEM_TYPE_INTEGER64:
231- value = snd_ctl_elem_value_get_integer64 (control, index);
232- break ;
233- case SND_CTL_ELEM_TYPE_ENUMERATED:
234- value = snd_ctl_elem_value_get_enumerated (control, index);
235- break ;
236- case SND_CTL_ELEM_TYPE_BYTES:
237- value = snd_ctl_elem_value_get_byte (control, index);
238- break ;
239- default :
240- error = " ALSA: Unknown control element type while reading alsa element " +
241- controlName;
242- return false ;
243- }
220+
221+ if (eType == SND_CTL_ELEM_TYPE_BYTES) {
222+ const void *data = snd_ctl_elem_value_get_bytes (control);
244223
245224 if (isDebugEnabled ()) {
246225
247- // The "info" method has been shadowed by a local variable
248- this ->info () << " Reading alsa element " << controlName
249- << " , index " << index << " with value " << value;
226+ // The "info" method has been shadowed by a local variable
227+ this ->info () << " Reading alsa element " << controlName;
250228 }
251229
252- // Write data to blackboard (beware this code is OK on Little Endian machines only)
253- toBlackboard (value);
230+ blackboardWrite (data, elementCount);
231+
232+ } else {
233+
234+ // Go through all indexes
235+ for (index = 0 ; index < elementCount; index++) {
236+
237+ switch (eType) {
238+ case SND_CTL_ELEM_TYPE_BOOLEAN:
239+ value = snd_ctl_elem_value_get_boolean (control, index);
240+ break ;
241+ case SND_CTL_ELEM_TYPE_INTEGER:
242+ value = snd_ctl_elem_value_get_integer (control, index);
243+ break ;
244+ case SND_CTL_ELEM_TYPE_INTEGER64:
245+ value = snd_ctl_elem_value_get_integer64 (control, index);
246+ break ;
247+ case SND_CTL_ELEM_TYPE_ENUMERATED:
248+ value = snd_ctl_elem_value_get_enumerated (control, index);
249+ break ;
250+ default :
251+ error = " ALSA: Unknown control element type while reading alsa element " +
252+ controlName;
253+ return false ;
254+ }
255+
256+ if (isDebugEnabled ()) {
257+
258+ // The "info" method has been shadowed by a local variable
259+ this ->info () << " Reading alsa element " << controlName
260+ << " , index " << index << " with value " << value;
261+ }
262+
263+ // Write data to blackboard (beware this code is OK on Little Endian machines only)
264+ toBlackboard (value);
265+ }
254266 }
255267
256268 } else {
@@ -281,39 +293,51 @@ bool LegacyAmixerControl::accessHW(bool receive, std::string &error)
281293 return ret == 0 ;
282294 }
283295
284- // Go through all indexes
285- for (index = 0 ; index < elementCount; index++) {
296+ if (eType == SND_CTL_ELEM_TYPE_BYTES) {
297+ std::vector< unsigned char > rawData (elementCount);
286298
287- // Read data from blackboard (beware this code is OK on Little Endian machines only)
288- value = fromBlackboard ();
299+ blackboardRead (rawData.data (), elementCount);
289300
290301 if (isDebugEnabled ()) {
291302
292- // The "info" method has been shadowed by a local variable
293- this ->info () << " Writing alsa element " << controlName
294- << " , index " << index << " with value " << value;
303+ // The "info" method has been shadowed by a local variable
304+ this ->info () << " Writing alsa element " << controlName;
295305 }
296306
297- switch (eType) {
298- case SND_CTL_ELEM_TYPE_BOOLEAN:
299- snd_ctl_elem_value_set_boolean (control, index, value);
300- break ;
301- case SND_CTL_ELEM_TYPE_INTEGER:
302- snd_ctl_elem_value_set_integer (control, index, value);
303- break ;
304- case SND_CTL_ELEM_TYPE_INTEGER64:
305- snd_ctl_elem_value_set_integer64 (control, index, value);
306- break ;
307- case SND_CTL_ELEM_TYPE_ENUMERATED:
308- snd_ctl_elem_value_set_enumerated (control, index, value);
309- break ;
310- case SND_CTL_ELEM_TYPE_BYTES:
311- snd_ctl_elem_value_set_byte (control, index, value);
312- break ;
313- default :
314- error = " ALSA: Unknown control element type while writing alsa element " +
307+ snd_ctl_elem_set_bytes (control, rawData.data (), elementCount);
308+
309+ } else {
310+ // Go through all indexes
311+ for (index = 0 ; index < elementCount; index++) {
312+
313+ // Read data from blackboard (beware this code is OK on Little Endian machines only)
314+ value = fromBlackboard ();
315+
316+ if (isDebugEnabled ()) {
317+
318+ // The "info" method has been shadowed by a local variable
319+ this ->info () << " Writing alsa element " << controlName
320+ << " , index " << index << " with value " << value;
321+ }
322+
323+ switch (eType) {
324+ case SND_CTL_ELEM_TYPE_BOOLEAN:
325+ snd_ctl_elem_value_set_boolean (control, index, value);
326+ break ;
327+ case SND_CTL_ELEM_TYPE_INTEGER:
328+ snd_ctl_elem_value_set_integer (control, index, value);
329+ break ;
330+ case SND_CTL_ELEM_TYPE_INTEGER64:
331+ snd_ctl_elem_value_set_integer64 (control, index, value);
332+ break ;
333+ case SND_CTL_ELEM_TYPE_ENUMERATED:
334+ snd_ctl_elem_value_set_enumerated (control, index, value);
335+ break ;
336+ default :
337+ error = " ALSA: Unknown control element type while writing alsa element " +
315338 controlName;
316- return false ;
339+ return false ;
340+ }
317341 }
318342 }
319343
0 commit comments