hardware/libaudio
Revision | 2bd5215c57c0f6ccba8af36d050618f52153e3b3 (tree) |
---|---|
Time | 2016-08-05 18:22:44 |
Author | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
audio_route: avoid an unnecessary error
The change tries to remove the error message:
07-27 16:25:15.129 1249 1249 E audio_hw_primary: Unable to open the mixer, aborting.
However, audio_route still doesn't work properly unless
we put an appropriate mixer_paths.xml.
@@ -26,13 +26,14 @@ | ||
26 | 26 | |
27 | 27 | #include <cutils/log.h> |
28 | 28 | |
29 | +#include <sound/asound.h> | |
29 | 30 | #include <tinyalsa/asoundlib.h> |
30 | 31 | |
31 | 32 | #define BUF_SIZE 1024 |
32 | 33 | #define MIXER_XML_PATH "/system/etc/mixer_paths.xml" |
33 | 34 | #define INITIAL_MIXER_PATH_SIZE 8 |
34 | 35 | |
35 | -#define MIXER_CARD 1 | |
36 | +struct snd_pcm_info *select_card(unsigned int device __unused, unsigned int flags); | |
36 | 37 | |
37 | 38 | struct mixer_state { |
38 | 39 | struct mixer_ctl *ctl; |
@@ -456,7 +457,12 @@ struct audio_route *audio_route_init(void) | ||
456 | 457 | if (!ar) |
457 | 458 | goto err_calloc; |
458 | 459 | |
459 | - ar->mixer = mixer_open(MIXER_CARD); | |
460 | + struct snd_pcm_info *info = select_card(0, PCM_OUT); | |
461 | + if (!info) { | |
462 | + ALOGW("Unable to find the mixer"); | |
463 | + goto err_mixer_open; | |
464 | + } | |
465 | + ar->mixer = mixer_open(info->card); | |
460 | 466 | if (!ar->mixer) { |
461 | 467 | ALOGE("Unable to open the mixer, aborting."); |
462 | 468 | goto err_mixer_open; |