Skip to content

Commit 427f5b6

Browse files
committed
patch 8.1.1502: cannot play any sound
Problem: Cannot play any sound. Solution: Use libcanberra if available. Add sound functions.
1 parent 260addf commit 427f5b6

16 files changed

Lines changed: 440 additions & 131 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ addons:
7777
- clang
7878
- lcov
7979
- gettext
80+
- libcanberra-dev
8081
- libperl-dev
8182
- python-dev
8283
- python3-dev

Filelist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ SRC_ALL = \
8888
src/search.c \
8989
src/sha256.c \
9090
src/sign.c \
91+
src/sound.c \
9192
src/spell.c \
9293
src/spell.h \
9394
src/spellfile.c \
@@ -150,6 +151,7 @@ SRC_ALL = \
150151
src/testdir/samples/test000 \
151152
src/testdir/if_ver*.vim \
152153
src/testdir/color_ramp.vim \
154+
src/testdir/silent.wav \
153155
src/proto.h \
154156
src/protodef.h \
155157
src/proto/arabic.pro \
@@ -209,6 +211,7 @@ SRC_ALL = \
209211
src/proto/search.pro \
210212
src/proto/sha256.pro \
211213
src/proto/sign.pro \
214+
src/proto/sound.pro \
212215
src/proto/spell.pro \
213216
src/proto/spellfile.pro \
214217
src/proto/syntax.pro \

runtime/doc/eval.txt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,6 +2622,12 @@ sin({expr}) Float sine of {expr}
26222622
sinh({expr}) Float hyperbolic sine of {expr}
26232623
sort({list} [, {func} [, {dict}]])
26242624
List sort {list}, using {func} to compare
2625+
sound_playevent({name} [, {callback}])
2626+
Number play an event sound
2627+
sound_playfile({name} [, {callback}])
2628+
Number play a sound file
2629+
sound_stop({id}) none stop playing sound {id}
2630+
sound_stopall() none stop playing all sounds
26252631
soundfold({word}) String sound-fold {word}
26262632
spellbadword() String badly spelled word at cursor
26272633
spellsuggest({word} [, {max} [, {capital}]])
@@ -8837,6 +8843,49 @@ sort({list} [, {func} [, {dict}]]) *sort()* *E702*
88378843
return a:i1 - a:i2
88388844
endfunc
88398845
<
8846+
*sound_playevent()*
8847+
sound_playevent({name} [, {callback}])
8848+
Play a sound identified by {name}. Which event names are
8849+
supported depends on the system. Often the XDG sound names
8850+
are used. On Ubuntu they may be found in
8851+
/usr/share/sounds/freedesktop/stereo. Example: >
8852+
call sound_playevent('bell')
8853+
8854+
< When {callback} is specified it is invoked when the sound is
8855+
finished. The first argument is the sound ID, the second
8856+
argument is the status:
8857+
0 sound was played to the end
8858+
1 sound was interruped
8859+
2 error occured after sound started
8860+
Example: >
8861+
func Callback(id, status)
8862+
echomsg "sound " .. a:id .. " finished with " .. a:status
8863+
endfunc
8864+
call sound_playevent('bell', 'Callback')
8865+
8866+
< Returns the sound ID, which can be passed to `sound_stop()`.
8867+
Returns zero if the sound could not be played.
8868+
{only available when compiled with the +sound feature}
8869+
8870+
*sound_playfile()*
8871+
sound_playfile({name} [, {callback}])
8872+
Like `sound_playevent()` but play sound file {name}. {name}
8873+
must be a full path. On Ubuntu you may find files to play
8874+
with this command: >
8875+
:!find /usr/share/sounds -type f | grep -v index.theme
8876+
8877+
< {only available when compiled with the +sound feature}
8878+
8879+
8880+
sound_stop({id}) *sound_stop()*
8881+
Stop playing sound {id}. {id} must be previously returned by
8882+
`sound_playevent()` or `sound_playfile()`.
8883+
{only available when compiled with the +sound feature}
8884+
8885+
sound_stopall() *sound_stopall()*
8886+
Stop playing all sounds.
8887+
{only available when compiled with the +sound feature}
8888+
88408889
*soundfold()*
88418890
soundfold({word})
88428891
Return the sound-folded equivalent of {word}. Uses the first
@@ -10756,6 +10805,7 @@ scrollbind Compiled with 'scrollbind' support. (always true)
1075610805
showcmd Compiled with 'showcmd' support.
1075710806
signs Compiled with |:sign| support.
1075810807
smartindent Compiled with 'smartindent' support.
10808+
sound Compiled with sound support, e.g. `sound_playevent()`
1075910809
spell Compiled with spell checking support |spell|.
1076010810
startuptime Compiled with |--startuptime| support.
1076110811
statusline Compiled with support for 'statusline', 'rulerformat'

src/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,7 @@ BASIC_SRC = \
16281628
search.c \
16291629
sha256.c \
16301630
sign.c \
1631+
sound.c \
16311632
spell.c \
16321633
spellfile.c \
16331634
syntax.c \
@@ -1743,6 +1744,7 @@ OBJ_COMMON = \
17431744
objects/search.o \
17441745
objects/sha256.o \
17451746
objects/sign.o \
1747+
objects/sound.o \
17461748
objects/spell.o \
17471749
objects/spellfile.o \
17481750
objects/syntax.o \
@@ -1883,6 +1885,7 @@ PRO_AUTO = \
18831885
search.pro \
18841886
sha256.pro \
18851887
sign.pro \
1888+
sound.pro \
18861889
spell.pro \
18871890
spellfile.pro \
18881891
syntax.pro \
@@ -3235,6 +3238,9 @@ objects/sha256.o: sha256.c
32353238
objects/sign.o: sign.c
32363239
$(CCC) -o $@ sign.c
32373240

3241+
objects/sound.o: sound.c
3242+
$(CCC) -o $@ sound.c
3243+
32383244
objects/spell.o: spell.c
32393245
$(CCC) -o $@ spell.c
32403246

@@ -3650,6 +3656,10 @@ objects/sign.o: sign.c vim.h protodef.h auto/config.h feature.h os_unix.h \
36503656
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
36513657
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
36523658
proto.h globals.h
3659+
objects/sound.o: spell.c vim.h protodef.h auto/config.h feature.h os_unix.h \
3660+
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
3661+
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
3662+
proto.h globals.h
36533663
objects/spell.o: spell.c vim.h protodef.h auto/config.h feature.h os_unix.h \
36543664
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
36553665
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \

src/auto/configure

Lines changed: 72 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -9303,28 +9303,8 @@ fi
93039303

93049304

93059305

9306-
9307-
if test -z "$SKIP_GTK2"; then
9308-
9309-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --disable-gtktest argument" >&5
9310-
$as_echo_n "checking --disable-gtktest argument... " >&6; }
9311-
# Check whether --enable-gtktest was given.
9312-
if test "${enable_gtktest+set}" = set; then :
9313-
enableval=$enable_gtktest;
9314-
else
9315-
enable_gtktest=yes
9316-
fi
9317-
9318-
if test "x$enable_gtktest" = "xyes" ; then
9319-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: gtk test enabled" >&5
9320-
$as_echo "gtk test enabled" >&6; }
9321-
else
9322-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: gtk test disabled" >&5
9323-
$as_echo "gtk test disabled" >&6; }
9324-
fi
9325-
9326-
if test "X$PKG_CONFIG" = "X"; then
9327-
if test -n "$ac_tool_prefix"; then
9306+
if test "X$PKG_CONFIG" = "X"; then
9307+
if test -n "$ac_tool_prefix"; then
93289308
# Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
93299309
set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
93309310
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -9422,6 +9402,26 @@ else
94229402
PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
94239403
fi
94249404

9405+
fi
9406+
9407+
9408+
if test -z "$SKIP_GTK2"; then
9409+
9410+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --disable-gtktest argument" >&5
9411+
$as_echo_n "checking --disable-gtktest argument... " >&6; }
9412+
# Check whether --enable-gtktest was given.
9413+
if test "${enable_gtktest+set}" = set; then :
9414+
enableval=$enable_gtktest;
9415+
else
9416+
enable_gtktest=yes
9417+
fi
9418+
9419+
if test "x$enable_gtktest" = "xyes" ; then
9420+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: gtk test enabled" >&5
9421+
$as_echo "gtk test enabled" >&6; }
9422+
else
9423+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: gtk test disabled" >&5
9424+
$as_echo "gtk test disabled" >&6; }
94259425
fi
94269426

94279427
if test "x$PKG_CONFIG" != "xno"; then
@@ -9677,107 +9677,6 @@ $as_echo "gtk test enabled" >&6; }
96779677
$as_echo "gtk test disabled" >&6; }
96789678
fi
96799679

9680-
if test "X$PKG_CONFIG" = "X"; then
9681-
if test -n "$ac_tool_prefix"; then
9682-
# Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
9683-
set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
9684-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
9685-
$as_echo_n "checking for $ac_word... " >&6; }
9686-
if ${ac_cv_path_PKG_CONFIG+:} false; then :
9687-
$as_echo_n "(cached) " >&6
9688-
else
9689-
case $PKG_CONFIG in
9690-
[\\/]* | ?:[\\/]*)
9691-
ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
9692-
;;
9693-
*)
9694-
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
9695-
for as_dir in $PATH
9696-
do
9697-
IFS=$as_save_IFS
9698-
test -z "$as_dir" && as_dir=.
9699-
for ac_exec_ext in '' $ac_executable_extensions; do
9700-
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
9701-
ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
9702-
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
9703-
break 2
9704-
fi
9705-
done
9706-
done
9707-
IFS=$as_save_IFS
9708-
9709-
;;
9710-
esac
9711-
fi
9712-
PKG_CONFIG=$ac_cv_path_PKG_CONFIG
9713-
if test -n "$PKG_CONFIG"; then
9714-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
9715-
$as_echo "$PKG_CONFIG" >&6; }
9716-
else
9717-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
9718-
$as_echo "no" >&6; }
9719-
fi
9720-
9721-
9722-
fi
9723-
if test -z "$ac_cv_path_PKG_CONFIG"; then
9724-
ac_pt_PKG_CONFIG=$PKG_CONFIG
9725-
# Extract the first word of "pkg-config", so it can be a program name with args.
9726-
set dummy pkg-config; ac_word=$2
9727-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
9728-
$as_echo_n "checking for $ac_word... " >&6; }
9729-
if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
9730-
$as_echo_n "(cached) " >&6
9731-
else
9732-
case $ac_pt_PKG_CONFIG in
9733-
[\\/]* | ?:[\\/]*)
9734-
ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
9735-
;;
9736-
*)
9737-
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
9738-
for as_dir in $PATH
9739-
do
9740-
IFS=$as_save_IFS
9741-
test -z "$as_dir" && as_dir=.
9742-
for ac_exec_ext in '' $ac_executable_extensions; do
9743-
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
9744-
ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
9745-
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
9746-
break 2
9747-
fi
9748-
done
9749-
done
9750-
IFS=$as_save_IFS
9751-
9752-
;;
9753-
esac
9754-
fi
9755-
ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
9756-
if test -n "$ac_pt_PKG_CONFIG"; then
9757-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
9758-
$as_echo "$ac_pt_PKG_CONFIG" >&6; }
9759-
else
9760-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
9761-
$as_echo "no" >&6; }
9762-
fi
9763-
9764-
if test "x$ac_pt_PKG_CONFIG" = x; then
9765-
PKG_CONFIG="no"
9766-
else
9767-
case $cross_compiling:$ac_tool_warned in
9768-
yes:)
9769-
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
9770-
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
9771-
ac_tool_warned=yes ;;
9772-
esac
9773-
PKG_CONFIG=$ac_pt_PKG_CONFIG
9774-
fi
9775-
else
9776-
PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
9777-
fi
9778-
9779-
fi
9780-
97819680
if test "x$PKG_CONFIG" != "xno"; then
97829681

97839682
if test "X$GTK_CONFIG" != "Xno" -o "X$PKG_CONFIG" != "Xno"; then
@@ -13026,6 +12925,56 @@ rm -rf conftest*
1302612925
fi
1302712926

1302812927

12928+
12929+
if test "x$PKG_CONFIG" != "xno"; then
12930+
canberra_lib=`$PKG_CONFIG --libs libcanberrax 2>/dev/null`
12931+
canberra_cflags=`$PKG_CONFIG --cflags libcanberrax 2>/dev/null`
12932+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: canberra_lib: $canberra_lib" >&5
12933+
$as_echo "canberra_lib: $canberra_lib" >&6; }
12934+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: canberra_cflags: $canberra_cflags" >&5
12935+
$as_echo "canberra_cflags: $canberra_cflags" >&6; }
12936+
fi
12937+
if test "x$canberra_lib" = "x"; then
12938+
canberra_lib=-lcanberra
12939+
canberra_cflags=-D_REENTRANT
12940+
fi
12941+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: canberra_lib: $canberra_lib" >&5
12942+
$as_echo "canberra_lib: $canberra_lib" >&6; }
12943+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: canberra_cflags: $canberra_cflags" >&5
12944+
$as_echo "canberra_cflags: $canberra_cflags" >&6; }
12945+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libcanberra" >&5
12946+
$as_echo_n "checking for libcanberra... " >&6; }
12947+
ac_save_CFLAGS="$CFLAGS"
12948+
ac_save_LIBS="$LIBS"
12949+
CFLAGS="$CFLAGS $canberra_cflags"
12950+
LIBS="$LIBS $canberra_lib"
12951+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12952+
/* end confdefs.h. */
12953+
12954+
# include <canberra.h>
12955+
12956+
int
12957+
main ()
12958+
{
12959+
12960+
ca_context *hello;
12961+
ca_context_create(&hello);
12962+
;
12963+
return 0;
12964+
}
12965+
_ACEOF
12966+
if ac_fn_c_try_link "$LINENO"; then :
12967+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
12968+
$as_echo "yes" >&6; }; $as_echo "#define HAVE_CANBERRA 1" >>confdefs.h
12969+
12970+
else
12971+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
12972+
$as_echo "no" >&6; }; CFLAGS="$ac_save_CFLAGS"; LIBS="$ac_save_LIBS"
12973+
fi
12974+
rm -f core conftest.err conftest.$ac_objext \
12975+
conftest$ac_exeext conftest.$ac_ext
12976+
12977+
1302912978
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for st_blksize" >&5
1303012979
$as_echo_n "checking for st_blksize... " >&6; }
1303112980
cat confdefs.h - <<_ACEOF >conftest.$ac_ext

src/config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@
207207
#undef HAVE_STRNICMP
208208
#undef HAVE_STRPBRK
209209
#undef HAVE_STRTOL
210+
#undef HAVE_CANBERRA
210211
#undef HAVE_ST_BLKSIZE
211212
#undef HAVE_SYSCONF
212213
#undef HAVE_SYSCTL

0 commit comments

Comments
 (0)