mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 23:12:44 +02:00
revert audio_mixer changes
Origin commit data
------------------
Branch: master
Commit: 236c2401f1
Author: martii <m4rtii@gmx.de>
Date: 2013-05-26 (Sun, 26 May 2013)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -43,6 +43,7 @@ libstb_hal_test_LDADD += \
|
|||||||
@SWSCALE_LIBS@
|
@SWSCALE_LIBS@
|
||||||
endif
|
endif
|
||||||
if BOXTYPE_SPARK
|
if BOXTYPE_SPARK
|
||||||
|
libstb_hal_test_LDADD += -lasound
|
||||||
SUBDIRS += libspark libeplayer3
|
SUBDIRS += libspark libeplayer3
|
||||||
libstb_hal_la_LIBADD += \
|
libstb_hal_la_LIBADD += \
|
||||||
libspark/libspark.la \
|
libspark/libspark.la \
|
||||||
|
@@ -5,7 +5,7 @@ INCLUDES = \
|
|||||||
noinst_LTLIBRARIES = libspark.la
|
noinst_LTLIBRARIES = libspark.la
|
||||||
|
|
||||||
AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing
|
AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing
|
||||||
AM_LDFLAGS = -lpthread
|
AM_LDFLAGS = -lpthread -lasound
|
||||||
|
|
||||||
libspark_la_SOURCES = \
|
libspark_la_SOURCES = \
|
||||||
hardware_caps.c \
|
hardware_caps.c \
|
||||||
|
@@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <audio_mixer.h>
|
#include <audio_mixer.h>
|
||||||
#include <dlfcn.h>
|
|
||||||
|
|
||||||
mixerVolume::mixerVolume(const char *name, const char *card, long volume) {
|
mixerVolume::mixerVolume(const char *name, const char *card, long volume) {
|
||||||
sid = NULL;
|
sid = NULL;
|
||||||
@@ -28,24 +27,6 @@ mixerVolume::mixerVolume(const char *name, const char *card, long volume) {
|
|||||||
max = 100;
|
max = 100;
|
||||||
char cardId[10];
|
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)
|
if (!name || !card)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -54,38 +35,36 @@ mixerVolume::mixerVolume(const char *name, const char *card, long volume) {
|
|||||||
return;
|
return;
|
||||||
snprintf(cardId, sizeof(cardId), "hw:%i", cx);
|
snprintf(cardId, sizeof(cardId), "hw:%i", cx);
|
||||||
|
|
||||||
if (0 > this->snd_mixer_open(&handle, 0))
|
if (0 > snd_mixer_open(&handle, 0))
|
||||||
return;
|
return;
|
||||||
if (0 > this->snd_mixer_attach(handle, cardId))
|
if (0 > snd_mixer_attach(handle, cardId))
|
||||||
return;
|
return;
|
||||||
if (0 > this->snd_mixer_selem_register(handle, NULL, NULL))
|
if (0 > snd_mixer_selem_register(handle, NULL, NULL))
|
||||||
return;
|
return;
|
||||||
if (0 > this->snd_mixer_load(handle))
|
if (0 > snd_mixer_load(handle))
|
||||||
return;
|
return;
|
||||||
snd_mixer_selem_id_alloca(&sid);
|
snd_mixer_selem_id_alloca(&sid);
|
||||||
if (!sid)
|
if (!sid)
|
||||||
return;
|
return;
|
||||||
this->snd_mixer_selem_id_set_index(sid, 0);
|
snd_mixer_selem_id_set_index(sid, 0);
|
||||||
this->snd_mixer_selem_id_set_name(sid, name);
|
snd_mixer_selem_id_set_name(sid, name);
|
||||||
elem = this->snd_mixer_find_selem(handle, sid);
|
elem = snd_mixer_find_selem(handle, sid);
|
||||||
if (elem) {
|
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);
|
setVolume(volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mixerVolume::~mixerVolume()
|
mixerVolume::~mixerVolume()
|
||||||
{
|
{
|
||||||
if (handle)
|
if (handle)
|
||||||
this->snd_mixer_close(handle);
|
snd_mixer_close(handle);
|
||||||
if (sid)
|
if (sid)
|
||||||
this->snd_mixer_selem_id_free(sid);
|
snd_mixer_selem_id_free(sid);
|
||||||
if (alsaLib)
|
|
||||||
dlclose(alsaLib);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mixerVolume::setVolume(long volume) {
|
bool mixerVolume::setVolume(long volume) {
|
||||||
return elem
|
return elem
|
||||||
&& (volume > -1)
|
&& (volume > -1)
|
||||||
&& (volume < 101)
|
&& (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);
|
||||||
}
|
}
|
||||||
|
@@ -28,21 +28,6 @@ class mixerVolume
|
|||||||
snd_mixer_t *handle;
|
snd_mixer_t *handle;
|
||||||
snd_mixer_elem_t* elem;
|
snd_mixer_elem_t* elem;
|
||||||
snd_mixer_selem_id_t *sid;
|
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:
|
public:
|
||||||
mixerVolume(const char *selem_name, const char *Card, long volume = -1);
|
mixerVolume(const char *selem_name, const char *Card, long volume = -1);
|
||||||
~mixerVolume(void);
|
~mixerVolume(void);
|
||||||
|
Reference in New Issue
Block a user