From 9b5a05c9310da17ac89d1e995f35bf470c6612e3 Mon Sep 17 00:00:00 2001 From: martii Date: Sun, 26 May 2013 14:24:31 +0200 Subject: [PATCH] revert audio_mixer changes Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/236c2401f1dd850bcb5c034df05865f3285d97ba Author: martii Date: 2013-05-26 (Sun, 26 May 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- Makefile.am | 1 + libspark/Makefile.am | 2 +- libspark/audio_mixer.cpp | 43 ++++++++++------------------------------ libspark/audio_mixer.h | 15 -------------- 4 files changed, 13 insertions(+), 48 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9a1589b..f6d8f87 100644 --- a/Makefile.am +++ b/Makefile.am @@ -43,6 +43,7 @@ libstb_hal_test_LDADD += \ @SWSCALE_LIBS@ endif if BOXTYPE_SPARK +libstb_hal_test_LDADD += -lasound SUBDIRS += libspark libeplayer3 libstb_hal_la_LIBADD += \ libspark/libspark.la \ diff --git a/libspark/Makefile.am b/libspark/Makefile.am index c41efe4..e4875f7 100644 --- a/libspark/Makefile.am +++ b/libspark/Makefile.am @@ -5,7 +5,7 @@ INCLUDES = \ noinst_LTLIBRARIES = libspark.la AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing -AM_LDFLAGS = -lpthread +AM_LDFLAGS = -lpthread -lasound libspark_la_SOURCES = \ hardware_caps.c \ diff --git a/libspark/audio_mixer.cpp b/libspark/audio_mixer.cpp index d8d67b7..f5a845a 100644 --- a/libspark/audio_mixer.cpp +++ b/libspark/audio_mixer.cpp @@ -18,7 +18,6 @@ */ #include -#include mixerVolume::mixerVolume(const char *name, const char *card, long volume) { sid = NULL; @@ -28,24 +27,6 @@ mixerVolume::mixerVolume(const char *name, const char *card, long volume) { max = 100; char cardId[10]; - alsaLib = dlopen("/lib/libasound.so.2", RTLD_NOW); - if (!alsaLib) - return; - if (!(this->snd_card_get_index = (int (*)(const char *))dlsym(alsaLib, "snd_card_get_index")) - || !(this->snd_mixer_open = (int (*)(snd_mixer_t **, int)) dlsym(alsaLib, "snd_mixer_open")) - || !(this->snd_mixer_attach = (int (*)(snd_mixer_t *, const char *)) dlsym(alsaLib, "snd_mixer_attach")) - || !(this->snd_mixer_selem_register = (int (*)(snd_mixer_t *, struct snd_mixer_selem_regopt *, snd_mixer_class_t **)) dlsym(alsaLib, "snd_mixer_selem_register")) - || !(this->snd_mixer_load = (int (*)(snd_mixer_t *)) dlsym(alsaLib, "snd_mixer_load")) - || !(this->snd_mixer_selem_id_set_index = (void (*)(snd_mixer_selem_id_t *, unsigned int)) dlsym(alsaLib, "snd_mixer_selem_id_set_index")) - || !(this->snd_mixer_selem_id_set_name = (void (*)(snd_mixer_selem_id_t *, const char *)) dlsym(alsaLib, "snd_mixer_selem_id_set_name")) - || !(this->snd_mixer_find_selem = (snd_mixer_elem_t *(*)(snd_mixer_t *, const snd_mixer_selem_id_t *)) dlsym(alsaLib, "snd_mixer_find_selem")) - || !(this->snd_mixer_selem_get_playback_volume_range = (int (*)(snd_mixer_elem_t *, long *, long *)) dlsym(alsaLib, "snd_mixer_selem_get_playback_volume_range")) - || !(this->snd_mixer_close = (int (*)(snd_mixer_t *)) dlsym(alsaLib, "snd_mixer_close")) - || !(this->snd_mixer_selem_id_free = (void (*)(snd_mixer_selem_id_t *)) dlsym(alsaLib, "snd_mixer_selem_id_free")) - || !(this->snd_mixer_selem_id_sizeof = (size_t (*)(void)) dlsym(alsaLib, "snd_mixer_selem_id_sizeof")) - || !(this->snd_mixer_selem_set_playback_volume_all = (int (*)(snd_mixer_elem_t *, long)) dlsym(alsaLib, "snd_mixer_selem_set_playback_volume_all"))) - return; - if (!name || !card) return; @@ -54,38 +35,36 @@ mixerVolume::mixerVolume(const char *name, const char *card, long volume) { return; snprintf(cardId, sizeof(cardId), "hw:%i", cx); - if (0 > this->snd_mixer_open(&handle, 0)) + if (0 > snd_mixer_open(&handle, 0)) return; - if (0 > this->snd_mixer_attach(handle, cardId)) + if (0 > snd_mixer_attach(handle, cardId)) return; - if (0 > this->snd_mixer_selem_register(handle, NULL, NULL)) + if (0 > snd_mixer_selem_register(handle, NULL, NULL)) return; - if (0 > this->snd_mixer_load(handle)) + if (0 > snd_mixer_load(handle)) return; snd_mixer_selem_id_alloca(&sid); if (!sid) return; - this->snd_mixer_selem_id_set_index(sid, 0); - this->snd_mixer_selem_id_set_name(sid, name); - elem = this->snd_mixer_find_selem(handle, sid); + snd_mixer_selem_id_set_index(sid, 0); + snd_mixer_selem_id_set_name(sid, name); + elem = snd_mixer_find_selem(handle, sid); if (elem) { - this->snd_mixer_selem_get_playback_volume_range(elem, &min, &max); + snd_mixer_selem_get_playback_volume_range(elem, &min, &max); setVolume(volume); } } mixerVolume::~mixerVolume() { if (handle) - this->snd_mixer_close(handle); + snd_mixer_close(handle); if (sid) - this->snd_mixer_selem_id_free(sid); - if (alsaLib) - dlclose(alsaLib); + snd_mixer_selem_id_free(sid); } bool mixerVolume::setVolume(long volume) { return elem && (volume > -1) && (volume < 101) - && !this->snd_mixer_selem_set_playback_volume_all(elem, min + volume * (max - min)/100); + && !snd_mixer_selem_set_playback_volume_all(elem, min + volume * (max - min)/100); } diff --git a/libspark/audio_mixer.h b/libspark/audio_mixer.h index 0ae037f..e716836 100644 --- a/libspark/audio_mixer.h +++ b/libspark/audio_mixer.h @@ -28,21 +28,6 @@ class mixerVolume snd_mixer_t *handle; snd_mixer_elem_t* elem; snd_mixer_selem_id_t *sid; - - void *alsaLib; - int (*snd_card_get_index)(const char *name); - int (*snd_mixer_open)(snd_mixer_t **mixer, int mode); - int (*snd_mixer_attach)(snd_mixer_t *mixer, const char *name); - int (*snd_mixer_selem_register)(snd_mixer_t *mixer, struct snd_mixer_selem_regopt *options, snd_mixer_class_t **classp); - int (*snd_mixer_load)(snd_mixer_t *mixer); - void (*snd_mixer_selem_id_set_index)(snd_mixer_selem_id_t *obj, unsigned int val); - void (*snd_mixer_selem_id_set_name)(snd_mixer_selem_id_t *obj, const char *val); - snd_mixer_elem_t *(*snd_mixer_find_selem)(snd_mixer_t *mixer, const snd_mixer_selem_id_t *id); - int (*snd_mixer_selem_get_playback_volume_range)(snd_mixer_elem_t *elem, long *min, long *max); - int (*snd_mixer_close)(snd_mixer_t *mixer); - void (*snd_mixer_selem_id_free)(snd_mixer_selem_id_t *obj); - int (*snd_mixer_selem_set_playback_volume_all)(snd_mixer_elem_t *elem, long value); - size_t (*snd_mixer_selem_id_sizeof)(void); public: mixerVolume(const char *selem_name, const char *Card, long volume = -1); ~mixerVolume(void);