diff --git a/desmume/configure.ac b/desmume/configure.ac
index a8625d0ec..3f56a28f8 100644
--- a/desmume/configure.ac
+++ b/desmume/configure.ac
@@ -89,6 +89,7 @@ fi
dnl - Check for GTK and/or libglade
FOUND_GLIB=no
+HAVE_ALSA=no
GLIB_VER=2.8
GTK_VER=2.6
AC_CHECK_TOOL(HAVE_PKG, pkg-config)
@@ -142,6 +143,10 @@ AC_PROVIDE_IFELSE([PKG_PROG_PKG_CONFIG], [
HAVE_LUA=no)
AC_SUBST(LUA_CFLAGS)
AC_SUBST(LUA_LIBS)
+
+ PKG_CHECK_MODULES(ALSA, alsa >= 1.0, HAVE_ALSA=yes, HAVE_ALSA=no)
+ AC_SUBST(ALSA_CFLAGS)
+ AC_SUBST(ALSA_LIBS)
fi
],[
echo "WARNING: pkg-config is not available therefore gtk, gtk-glade UIs and lua scripting are not available either."
@@ -150,6 +155,11 @@ AC_PROVIDE_IFELSE([PKG_PROG_PKG_CONFIG], [
dnl -- force lua disabled
AM_CONDITIONAL([HAVE_LUA], [test "${HAVE_LUA}x" = "yes"])
+AM_CONDITIONAL([HAVE_ALSA], [test "${HAVE_ALSA}" = "yes"])
+if test "x$HAVE_ALSA" = "xno"; then
+ AC_DEFINE([FAKE_MIC])
+fi
+
dnl - set conditional for glib, needed to avoid commandline.cpp compilation for cli frontend since it depends on glib
AM_CONDITIONAL([HAVE_GLIB], [test "${FOUND_GLIB}" = "yes"])
diff --git a/desmume/src/Makefile.am b/desmume/src/Makefile.am
index 44a593170..4a6124144 100644
--- a/desmume/src/Makefile.am
+++ b/desmume/src/Makefile.am
@@ -55,13 +55,17 @@ libdesmume_a_SOURCES = \
agg/src/agg_trans_affine.cpp agg/src/agg_trans_double_path.cpp agg/src/agg_trans_single_path.cpp agg/src/agg_trans_warp_magnifier.cpp \
agg/src/agg_vcgen_bspline.cpp agg/src/agg_vcgen_contour.cpp agg/src/agg_vcgen_dash.cpp agg/src/agg_vcgen_markers_term.cpp agg/src/agg_vcgen_smooth_poly1.cpp agg/src/agg_vcgen_stroke.cpp \
agg/src/agg_vpgen_clip_polygon.cpp agg/src/agg_vpgen_clip_polyline.cpp agg/src/agg_vpgen_segmentator \
- mic.cpp mic.h \
cheatSystem.cpp cheatSystem.h \
texcache.cpp texcache.h rasterize.cpp rasterize.h \
version.h
if HAVE_GLIB
libdesmume_a_SOURCES += commandline.h commandline.cpp
endif
+if HAVE_ALSA
+libdesmume_a_SOURCES += mic_alsa.cpp
+else
+libdesmume_a_SOURCES += mic.cpp
+endif
if HAVE_LUA
libdesmume_a_SOURCES += lua-engine.cpp
endif
diff --git a/desmume/src/cli/main.cpp b/desmume/src/cli/main.cpp
index f65f2cdd0..837bdb7b6 100644
--- a/desmume/src/cli/main.cpp
+++ b/desmume/src/cli/main.cpp
@@ -684,10 +684,12 @@ static void desmume_cycle(int *sdl_quit, int *boost, struct my_config * my_confi
case SDLK_ESCAPE:
*sdl_quit = 1;
break;
+#ifdef FAKE_MIC
case SDLK_m:
enable_fake_mic = !enable_fake_mic;
Mic_DoNoise(enable_fake_mic);
break;
+#endif
case SDLK_o:
*boost = !(*boost);
break;
diff --git a/desmume/src/gtk/main.cpp b/desmume/src/gtk/main.cpp
index 600feb80e..d3849a870 100644
--- a/desmume/src/gtk/main.cpp
+++ b/desmume/src/gtk/main.cpp
@@ -111,7 +111,9 @@ static void ToggleMenuVisible(GtkToggleAction *action);
static void ToggleStatusbarVisible(GtkToggleAction *action);
static void ToggleToolbarVisible(GtkToggleAction *action);
static void ToggleAudio (GtkToggleAction *action);
+#ifdef FAKE_MIC
static void ToggleMicNoise (GtkToggleAction *action);
+#endif
static void ToggleGap (GtkToggleAction *action);
static void SetRotation (GtkAction *action);
static void ToggleLayerVisibility(GtkToggleAction* action, gpointer data);
@@ -167,7 +169,9 @@ static const char *ui_description =
" "
" "
" "
+#ifdef FAKE_MIC
" "
+#endif
"