Conditionally compile new ALSA sound code

This commit is contained in:
Andrew Bettison 2012-05-10 18:29:27 +09:30
parent 022e3289dd
commit fe25f06129
4 changed files with 48 additions and 19 deletions

View File

@ -70,7 +70,8 @@ LOCAL_SRC_FILES:= \
serval-dna/monitor-cli.c \
serval-dna/codecs.c \
serval-dna/audiodevices.c \
serval-dna/audio_msm_g1.c
serval-dna/audio_msm_g1.c \
serval-dna/audio_alsa.c
LOCAL_MODULE:= serval

View File

@ -43,7 +43,8 @@ SRCS= batman.c \
monitor-cli.c \
codecs.c \
audiodevices.c \
audio_msm_g1.c
audio_msm_g1.c \
audio_alsa.c
HAVE_VOIPTEST= @HAVE_VOIPTEST@
ifeq ($(HAVE_VOIPTEST), 1)

View File

@ -16,13 +16,15 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "serval.h"
#ifdef HAVE_ALSA_ASOUNDLIB_H
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <alsa/asoundlib.h>
#include "serval.h"
#ifndef ANDROID
#define ALSA_LIB_PATH "/lib/libasound.so.2"
#else
@ -241,23 +243,25 @@ int audio_alsa_write(unsigned char *buffer,int bytes)
else return 0;
}
#endif // HAVE_ALSA_ASOUNDLIB_H
monitor_audio *audio_alsa_detect()
{
#ifdef HAVE_ALSA_ASOUNDLIB_H
if (!alsa) alsa_load();
if (!alsa) return NULL;
int r;
snd_pcm_t *handle;
if ((r = alsa->snd_pcm_open (&handle, "default", SND_PCM_STREAM_PLAYBACK, 0)) < 0)
return NULL;
alsa->snd_pcm_close(handle);
monitor_audio *au=calloc(sizeof(monitor_audio),1);
strcpy(au->name,"ALSA compatible");
au->start=audio_alsa_start;
au->stop=audio_alsa_stop;
au->poll_fds=audio_alsa_pollfds;
au->read=audio_alsa_read;
au->write=audio_alsa_write;
return au;
if (alsa->snd_pcm_open (&handle, "default", SND_PCM_STREAM_PLAYBACK, 0) != -1) {
alsa->snd_pcm_close(handle);
monitor_audio *au=calloc(sizeof(monitor_audio),1);
strcpy(au->name,"ALSA compatible");
au->start=audio_alsa_start;
au->stop=audio_alsa_stop;
au->poll_fds=audio_alsa_pollfds;
au->read=audio_alsa_read;
au->write=audio_alsa_write;
return au;
}
#endif // HAVE_ALSA_ASOUNDLIB_H
return NULL;
}

View File

@ -64,7 +64,30 @@ fi
AC_CHECK_LIB(c,srandomdev)
AC_CHECK_HEADERS(stdio.h errno.h stdlib.h strings.h unistd.h string.h arpa/inet.h sys/socket.h sys/mman.h sys/time.h poll.h netdb.h linux/if.h linux/netlink.h linux/rtnetlink.h net/if.h netinet/in.h ifaddrs.h net/route.h signal.h jni.h)
AC_CHECK_HEADERS(
stdio.h \
errno.h \
stdlib.h \
strings.h \
unistd.h \
string.h \
arpa/inet.h \
sys/socket.h \
sys/mman.h \
sys/time.h \
poll.h \
netdb.h \
linux/if.h \
linux/netlink.h \
linux/rtnetlink.h \
net/if.h \
netinet/in.h \
ifaddrs.h \
net/route.h \
signal.h \
jni.h \
alsa/asoundlib.h \
)
echo "Fetching and building NaCl if required."
echo "(this can take HOURS to build depending on your architecture,"