File alsa-lib-hg-fixes.diff of Package alsa

diff -r b1dfac5a4d55 configure.in
--- a/configure.in	Tue Feb 05 10:08:09 2008 +0100
+++ b/configure.in	Fri Mar 14 14:12:33 2008 +0100
@@ -575,8 +575,8 @@ if test ! -L "$srcdir"/include/alsa ; th
   ln -sf . "$srcdir"/include/alsa
 fi
 
-AC_OUTPUT(Makefile doc/Makefile doc/pictures/Makefile include/Makefile
-	  include/sound/Makefile src/Versions src/Makefile \
+AC_OUTPUT(Makefile doc/Makefile doc/pictures/Makefile doc/doxygen.cfg \
+	  include/Makefile include/sound/Makefile src/Versions src/Makefile \
           src/control/Makefile src/mixer/Makefile \
 	  src/pcm/Makefile src/pcm/scopes/Makefile \
 	  src/rawmidi/Makefile src/timer/Makefile \
diff -r b1dfac5a4d55 doc/Makefile.am
--- a/doc/Makefile.am	Tue Feb 05 10:08:09 2008 +0100
+++ b/doc/Makefile.am	Fri Mar 14 14:12:33 2008 +0100
@@ -5,6 +5,7 @@ INCLUDES=-I$(top_srcdir)/include
 INCLUDES=-I$(top_srcdir)/include
 
 doc:
+	test -e doxygen.cfg || sed s:@top_srcdir@:..:g doxygen.cfg.in > doxygen.cfg
 	doxygen doxygen.cfg
 
 doc-pack: doc
diff -r b1dfac5a4d55 doc/doxygen.cfg
--- a/doc/doxygen.cfg	Tue Feb 05 10:08:09 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,119 +0,0 @@
-PROJECT_NAME     = "ALSA project - the C library reference"
-OUTPUT_DIRECTORY = doxygen
-GENERATE_LATEX   = NO
-GENERATE_MAN     = NO
-GENERATE_RTF	 = NO
-
-CASE_SENSE_NAMES = NO
-INPUT            = index.doxygen \
-		   ../include/asoundlib.h \
-		   ../include/version.h \
-		   ../include/global.h \
-		   ../include/asoundef.h \
-		   ../include/input.h \
-		   ../include/output.h \
-		   ../include/error.h \
-		   ../include/conf.h \
-		   ../include/control.h \
-		   ../include/pcm.h \
-		   ../include/rawmidi.h \
-		   ../include/timer.h \
-		   ../include/hwdep.h \
-		   ../include/seq.h \
-		   ../include/seq_event.h \
-		   ../include/seqmid.h \
-		   ../include/seq_midi_event.h \
-		   ../include/pcm_external.h \
-		   ../include/pcm_extplug.h \
-		   ../include/pcm_ioplug.h \
-		   ../include/control_external.h \
-		   ../include/mixer.h \
-		   ../src/error.c \
-		   ../src/dlmisc.c \
-		   ../src/async.c \
-		   ../src/input.c \
-		   ../src/output.c \
-		   ../src/conf.c \
-		   ../src/confmisc.c \
-		   ../src/names.c \
-		   ../src/shmarea.c \
-		   ../src/userfile.c \
-		   ../src/control \
-		   ../src/mixer \
-		   ../src/pcm/pcm.c \
-		   ../src/pcm/pcm_mmap.c \
-                   ../src/pcm/pcm_plugin.c \
-		   ../src/pcm/pcm_hw.c \
-		   ../src/pcm/pcm_mmap_emul.c \
-		   ../src/pcm/pcm_shm.c \
-		   ../src/pcm/pcm_null.c \
-		   ../src/pcm/pcm_copy.c \
-		   ../src/pcm/pcm_linear.c \
-		   ../src/pcm/pcm_lfloat.c \
-		   ../src/pcm/pcm_mulaw.c \
-		   ../src/pcm/pcm_alaw.c \
-		   ../src/pcm/pcm_adpcm.c \
-		   ../src/pcm/pcm_route.c \
-		   ../src/pcm/pcm_rate.c \
-		   ../src/pcm/pcm_plug.c \
-		   ../src/pcm/pcm_file.c \
-		   ../src/pcm/pcm_multi.c \
-		   ../src/pcm/pcm_share.c \
-		   ../src/pcm/pcm_hooks.c \
-		   ../src/pcm/pcm_dmix.c \
-		   ../src/pcm/pcm_dshare.c \
-		   ../src/pcm/pcm_dsnoop.c \
-		   ../src/pcm/pcm_meter.c \
-		   ../src/pcm/pcm_ladspa.c \
-		   ../src/pcm/pcm_asym.c \
-		   ../src/pcm/pcm_iec958.c \
-		   ../src/pcm/pcm_softvol.c \
-		   ../src/pcm/pcm_extplug.c \
-		   ../src/pcm/pcm_ioplug.c \
-		   ../src/pcm/pcm_empty.c \
-		   ../src/pcm/pcm_misc.c \
-		   ../src/pcm/pcm_simple.c \
-		   ../src/rawmidi \
-		   ../src/timer \
-		   ../src/hwdep \
-		   ../src/seq
-EXCLUDE		 = ../src/control/control_local.h \
-		   ../src/pcm/atomic.h \
-		   ../src/pcm/interval.h \
-		   ../src/pcm/interval_inline.h \
-		   ../src/pcm/mask.h \
-		   ../src/pcm/mask_inline.h \
-		   ../src/pcm/pcm_local.h \
-		   ../src/pcm/pcm_meter.h \
-		   ../src/pcm/pcm_plugin.h \
-		   ../src/pcm/plugin_ops.h \
-		   ../src/pcm/ladspa.h \
-		   ../src/hwdep/hwdep_local.h \
-		   ../src/mixer/mixer_local.h \
-		   ../src/rawmidi/rawmidi_local.h \
-		   ../src/seq/seq_local.h
-RECURSIVE	 = YES
-FILE_PATTERNS    = *.c *.h
-EXAMPLE_PATH     = ../test
-IMAGE_PATH	 = pictures
-QUIET            = YES
-
-EXTRACT_ALL	 = NO
-EXTRACT_STATIC	 = NO
-SHOW_INCLUDE_FILES = NO
-JAVADOC_AUTOBRIEF = NO
-INHERIT_DOCS	 = YES
-ENABLED_SECTIONS = ""
-MACRO_EXPANSION  = YES
-EXPAND_ONLY_PREDEF = YES
-PREDEFINED	 = DOXYGEN PIC "DOC_HIDDEN" \
-		   "ATTRIBUTE_UNUSED=" \
-		   ALSA_PCM_NEW_HW_PARAMS_API \
-		   _POSIX_C_SOURCE \
-		   "use_default_symbol_version(x,y,z)=" \
-		   "link_warning(x,y)="
-
-OPTIMIZE_OUTPUT_FOR_C = YES	# doxygen 1.2.6 option
-
-#INPUT_FILTER	 = inputfilter
-#FILTER_SOURCE_FILES = YES
diff -r b1dfac5a4d55 doc/doxygen.cfg.in
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/doxygen.cfg.in	Fri Mar 14 14:12:33 2008 +0100
@@ -0,0 +1,119 @@
+PROJECT_NAME     = "ALSA project - the C library reference"
+OUTPUT_DIRECTORY = doxygen
+GENERATE_LATEX   = NO
+GENERATE_MAN     = NO
+GENERATE_RTF	 = NO
+
+CASE_SENSE_NAMES = NO
+INPUT            = @top_srcdir@/doc/index.doxygen \
+		   @top_srcdir@/include/asoundlib.h \
+		   @top_srcdir@/include/version.h \
+		   @top_srcdir@/include/global.h \
+		   @top_srcdir@/include/asoundef.h \
+		   @top_srcdir@/include/input.h \
+		   @top_srcdir@/include/output.h \
+		   @top_srcdir@/include/error.h \
+		   @top_srcdir@/include/conf.h \
+		   @top_srcdir@/include/control.h \
+		   @top_srcdir@/include/pcm.h \
+		   @top_srcdir@/include/rawmidi.h \
+		   @top_srcdir@/include/timer.h \
+		   @top_srcdir@/include/hwdep.h \
+		   @top_srcdir@/include/seq.h \
+		   @top_srcdir@/include/seq_event.h \
+		   @top_srcdir@/include/seqmid.h \
+		   @top_srcdir@/include/seq_midi_event.h \
+		   @top_srcdir@/include/pcm_external.h \
+		   @top_srcdir@/include/pcm_extplug.h \
+		   @top_srcdir@/include/pcm_ioplug.h \
+		   @top_srcdir@/include/control_external.h \
+		   @top_srcdir@/include/mixer.h \
+		   @top_srcdir@/src/error.c \
+		   @top_srcdir@/src/dlmisc.c \
+		   @top_srcdir@/src/async.c \
+		   @top_srcdir@/src/input.c \
+		   @top_srcdir@/src/output.c \
+		   @top_srcdir@/src/conf.c \
+		   @top_srcdir@/src/confmisc.c \
+		   @top_srcdir@/src/names.c \
+		   @top_srcdir@/src/shmarea.c \
+		   @top_srcdir@/src/userfile.c \
+		   @top_srcdir@/src/control \
+		   @top_srcdir@/src/mixer \
+		   @top_srcdir@/src/pcm/pcm.c \
+		   @top_srcdir@/src/pcm/pcm_mmap.c \
+		   @top_srcdir@/src/pcm/pcm_plugin.c \
+		   @top_srcdir@/src/pcm/pcm_hw.c \
+		   @top_srcdir@/src/pcm/pcm_mmap_emul.c \
+		   @top_srcdir@/src/pcm/pcm_shm.c \
+		   @top_srcdir@/src/pcm/pcm_null.c \
+		   @top_srcdir@/src/pcm/pcm_copy.c \
+		   @top_srcdir@/src/pcm/pcm_linear.c \
+		   @top_srcdir@/src/pcm/pcm_lfloat.c \
+		   @top_srcdir@/src/pcm/pcm_mulaw.c \
+		   @top_srcdir@/src/pcm/pcm_alaw.c \
+		   @top_srcdir@/src/pcm/pcm_adpcm.c \
+		   @top_srcdir@/src/pcm/pcm_route.c \
+		   @top_srcdir@/src/pcm/pcm_rate.c \
+		   @top_srcdir@/src/pcm/pcm_plug.c \
+		   @top_srcdir@/src/pcm/pcm_file.c \
+		   @top_srcdir@/src/pcm/pcm_multi.c \
+		   @top_srcdir@/src/pcm/pcm_share.c \
+		   @top_srcdir@/src/pcm/pcm_hooks.c \
+		   @top_srcdir@/src/pcm/pcm_dmix.c \
+		   @top_srcdir@/src/pcm/pcm_dshare.c \
+		   @top_srcdir@/src/pcm/pcm_dsnoop.c \
+		   @top_srcdir@/src/pcm/pcm_meter.c \
+		   @top_srcdir@/src/pcm/pcm_ladspa.c \
+		   @top_srcdir@/src/pcm/pcm_asym.c \
+		   @top_srcdir@/src/pcm/pcm_iec958.c \
+		   @top_srcdir@/src/pcm/pcm_softvol.c \
+		   @top_srcdir@/src/pcm/pcm_extplug.c \
+		   @top_srcdir@/src/pcm/pcm_ioplug.c \
+		   @top_srcdir@/src/pcm/pcm_empty.c \
+		   @top_srcdir@/src/pcm/pcm_misc.c \
+		   @top_srcdir@/src/pcm/pcm_simple.c \
+		   @top_srcdir@/src/rawmidi \
+		   @top_srcdir@/src/timer \
+		   @top_srcdir@/src/hwdep \
+		   @top_srcdir@/src/seq
+EXCLUDE		 = @top_srcdir@/src/control/control_local.h \
+		   @top_srcdir@/src/pcm/atomic.h \
+		   @top_srcdir@/src/pcm/interval.h \
+		   @top_srcdir@/src/pcm/interval_inline.h \
+		   @top_srcdir@/src/pcm/mask.h \
+		   @top_srcdir@/src/pcm/mask_inline.h \
+		   @top_srcdir@/src/pcm/pcm_local.h \
+		   @top_srcdir@/src/pcm/pcm_meter.h \
+		   @top_srcdir@/src/pcm/pcm_plugin.h \
+		   @top_srcdir@/src/pcm/plugin_ops.h \
+		   @top_srcdir@/src/pcm/ladspa.h \
+		   @top_srcdir@/src/hwdep/hwdep_local.h \
+		   @top_srcdir@/src/mixer/mixer_local.h \
+		   @top_srcdir@/src/rawmidi/rawmidi_local.h \
+		   @top_srcdir@/src/seq/seq_local.h
+RECURSIVE	 = YES
+FILE_PATTERNS    = *.c *.h
+EXAMPLE_PATH     = @top_srcdir@/test
+IMAGE_PATH	 = pictures
+QUIET            = YES
+
+EXTRACT_ALL	 = NO
+EXTRACT_STATIC	 = NO
+SHOW_INCLUDE_FILES = NO
+JAVADOC_AUTOBRIEF = NO
+INHERIT_DOCS	 = YES
+ENABLED_SECTIONS = ""
+MACRO_EXPANSION  = YES
+EXPAND_ONLY_PREDEF = YES
+PREDEFINED	 = DOXYGEN PIC "DOC_HIDDEN" \
+		   "ATTRIBUTE_UNUSED=" \
+		   ALSA_PCM_NEW_HW_PARAMS_API \
+		   _POSIX_C_SOURCE \
+		   "use_default_symbol_version(x,y,z)=" \
+		   "link_warning(x,y)="
+
+OPTIMIZE_OUTPUT_FOR_C = YES	# doxygen 1.2.6 option
+
+#INPUT_FILTER	 = inputfilter
+#FILTER_SOURCE_FILES = YES
diff -r b1dfac5a4d55 include/asoundef.h
--- a/include/asoundef.h	Tue Feb 05 10:08:09 2008 +0100
+++ b/include/asoundef.h	Fri Mar 14 14:12:33 2008 +0100
@@ -121,6 +121,14 @@ extern "C" {
 #define IEC958_AES3_CON_CLOCK_1000PPM	(0<<4)	/**< 1000 ppm */
 #define IEC958_AES3_CON_CLOCK_50PPM	(1<<4)	/**< 50 ppm */
 #define IEC958_AES3_CON_CLOCK_VARIABLE	(2<<4)	/**< variable pitch */
+#define IEC958_AES4_CON_MAX_WORDLEN_24	(1<<0)	/**< 0 = 20-bit, 1 = 24-bit */
+#define IEC958_AES4_CON_WORDLEN		(7<<1)	/**< mask - sample word length */
+#define IEC958_AES4_CON_WORDLEN_NOTID	(0<<1)	/**< not indicated */
+#define IEC958_AES4_CON_WORDLEN_20_16	(1<<1)	/**< 20-bit or 16-bit */
+#define IEC958_AES4_CON_WORDLEN_22_18	(2<<1)	/**< 22-bit or 18-bit */
+#define IEC958_AES4_CON_WORDLEN_23_19	(4<<1)	/**< 23-bit or 19-bit */
+#define IEC958_AES4_CON_WORDLEN_24_20	(5<<1)	/**< 24-bit or 20-bit */
+#define IEC958_AES4_CON_WORDLEN_21_17	(6<<1)	/**< 21-bit or 17-bit */
 
 /** \} */
 
diff -r b1dfac5a4d55 include/iatomic.h
--- a/include/iatomic.h	Tue Feb 05 10:08:09 2008 +0100
+++ b/include/iatomic.h	Fri Mar 14 14:12:33 2008 +0100
@@ -1010,6 +1010,75 @@ static __inline__ void atomic_clear_mask
 
 #endif /* __arm__ */
 
+#ifdef __sh__
+
+typedef struct { volatile int counter; } atomic_t;
+
+#define ATOMIC_INIT(i)	{ (i) }
+
+#define atomic_read(v)			((v)->counter)
+#define atomic_set(v,i)			(((v)->counter) = (i))
+
+#define atomic_dec_return(v)		atomic_sub_return(1,(v))
+#define atomic_inc_return(v)		atomic_add_return(1,(v))
+
+#define atomic_sub_and_test(i,v)	(atomic_sub_return((i), (v)) == 0)
+#define atomic_dec_and_test(v)		(atomic_sub_return(1, (v)) == 0)
+#define atomic_inc_and_test(v)		(atomic_add_return(1, (v)) != 0)
+
+#define atomic_add(i,v)			atomic_add_return((i),(v))
+#define atomic_sub(i,v)			atomic_sub_return((i),(v))
+#define atomic_inc(v)			atomic_add(1,(v))
+#define atomic_dec(v)			atomic_sub(1,(v))
+
+static __inline__ int atomic_add_return(int i, volatile atomic_t *v)
+{
+	int result;
+
+	asm volatile (
+	"	.align	2\n"
+	"	mova	99f, r0\n"
+	"	mov	r15, r1\n"
+	"	mov	#-6, r15\n"
+	"	mov.l	@%2, %0\n"
+	"	add	%1, %0\n"
+	"	mov.l	%0, @%2\n"
+	"99:	mov	r1, r15"
+	: "=&r"(result)
+	: "r"(i), "r"(v)
+	: "r0", "r1");
+
+	return result;
+}
+
+static __inline__ int atomic_sub_return(int i, volatile atomic_t *v)
+{
+	int result;
+
+	asm volatile (
+	"	.align	2\n"
+	"	mova	99f, r0\n"
+	"	mov	r15, r1\n"
+	"	mov	#-6, r15\n"
+	"	mov.l	@%2, %0\n"
+	"	sub	%1, %0\n"
+	"	mov.l	%0, @%2\n"
+	"99:	mov	r1, r15"
+	: "=&r"(result)
+	: "r"(i), "r"(v)
+	: "r0", "r1");
+
+	return result;
+}
+
+#define mb() __asm__ __volatile__ ("" : : : "memory")
+#define rmb() mb()
+#define wmb() mb()
+
+#define IATOMIC_DEFINED		1
+
+#endif /* __sh__ */
+
 #ifndef IATOMIC_DEFINED
 /*
  * non supported architecture.
diff -r b1dfac5a4d55 include/pcm.h
--- a/include/pcm.h	Tue Feb 05 10:08:09 2008 +0100
+++ b/include/pcm.h	Fri Mar 14 14:12:33 2008 +0100
@@ -1105,6 +1105,8 @@ int snd_pcm_sw_params_get_xfer_align(con
 int snd_pcm_sw_params_get_xfer_align(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val) __attribute__((deprecated));
 int snd_pcm_sw_params_set_sleep_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, unsigned int val) __attribute__((deprecated));
 int snd_pcm_sw_params_get_sleep_min(const snd_pcm_sw_params_t *params, unsigned int *val) __attribute__((deprecated));
+#endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_SW_PARAMS_API */
+#if !defined(ALSA_LIBRARY_BUILD) && !defined(ALSA_PCM_OLD_HW_PARAMS_API)
 int snd_pcm_hw_params_get_tick_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
 int snd_pcm_hw_params_get_tick_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
 int snd_pcm_hw_params_get_tick_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
@@ -1116,7 +1118,7 @@ int snd_pcm_hw_params_set_tick_time_near
 int snd_pcm_hw_params_set_tick_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
 int snd_pcm_hw_params_set_tick_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
 int snd_pcm_hw_params_set_tick_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) __attribute__((deprecated));
-#endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_SW_PARAMS_API */
+#endif /* !ALSA_LIBRARY_BUILD && !ALSA_PCM_OLD_HW_PARAMS_API */
 
 /** \} */
 
diff -r b1dfac5a4d55 include/seq.h
--- a/include/seq.h	Tue Feb 05 10:08:09 2008 +0100
+++ b/include/seq.h	Fri Mar 14 14:12:33 2008 +0100
@@ -152,6 +152,11 @@ void snd_seq_client_info_set_broadcast_f
 void snd_seq_client_info_set_broadcast_filter(snd_seq_client_info_t *info, int val);
 void snd_seq_client_info_set_error_bounce(snd_seq_client_info_t *info, int val);
 void snd_seq_client_info_set_event_filter(snd_seq_client_info_t *info, unsigned char *filter);
+
+void snd_seq_client_info_event_filter_clear(snd_seq_client_info_t *info);
+void snd_seq_client_info_event_filter_add(snd_seq_client_info_t *info, int event_type);
+void snd_seq_client_info_event_filter_del(snd_seq_client_info_t *info, int event_type);
+int snd_seq_client_info_event_filter_check(snd_seq_client_info_t *info, int event_type);
 
 int snd_seq_get_client_info(snd_seq_t *handle, snd_seq_client_info_t *info);
 int snd_seq_get_any_client_info(snd_seq_t *handle, int client, snd_seq_client_info_t *info);
@@ -575,6 +580,7 @@ int snd_seq_remove_events(snd_seq_t *han
  */
 
 void snd_seq_set_bit(int nr, void *array);
+void snd_seq_unset_bit(int nr, void *array);
 int snd_seq_change_bit(int nr, void *array);
 int snd_seq_get_bit(int nr, void *array);
 
diff -r b1dfac5a4d55 include/sound/asound.h
--- a/include/sound/asound.h	Tue Feb 05 10:08:09 2008 +0100
+++ b/include/sound/asound.h	Fri Mar 14 14:12:33 2008 +0100
@@ -59,6 +59,7 @@
 #ifndef __KERNEL__
 #include <sys/time.h>
 #include <sys/types.h>
+#include <sys/ioctl.h>
 #endif
 
 /*
diff -r b1dfac5a4d55 modules/mixer/simple/Makefile.am
--- a/modules/mixer/simple/Makefile.am	Tue Feb 05 10:08:09 2008 +0100
+++ b/modules/mixer/simple/Makefile.am	Fri Mar 14 14:12:33 2008 +0100
@@ -1,4 +1,5 @@ pkglibdir = @ALSA_PLUGIN_DIR@/smixer
-pkglibdir = @ALSA_PLUGIN_DIR@/smixer
+alsaplugindir = @ALSA_PLUGIN_DIR@
+pkglibdir = $(alsaplugindir)/smixer
 pythonlibs = @PYTHON_LIBS@
 pythonincludes = @PYTHON_INCLUDES@
 
diff -r b1dfac5a4d55 src/conf/Makefile.am
--- a/src/conf/Makefile.am	Tue Feb 05 10:08:09 2008 +0100
+++ b/src/conf/Makefile.am	Fri Mar 14 14:12:33 2008 +0100
@@ -10,5 +10,6 @@ endif
 
 EXTRA_DIST = $(cfg_files)
 
-alsadir = @ALSA_CONFIG_DIR@
+alsaconfigdir = @ALSA_CONFIG_DIR@
+alsadir = $(alsaconfigdir)
 alsa_DATA = $(cfg_files)
diff -r b1dfac5a4d55 src/conf/alsa.conf
--- a/src/conf/alsa.conf	Tue Feb 05 10:08:09 2008 +0100
+++ b/src/conf/alsa.conf	Fri Mar 14 14:12:33 2008 +0100
@@ -95,6 +95,8 @@ defaults.pcm.iec958.device defaults.pcm.
 defaults.pcm.iec958.device defaults.pcm.device
 defaults.pcm.modem.card defaults.pcm.card
 defaults.pcm.modem.device defaults.pcm.device
+# truncate files via file or tee PCM
+defaults.pcm.file_truncate	true
 defaults.rawmidi.card 0
 defaults.rawmidi.device 0
 defaults.rawmidi.subdevice -1
@@ -125,6 +127,7 @@ pcm.surround71 cards.pcm.surround71
 pcm.surround71 cards.pcm.surround71
 pcm.iec958 cards.pcm.iec958
 pcm.spdif iec958
+pcm.hdmi cards.pcm.hdmi
 pcm.dmix cards.pcm.dmix
 pcm.dsnoop cards.pcm.dsnoop
 pcm.modem cards.pcm.modem
@@ -269,6 +272,10 @@ pcm.tee {
 	slave.pcm $SLAVE
 	file $FILE
 	format $FORMAT
+	truncate {
+		@func refer
+		name defaults.pcm.file_truncate
+	}
 }
 
 pcm.file {
@@ -284,6 +291,10 @@ pcm.file {
 	slave.pcm null
 	file $FILE
 	format $FORMAT
+	truncate {
+		@func refer
+		name defaults.pcm.file_truncate
+	}
 }
 
 pcm.null {
diff -r b1dfac5a4d55 src/conf/cards/HDA-Intel.conf
--- a/src/conf/cards/HDA-Intel.conf	Tue Feb 05 10:08:09 2008 +0100
+++ b/src/conf/cards/HDA-Intel.conf	Fri Mar 14 14:12:33 2008 +0100
@@ -137,6 +137,51 @@ HDA-Intel.pcm.iec958.0 {
 	hint.device 1
 }
 
+<confdir:pcm/hdmi.conf>
+
+HDA-Intel.pcm.hdmi.0 {
+	@args [ CARD AES0 AES1 AES2 AES3 ]
+	@args.CARD {
+		type string
+	}
+	@args.AES0 {
+		type integer
+	}
+	@args.AES1 {
+		type integer
+	}
+	@args.AES2 {
+		type integer
+	}
+	@args.AES3 {
+		type integer
+	}
+	type hooks
+	slave.pcm {
+		type hw
+		card $CARD
+		device 3
+	}
+	hooks.0 {
+		type ctl_elems
+		hook_args [
+		{
+			name "IEC958 Playback Default"
+			lock true
+			preserve true
+			value [ $AES0 $AES1 $AES2 $AES3 ]
+		}
+		{
+			name "IEC958 Playback Switch"
+			lock true
+			preserve true
+			value true
+		}
+		]
+	}
+	hint.device 3
+}
+
 <confdir:pcm/modem.conf>
 
 HDA-Intel.pcm.modem.0 {
diff -r b1dfac5a4d55 src/conf/cards/Makefile.am
--- a/src/conf/cards/Makefile.am	Tue Feb 05 10:08:09 2008 +0100
+++ b/src/conf/cards/Makefile.am	Fri Mar 14 14:12:33 2008 +0100
@@ -1,4 +1,5 @@ alsadir = @ALSA_CONFIG_DIR@/cards
-alsadir = @ALSA_CONFIG_DIR@/cards
+alsaconfigdir = @ALSA_CONFIG_DIR@
+alsadir = $(alsaconfigdir)/cards
 cfg_files = aliases.conf \
 	AACI.conf \
 	ATIIXP.conf \
@@ -58,7 +59,7 @@ alsa_DATA = $(cfg_files)
 alsa_DATA = $(cfg_files)
 
 if BUILD_ALISP
-SI7018dir = @ALSA_CONFIG_DIR@/cards/SI7018
+SI7018dir = $(alsaconfigdir)/cards/SI7018
 SI7018_files = \
 	SI7018/sndoc-mixer.alisp \
 	SI7018/sndop-mixer.alisp
diff -r b1dfac5a4d55 src/conf/cards/NFORCE.conf
--- a/src/conf/cards/NFORCE.conf	Tue Feb 05 10:08:09 2008 +0100
+++ b/src/conf/cards/NFORCE.conf	Fri Mar 14 14:12:33 2008 +0100
@@ -171,6 +171,79 @@ NFORCE.pcm.surround51.0 {
 	}
 }
 
+<confdir:pcm/surround71.conf>
+
+NFORCE.pcm.surround71.0 {
+    @args [ CARD ]
+    @args.CARD {
+        type string
+    }
+    type softvol
+    slave.pcm {
+        type route
+        ttable.0.0 1
+        ttable.1.1 1
+        ttable.2.4 1
+        ttable.3.5 1
+        ttable.4.2 1
+        ttable.5.3 1
+        ttable.6.6 1
+        ttable.7.7 1
+        slave.pcm {
+            type hooks
+            slave.pcm {
+                type hw
+                card $CARD
+                device 0
+            }
+            hooks.0 {
+                type ctl_elems
+                hook_args [
+                {
+                    name "Channel Mode"
+                    preserve true
+                    value "8ch"
+                    lock true
+                    optional true
+                }
+                # for old drivers
+                {
+                    name "Line-In As Surround"
+                    preserve true
+                    value true
+                    optional true
+                }
+                {
+                    name "Mic As Center/LFE"
+                    preserve true
+                    value true
+                    optional true
+                }
+                {
+                    name "Surround Down Mix"
+                    preserve true
+                    value off
+                    lock true
+                    optional true
+                }
+                {
+                    name "Center/LFE Down Mix"
+                    preserve true
+                    value off
+                    lock true
+                    optional true
+                }
+                ]
+            }
+        }
+        slave.channels 8
+    }
+    control {
+        name "PCM Playback Volume"
+        card $CARD
+    }
+}
+
 <confdir:pcm/iec958.conf>
 
 NFORCE.pcm.iec958.0 {
diff -r b1dfac5a4d55 src/conf/pcm/Makefile.am
--- a/src/conf/pcm/Makefile.am	Tue Feb 05 10:08:09 2008 +0100
+++ b/src/conf/pcm/Makefile.am	Fri Mar 14 14:12:33 2008 +0100
@@ -1,11 +1,12 @@ cfg_files = default.conf front.conf rear
 cfg_files = default.conf front.conf rear.conf center_lfe.conf side.conf\
 	    surround40.conf surround41.conf \
 	    surround50.conf surround51.conf \
-	    surround71.conf iec958.conf modem.conf \
+	    surround71.conf iec958.conf hdmi.conf modem.conf \
 	    dmix.conf dsnoop.conf \
 	    dpl.conf
 
 EXTRA_DIST = $(cfg_files)
 
-alsadir = @ALSA_CONFIG_DIR@/pcm
+alsaconfigdir = @ALSA_CONFIG_DIR@
+alsadir = $(alsaconfigdir)/pcm
 alsa_DATA = $(cfg_files)
diff -r b1dfac5a4d55 src/conf/pcm/hdmi.conf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/conf/pcm/hdmi.conf	Fri Mar 14 14:12:33 2008 +0100
@@ -0,0 +1,83 @@
+#
+#  Hardware output from HDMI
+#
+
+pcm.!hdmi {
+	@args [ CARD DEV AES0 AES1 AES2 AES3 ]
+	@args.CARD {
+		type string
+		default {
+			@func getenv
+			vars [
+				ALSA_IEC958_CARD
+				ALSA_PCM_CARD
+				ALSA_CARD
+			]
+			default {
+				@func refer
+				name defaults.pcm.iec958.card
+			}
+		}
+	}
+	@args.DEV {
+		type integer
+		default {
+			@func igetenv
+			vars [
+				ALSA_IEC958_DEVICE
+			]
+			default {
+				@func refer
+				name defaults.pcm.iec958.device
+			}
+		}
+	}
+	@args.AES0 {
+		type integer
+		# consumer, not-copyright, emphasis-none, mode=0
+		default 0x04
+	}
+	@args.AES1 {
+		type integer
+		# original, PCM coder
+		default 0x82
+	}
+	@args.AES2 {
+		type integer
+		# source and channel
+		default 0x00
+	}
+	@args.AES3 {
+		type integer
+		# fs=48000Hz, clock accuracy=1000ppm
+		default 0x02
+	}
+	type empty
+	slave.pcm {
+		@func refer
+		name {
+			@func concat
+			strings [
+				"cards."
+				{
+					@func card_driver
+					card $CARD
+				}
+				".pcm.hdmi." $DEV ":"
+				"CARD=" $CARD ","
+				"AES0=" $AES0 ","
+				"AES1=" $AES1 ","
+				"AES2=" $AES2 ","
+				"AES3=" $AES3
+			]
+		}
+	}
+	hint {
+		show {
+			@func refer
+			name defaults.namehint.basic
+		}
+		description "HDMI Audio Output"
+		device $DEV
+	}
+}
diff -r b1dfac5a4d55 src/control/namehint.c
--- a/src/control/namehint.c	Tue Feb 05 10:08:09 2008 +0100
+++ b/src/control/namehint.c	Fri Mar 14 14:12:33 2008 +0100
@@ -197,10 +197,11 @@ static char *get_dev_name(struct hint_li
 			free(str1);
 			return res;
 		}
-	} else {
-		return strdup(list->cardname);
 	}
-	return NULL;
+	/* if the specified device doesn't exist, skip this entry */
+	if (list->device_input >= 0 || list->device_output >= 0)
+		return NULL;
+	return strdup(list->cardname);
 }
 
 #ifndef DOC_HIDDEN
@@ -304,8 +305,8 @@ static int try_config(struct hint_list *
 				err = -EINVAL;
 				goto __cleanup;
 			}
-			list->device_input = -1;
-			list->device_output = -1;
+			list->device_input = dev;
+			list->device_output = dev;
 		}
 		if (snd_config_search(cfg, "device_input", &n) >= 0) {
 			if (snd_config_get_integer(n, &list->device_input) < 0) {
diff -r b1dfac5a4d55 src/pcm/pcm_dmix.c
--- a/src/pcm/pcm_dmix.c	Tue Feb 05 10:08:09 2008 +0100
+++ b/src/pcm/pcm_dmix.c	Fri Mar 14 14:12:33 2008 +0100
@@ -311,9 +311,9 @@ static void snd_pcm_dmix_sync_area(snd_p
 	if (size >= pcm->boundary / 2)
 		size = pcm->boundary - size;
 
-	/* the slave_app_ptr can be far behing the slave_hw_ptr */
+	/* the slave_app_ptr can be far behind the slave_hw_ptr */
 	/* reduce mixing and errors here - just skip not catched writes */
-	if (dmix->slave_hw_ptr < dmix->slave_appl_ptr)
+	if (dmix->slave_hw_ptr <= dmix->slave_appl_ptr)
 		slave_size = dmix->slave_appl_ptr - dmix->slave_hw_ptr;
 	else
 		slave_size = dmix->slave_appl_ptr + (dmix->slave_boundary - dmix->slave_hw_ptr);
diff -r b1dfac5a4d55 src/pcm/pcm_file.c
--- a/src/pcm/pcm_file.c	Tue Feb 05 10:08:09 2008 +0100
+++ b/src/pcm/pcm_file.c	Fri Mar 14 14:12:33 2008 +0100
@@ -231,21 +231,19 @@ static snd_pcm_sframes_t snd_pcm_file_re
 {
 	snd_pcm_file_t *file = pcm->private_data;
 	snd_pcm_channel_area_t areas[pcm->channels];
-	snd_pcm_sframes_t n /* , bytesn */;
+	snd_pcm_sframes_t n;
 
+	n = snd_pcm_readi(file->gen.slave, buffer, size);
+	if (n <= 0)
+		return n;
 	if (file->ifd >= 0) {
-		n = /* bytesn = */ read(file->ifd, buffer, size * pcm->frame_bits / 8);
-		if (n > 0)
-			n = n * 8 / pcm->frame_bits;
-		/* SNDERR("DEBUG: channels = %d, sample_bits = %d, frame_bits = %d, bytes = %d, frames = %d",
-		        pcm->channels, pcm->sample_bits, pcm->frame_bits, bytesn, n); */
-	} else {
-		n = snd_pcm_readi(file->gen.slave, buffer, size);
-		if (n > 0) {
-			snd_pcm_areas_from_buf(pcm, areas, buffer);
-			snd_pcm_file_add_frames(pcm, areas, 0, n);
-		}
+		n = read(file->ifd, buffer, n * pcm->frame_bits / 8);
+		if (n < 0)
+			return n;
+		return n * 8 / pcm->frame_bits;
 	}
+	snd_pcm_areas_from_buf(pcm, areas, buffer);
+	snd_pcm_file_add_frames(pcm, areas, 0, n);
 	return n;
 }
 
@@ -396,6 +394,7 @@ static snd_pcm_fast_ops_t snd_pcm_file_f
  * \param ifname Input filename (or NULL if file descriptor ifd is available)
  * \param ifd Input file descriptor (if (ifd < 0) && (ifname == NULL), no input
  *            redirection will be performed)
+ * \param trunc Truncate the file if it already exists
  * \param fmt File format ("raw" is supported only)
  * \param perm File permission
  * \param slave Slave PCM handle
@@ -406,13 +405,15 @@ static snd_pcm_fast_ops_t snd_pcm_file_f
  *          changed in future.
  */
 int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
-		      const char *fname, int fd, const char *ifname, int ifd, 
+		      const char *fname, int fd, const char *ifname, int ifd,
+		      int trunc,
 		      const char *fmt, int perm, snd_pcm_t *slave, int close_slave)
 {
 	snd_pcm_t *pcm;
 	snd_pcm_file_t *file;
 	snd_pcm_file_format_t format;
 	struct timespec timespec;
+	char *tmpname = NULL;
 	int err;
 
 	assert(pcmp);
@@ -424,9 +425,30 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, 
 		return -EINVAL;
 	}
 	if (fname) {
-		fd = open(fname, O_WRONLY|O_CREAT, perm);
+		if (trunc)
+			fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, perm);
+		else {
+			fd = open(fname, O_WRONLY|O_CREAT|O_EXCL, perm);
+			if (fd < 0) {
+				int idx, len;
+				len = strlen(fname) + 6;
+				tmpname = malloc(len);
+				if (!tmpname)
+					return -ENOMEM;
+				for (idx = 1; idx < 10000; idx++) {
+					snprintf(tmpname, len,
+						 "%s.%04d", fname, idx);
+					fd = open(tmpname, O_WRONLY|O_CREAT|O_EXCL, perm);
+					if (fd >= 0) {
+						fname = tmpname;
+						break;
+					}
+				}
+			}
+		}
 		if (fd < 0) {
 			SYSERR("open %s for writing failed", fname);
+			free(tmpname);
 			return -errno;
 		}
 	}
@@ -434,6 +456,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, 
 	if (!file) {
 		if (fname)
 			close(fd);
+		free(tmpname);
 		return -ENOMEM;
 	}
 
@@ -443,6 +466,8 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, 
 			SYSERR("open %s for reading failed", ifname);
 			if (fname)
 				close(fd);
+			free(file);
+			free(tmpname);
 			return -errno;
 		}
 	}
@@ -461,6 +486,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, 
 	if (err < 0) {
 		free(file->fname);
 		free(file);
+		free(tmpname);
 		return err;
 	}
 	pcm->ops = &snd_pcm_file_ops;
@@ -469,7 +495,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, 
 	pcm->poll_fd = slave->poll_fd;
 	pcm->poll_events = slave->poll_events;
 	pcm->mmap_shadow = 1;
-#ifdef HAVE_CLOCK_GETTIME
+#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
 	pcm->monotonic = clock_gettime(CLOCK_MONOTONIC, &timespec) == 0;
 #else
 	pcm->monotonic = 0;
@@ -478,6 +504,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, 
 	snd_pcm_link_appl_ptr(pcm, slave);
 	*pcmp = pcm;
 
+	free(tmpname);
 	return 0;
 }
 
@@ -541,7 +568,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp,
 	snd_config_t *slave = NULL, *sconf;
 	const char *fname = NULL, *ifname = NULL;
 	const char *format = NULL;
-	long fd = -1, ifd = -1;
+	long fd = -1, ifd = -1, trunc = 1;
 	long perm = 0600;
 	snd_config_for_each(i, next, conf) {
 		snd_config_t *n = snd_config_iterator_entry(i);
@@ -596,6 +623,13 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp,
 			}
 			continue;
 		}
+		if (strcmp(id, "truncate") == 0) {
+			err = snd_config_get_bool(n);
+			if (err < 0)
+				return -EINVAL;
+			trunc = err;
+			continue;
+		}
 		SNDERR("Unknown field %s", id);
 		return -EINVAL;
 	}
@@ -606,7 +640,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp,
 	err = snd_pcm_slave_conf(root, slave, &sconf, 0);
 	if (err < 0)
 		return err;
-	if (!fname && fd < 0) {
+	if (!fname && fd < 0 && !ifname) {
 		snd_config_delete(sconf);
 		SNDERR("file is not defined");
 		return -EINVAL;
@@ -615,7 +649,8 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp,
 	snd_config_delete(sconf);
 	if (err < 0)
 		return err;
-	err = snd_pcm_file_open(pcmp, name, fname, fd, ifname, ifd, format, perm, spcm, 1);
+	err = snd_pcm_file_open(pcmp, name, fname, fd, ifname, ifd,
+				trunc, format, perm, spcm, 1);
 	if (err < 0)
 		snd_pcm_close(spcm);
 	return err;
diff -r b1dfac5a4d55 src/pcm/pcm_hw.c
--- a/src/pcm/pcm_hw.c	Tue Feb 05 10:08:09 2008 +0100
+++ b/src/pcm/pcm_hw.c	Fri Mar 14 14:12:33 2008 +0100
@@ -994,7 +994,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp,
 	if (SNDRV_PROTOCOL_INCOMPATIBLE(ver, SNDRV_PCM_VERSION_MAX))
 		return -SND_ERROR_INCOMPATIBLE_VERSION;
 
-#ifdef HAVE_CLOCK_GETTIME
+#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
 	if (SNDRV_PROTOCOL_VERSION(2, 0, 9) <= ver) {
 		struct timespec timespec;
 		if (clock_gettime(CLOCK_MONOTONIC, &timespec) == 0) {
diff -r b1dfac5a4d55 src/pcm/pcm_ioplug.c
--- a/src/pcm/pcm_ioplug.c	Tue Feb 05 10:08:09 2008 +0100
+++ b/src/pcm/pcm_ioplug.c	Fri Mar 14 14:12:33 2008 +0100
@@ -484,7 +484,7 @@ static int snd_pcm_ioplug_pause(snd_pcm_
 {
 	ioplug_priv_t *io = pcm->private_data;
 	static snd_pcm_state_t states[2] = {
-		SND_PCM_STATE_PAUSED, SND_PCM_STATE_RUNNING
+		SND_PCM_STATE_RUNNING, SND_PCM_STATE_PAUSED
 	};
 	int prev, err;
 
diff -r b1dfac5a4d55 src/pcm/pcm_local.h
--- a/src/pcm/pcm_local.h	Tue Feb 05 10:08:09 2008 +0100
+++ b/src/pcm/pcm_local.h	Fri Mar 14 14:12:33 2008 +0100
@@ -944,13 +944,17 @@ typedef union snd_tmp_double {
 /* get the current timestamp */
 static inline void gettimestamp(snd_htimestamp_t *tstamp, int monotonic)
 {
+#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
 	if (monotonic) {
 		clock_gettime(CLOCK_MONOTONIC, tstamp);
 	} else {
+#endif
 		struct timeval tv;
 
 		gettimeofday(&tv, 0);
 		tstamp->tv_sec = tv.tv_sec;
 		tstamp->tv_nsec = tv.tv_usec * 1000L;
+#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
 	}
+#endif
 }
diff -r b1dfac5a4d55 src/seq/seq.c
--- a/src/seq/seq.c	Tue Feb 05 10:08:09 2008 +0100
+++ b/src/seq/seq.c	Fri Mar 14 14:12:33 2008 +0100
@@ -1522,11 +1522,17 @@ int snd_seq_client_info_get_error_bounce
 }
 
 /**
- * \brief Get the event filter bitmap of a client_info container
+ * \brief (DEPRECATED) Get the event filter bitmap of a client_info container
  * \param info client_info container
  * \return NULL if no event filter, or pointer to event filter bitmap
  *
- * \sa snd_seq_get_client_info(), snd_seq_client_info_set_event_filter()
+ * Use #snd_seq_client_info_event_filter_check() instead.
+ *
+ * \sa snd_seq_client_info_event_filter_add(),
+ *     snd_seq_client_info_event_filter_del(),
+ *     snd_seq_client_info_event_filter_check(),
+ *     snd_seq_client_info_event_filter_clear(),
+ *     snd_seq_get_client_info()
  */
 const unsigned char *snd_seq_client_info_get_event_filter(const snd_seq_client_info_t *info)
 {
@@ -1538,6 +1544,87 @@ const unsigned char *snd_seq_client_info
 }
 
 /**
+ * \brief Disable event filtering of a client_info container
+ * \param info client_info container
+ *
+ * Remove all event types added with #snd_seq_client_info_event_filter_add and clear
+ * the event filtering flag of this client_info container.
+ * 
+ * \sa snd_seq_client_info_event_filter_add(),
+ *     snd_seq_client_info_event_filter_del(),
+ *     snd_seq_client_info_event_filter_check(),
+ *     snd_seq_get_client_info(),
+ *     snd_seq_set_client_info()
+ */
+void snd_seq_client_info_event_filter_clear(snd_seq_client_info_t *info)
+{
+       assert(info);
+       info->filter &= ~SNDRV_SEQ_FILTER_USE_EVENT;
+       memset(info->event_filter, 0, sizeof(info->event_filter));
+}
+
+/**
+ * \brief Add an event type to the event filtering of a client_info container
+ * \param info client_info container
+ * \param event_type event type to be added
+ * 
+ * Set the event filtering flag of this client_info and add the specified event type to the 
+ * filter bitmap of this client_info container.
+ *
+ * \sa snd_seq_get_client_info(),
+ *     snd_seq_set_client_info(),
+ *     snd_seq_client_info_event_filter_del(),
+ *     snd_seq_client_info_event_filter_check(),
+ *     snd_seq_client_info_event_filter_clear()
+ */
+void snd_seq_client_info_event_filter_add(snd_seq_client_info_t *info, int event_type)
+{
+       assert(info);
+       info->filter |= SNDRV_SEQ_FILTER_USE_EVENT;
+       snd_seq_set_bit(event_type, info->event_filter);
+}
+
+/**
+ * \brief Remove an event type from the event filtering of a client_info container
+ * \param info client_info container
+ * \param event_type event type to be removed
+ *
+ * Removes the specified event from the filter bitmap of this client_info container. It will
+ * not clear the event filtering flag, use #snd_seq_client_info_event_filter_clear instead.
+ *
+ * \sa snd_seq_get_client_info(),
+ *     snd_seq_set_client_info(),
+ *     snd_seq_client_info_event_filter_add(),
+ *     snd_seq_client_info_event_filter_check(),
+ *     snd_seq_client_info_event_filter_clear()
+ */
+void snd_seq_client_info_event_filter_del(snd_seq_client_info_t *info, int event_type)
+{
+       assert(info);
+       snd_seq_unset_bit(event_type, info->event_filter);
+}
+
+/**
+ * \brief Check if an event type is present in the event filtering of a client_info container
+ * \param info client_info container
+ * \param event_type event type to be checked
+ * \return 1 if the event type is present, 0 otherwise
+ *
+ * Test if the event type is in the filter bitamp of this client_info container.
+ *
+ * \sa snd_seq_get_client_info(),
+ *     snd_seq_set_client_info(),
+ *     snd_seq_client_info_event_filter_add(),
+ *     snd_seq_client_info_event_filter_del(),
+ *     snd_seq_client_info_event_filter_clear()
+ */
+int snd_seq_client_info_event_filter_check(snd_seq_client_info_t *info, int event_type)
+{
+       assert(info);
+       return snd_seq_get_bit(event_type, info->event_filter);
+} 
+
+/**
  * \brief Get the number of opened ports of a client_info container
  * \param info client_info container
  * \return number of opened ports
@@ -1623,12 +1710,17 @@ void snd_seq_client_info_set_error_bounc
 }
 
 /**
- * \brief Set the event filter bitmap of a client_info container
- * \param info client_info container
- * \param filter event filter bitmap
- *
- * \sa snd_seq_get_client_info(), snd_seq_client_info_get_event_filger(),
- *     snd_seq_set_client_event_filter()
+ * \brief (DEPRECATED) Set the event filter bitmap of a client_info container
+ * \param info client_info container
+ * \param filter event filter bitmap, pass NULL for no event filtering
+ *
+ * Use #snd_seq_client_info_event_filter_add instead.
+ *
+ * \sa snd_seq_client_info_event_filter_add(),
+ *     snd_seq_client_info_event_filter_del(),
+ *     snd_seq_client_info_event_filter_check(),
+ *     snd_seq_client_info_event_filter_clear(),
+ *     snd_seq_set_client_info()
  */
 void snd_seq_client_info_set_event_filter(snd_seq_client_info_t *info, unsigned char *filter)
 {
@@ -4663,6 +4755,14 @@ void snd_seq_set_bit(int nr, void *array
 }
 
 /**
+ * \brief unset a bit flag
+ */
+void snd_seq_unset_bit(int nr, void *array)
+{
+       ((unsigned int *)array)[nr >> 5] &= ~(1UL << (nr & 31));
+}
+
+/**
  * \brief change a bit flag
  */
 int snd_seq_change_bit(int nr, void *array)
@@ -4670,7 +4770,7 @@ int snd_seq_change_bit(int nr, void *arr
 	int result;
 
 	result = ((((unsigned int *)array)[nr >> 5]) & (1UL << (nr & 31))) ? 1 : 0;
-	((unsigned int *)array)[nr >> 5] |= 1UL << (nr & 31);
+	((unsigned int *)array)[nr >> 5] ^= 1UL << (nr & 31);
 	return result;
 }
 
diff -r b1dfac5a4d55 src/seq/seqmid.c
--- a/src/seq/seqmid.c	Tue Feb 05 10:08:09 2008 +0100
+++ b/src/seq/seqmid.c	Fri Mar 14 14:12:34 2008 +0100
@@ -251,8 +251,7 @@ int snd_seq_set_client_event_filter(snd_
 
 	if ((err = snd_seq_get_client_info(seq, &info)) < 0)
 		return err;
-	info.filter |= SNDRV_SEQ_FILTER_USE_EVENT;
-	snd_seq_set_bit(event_type, info.event_filter);
+	snd_seq_client_info_event_filter_add(&info, event_type);
 	return snd_seq_set_client_info(seq, &info);
 }
 
diff -r b1dfac5a4d55 test/Makefile.am
--- a/test/Makefile.am	Tue Feb 05 10:08:09 2008 +0100
+++ b/test/Makefile.am	Fri Mar 14 14:12:34 2008 +0100
@@ -1,6 +1,6 @@ check_PROGRAMS=control pcm pcm_min laten
 check_PROGRAMS=control pcm pcm_min latency seq \
 	       playmidi1 timer rawmidi midiloop \
-	       oldapi queue_timer namehint
+	       oldapi queue_timer namehint client_event_filter
 
 control_LDADD=../src/libasound.la
 pcm_LDADD=../src/libasound.la
@@ -14,6 +14,7 @@ oldapi_LDADD=../src/libasound.la
 oldapi_LDADD=../src/libasound.la
 queue_timer_LDADD=../src/libasound.la
 namehint_LDADD=../src/libasound.la
+client_event_filter_LDADD=../src/libasound.la
 code_CFLAGS=-Wall -pipe -g -O2
 
 INCLUDES=-I$(top_srcdir)/include
diff -r b1dfac5a4d55 test/client_event_filter.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/client_event_filter.c	Fri Mar 14 14:12:34 2008 +0100
@@ -0,0 +1,46 @@
+#include <alsa/asoundlib.h>
+
+void dump_event_filter(snd_seq_client_info_t *client_info) {
+	int i, b;
+
+	for (i = 0; i <= 255;) {
+		b = snd_seq_client_info_event_filter_check(client_info, i);
+		i++;
+		printf("%c%s%s", (b ? 'X' : '.'),
+			(i % 8 == 0 ? " " : ""),
+			(i % 32 == 0 ? "\n" : ""));
+	}
+	printf("\n");
+}
+
+int main(void) {
+	snd_seq_client_info_t *client_info;
+
+	snd_seq_client_info_alloca(&client_info);
+
+	printf("first client_info_event_filter                   :\n");
+	dump_event_filter(client_info);
+
+	snd_seq_client_info_event_filter_add(client_info, SND_SEQ_EVENT_NOTEON);
+	printf("after snd_seq_client_info_event_filter_add(client_info, SND_SEQ_EVENT_NOTEON);\n");
+	dump_event_filter(client_info);
+
+	snd_seq_client_info_event_filter_add(client_info, SND_SEQ_EVENT_PGMCHANGE);
+	printf("after snd_seq_client_info_event_filter_add(client_info, SND_SEQ_EVENT_PGMCHANGE);\n");
+	dump_event_filter(client_info);
+
+	snd_seq_client_info_event_filter_del(client_info, SND_SEQ_EVENT_NOTEON);
+	printf("after snd_seq_client_info_event_filter_del(client_info, SND_SEQ_EVENT_NOTEON);\n");
+	dump_event_filter(client_info);
+
+	snd_seq_client_info_event_filter_clear(client_info);
+	printf("after snd_seq_client_info_event_filter_clear(client_info);\n");
+	dump_event_filter(client_info);
+
+	snd_seq_client_info_event_filter_add(client_info, SND_SEQ_EVENT_NOTEON);
+	printf("after snd_seq_client_info_event_filter_add(client_info, SND_SEQ_EVENT_NOTEON);\n");
+	dump_event_filter(client_info);
+
+	return 0;
+}
+
openSUSE Build Service is sponsored by