Mercurial > vim
annotate src/sound.c @ 32996:dd8da8f1c2bc v9.0.1790
patch 9.0.1790: Redundant LSP Content-Type header
Commit: https://github.com/vim/vim/commit/8fbd9449e71f2ad93e594be575209a7424eb093e
Author: Magnus Gro? <magnus@mggross.com>
Date: Sun Aug 27 00:49:51 2023 +0200
patch 9.0.1790: Redundant LSP Content-Type header
Problem: The Content-Type header is an optional header that some LSP
servers struggle with and may crash when encountering it.
Solution: Drop the Content-Type header from all messages, because we use
the default value anyway.
Because pretty much all popular LSP clients (e.g. coc.nvim, VSCode) do
not send the Content-Type header, the LSP server ecosystem has developed
such that some LSP servers may even crash when encountering it.
To improve compatibility with these misbehaving LSP servers, we drop
this header as well.
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Magnus Gro? <magnus@mggross.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 27 Aug 2023 11:15:03 +0200 |
parents | 4545f58c8490 |
children | def9fc5c92d1 |
rev | line source |
---|---|
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 * sound.c: functions related making noise |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 */ |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 #include "vim.h" |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
16 #if defined(FEAT_SOUND) || defined(PROTO) |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 static long sound_id = 0; |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 |
30932
e1e21033c859
patch 9.0.0800: compiler complains about repeated typedef
Bram Moolenaar <Bram@vim.org>
parents:
30719
diff
changeset
|
20 // soundcb_T is typdef'ed in proto/sound.pro |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 struct soundcb_S { |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 callback_T snd_callback; |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
24 #ifdef MSWIN |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
25 MCIDEVICEID snd_device_id; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
26 long snd_id; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
27 #endif |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 soundcb_T *snd_next; |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 }; |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 static soundcb_T *first_callback = NULL; |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 |
17708
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
33 /* |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
34 * Return TRUE when a sound callback has been created, it may be invoked when |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
35 * the sound finishes playing. Also see has_sound_callback_in_queue(). |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
36 */ |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
37 int |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
38 has_any_sound_callback(void) |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
39 { |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
40 return first_callback != NULL; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
41 } |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
42 |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 static soundcb_T * |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 get_sound_callback(typval_T *arg) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 { |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 callback_T callback; |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 soundcb_T *soundcb; |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 if (arg->v_type == VAR_UNKNOWN) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 return NULL; |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 callback = get_callback(arg); |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 if (callback.cb_name == NULL) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 return NULL; |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 soundcb = ALLOC_ONE(soundcb_T); |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 if (soundcb == NULL) |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
57 { |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 free_callback(&callback); |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
59 return NULL; |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 } |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
61 |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
62 soundcb->snd_next = first_callback; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
63 first_callback = soundcb; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
64 set_callback(&soundcb->snd_callback, &callback); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
65 if (callback.cb_free_name) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
66 vim_free(callback.cb_name); |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 return soundcb; |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 } |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 /* |
30719
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
71 * Call "soundcb" with proper parameters. |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
72 */ |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
73 void |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
74 call_sound_callback(soundcb_T *soundcb, long snd_id, int result) |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
75 { |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
76 typval_T argv[3]; |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
77 typval_T rettv; |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
78 |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
79 argv[0].v_type = VAR_NUMBER; |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
80 argv[0].vval.v_number = snd_id; |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
81 argv[1].v_type = VAR_NUMBER; |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
82 argv[1].vval.v_number = result; |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
83 argv[2].v_type = VAR_UNKNOWN; |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
84 |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
85 call_callback(&soundcb->snd_callback, -1, &rettv, 2, argv); |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
86 clear_tv(&rettv); |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
87 } |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
88 |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
89 /* |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 * Delete "soundcb" from the list of pending callbacks. |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 */ |
30719
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
92 void |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 delete_sound_callback(soundcb_T *soundcb) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 { |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 soundcb_T *p; |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 soundcb_T *prev = NULL; |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 for (p = first_callback; p != NULL; prev = p, p = p->snd_next) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 if (p == soundcb) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 { |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 if (prev == NULL) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 first_callback = p->snd_next; |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 else |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 prev->snd_next = p->snd_next; |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 free_callback(&p->snd_callback); |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 vim_free(p); |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 break; |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 } |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 } |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
111 #if defined(HAVE_CANBERRA) || defined(PROTO) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
112 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
113 /* |
30719
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
114 * Sound implementation for Linux/Unix using libcanberra. |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
115 */ |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
116 # include <canberra.h> |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
117 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
118 static ca_context *context = NULL; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
119 |
17708
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
120 // Structure to store info about a sound callback to be invoked soon. |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
121 typedef struct soundcb_queue_S soundcb_queue_T; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
122 |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
123 struct soundcb_queue_S { |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
124 soundcb_queue_T *scb_next; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
125 uint32_t scb_id; // ID of the sound |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
126 int scb_result; // CA_ value |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
127 soundcb_T *scb_callback; // function to call |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
128 }; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
129 |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
130 // Queue of callbacks to invoke from the main loop. |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
131 static soundcb_queue_T *callback_queue = NULL; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
132 |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
133 /* |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
134 * Add a callback to the queue of callbacks to invoke later from the main loop. |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
135 * That is because the callback may be called from another thread and invoking |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
136 * another sound function may cause trouble. |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
137 */ |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 static void |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 sound_callback( |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 ca_context *c UNUSED, |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 uint32_t id, |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 int error_code, |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 void *userdata) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 { |
17708
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
145 soundcb_T *soundcb = (soundcb_T *)userdata; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
146 soundcb_queue_T *scb; |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 |
17708
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
148 scb = ALLOC_ONE(soundcb_queue_T); |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
149 if (scb == NULL) |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
150 return; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
151 scb->scb_next = callback_queue; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
152 callback_queue = scb; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
153 scb->scb_id = id; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
154 scb->scb_result = error_code == CA_SUCCESS ? 0 |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 : error_code == CA_ERROR_CANCELED |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 || error_code == CA_ERROR_DESTROYED |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 ? 1 : 2; |
17708
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
158 scb->scb_callback = soundcb; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
159 } |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
160 |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
161 /* |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
162 * Return TRUE if there is a sound callback to be called. |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
163 */ |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
164 int |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
165 has_sound_callback_in_queue(void) |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
166 { |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
167 return callback_queue != NULL; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
168 } |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 |
17708
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
170 /* |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
171 * Invoke queued sound callbacks. |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
172 */ |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
173 void |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
174 invoke_sound_callback(void) |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
175 { |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
176 soundcb_queue_T *scb; |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
177 |
17708
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
178 while (callback_queue != NULL) |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
179 { |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
180 scb = callback_queue; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
181 callback_queue = scb->scb_next; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
182 |
30719
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
183 call_sound_callback(scb->scb_callback, scb->scb_id, scb->scb_result); |
17708
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
184 |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
185 delete_sound_callback(scb->scb_callback); |
17895
d55356da47c1
patch 8.1.1944: leaking memory when using sound callback
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
186 vim_free(scb); |
17708
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17642
diff
changeset
|
187 } |
26466
d413104a94c8
patch 8.2.3763: when editing the cmdline a callback may cause a scroll up
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
188 redraw_after_callback(TRUE, FALSE); |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
189 } |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 static void |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 sound_play_common(typval_T *argvars, typval_T *rettv, int playfile) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 { |
25356
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24842
diff
changeset
|
194 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) |
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24842
diff
changeset
|
195 return; |
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24842
diff
changeset
|
196 |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 if (context == NULL) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 ca_context_create(&context); |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
199 if (context == NULL) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
200 return; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
201 |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
202 soundcb_T *soundcb = get_sound_callback(&argvars[1]); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
203 int res = CA_ERROR_INVALID; |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
205 ++sound_id; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
206 if (soundcb == NULL) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
207 { |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
208 res = ca_context_play(context, sound_id, |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
209 playfile ? CA_PROP_MEDIA_FILENAME : CA_PROP_EVENT_ID, |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
210 tv_get_string(&argvars[0]), |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
211 CA_PROP_CANBERRA_CACHE_CONTROL, "volatile", |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
212 NULL); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
213 } |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
214 else |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
215 { |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
216 static ca_proplist *proplist = NULL; |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
218 ca_proplist_create(&proplist); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
219 if (proplist != NULL) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
220 { |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
221 if (playfile) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
222 ca_proplist_sets(proplist, CA_PROP_MEDIA_FILENAME, |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
223 (char *)tv_get_string(&argvars[0])); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
224 else |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
225 ca_proplist_sets(proplist, CA_PROP_EVENT_ID, |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
226 (char *)tv_get_string(&argvars[0])); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
227 ca_proplist_sets(proplist, CA_PROP_CANBERRA_CACHE_CONTROL, |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
228 "volatile"); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
229 res = ca_context_play_full(context, sound_id, proplist, |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
230 sound_callback, soundcb); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
231 if (res != CA_SUCCESS) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
232 delete_sound_callback(soundcb); |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
234 ca_proplist_destroy(proplist); |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 } |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 } |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
237 rettv->vval.v_number = res == CA_SUCCESS ? sound_id : 0; |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 } |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 void |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 f_sound_playevent(typval_T *argvars, typval_T *rettv) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 { |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 sound_play_common(argvars, rettv, FALSE); |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 } |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 |
17026
905e1b154058
patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents:
17004
diff
changeset
|
246 /* |
905e1b154058
patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents:
17004
diff
changeset
|
247 * implementation of sound_playfile({path} [, {callback}]) |
905e1b154058
patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents:
17004
diff
changeset
|
248 */ |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 void |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 f_sound_playfile(typval_T *argvars, typval_T *rettv) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
251 { |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 sound_play_common(argvars, rettv, TRUE); |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
253 } |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 |
17026
905e1b154058
patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents:
17004
diff
changeset
|
255 /* |
905e1b154058
patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents:
17004
diff
changeset
|
256 * implementation of sound_stop({id}) |
905e1b154058
patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents:
17004
diff
changeset
|
257 */ |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 void |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 f_sound_stop(typval_T *argvars, typval_T *rettv UNUSED) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
261 if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
262 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
263 |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 if (context != NULL) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 ca_context_cancel(context, tv_get_number(&argvars[0])); |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 } |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 |
17026
905e1b154058
patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents:
17004
diff
changeset
|
268 /* |
905e1b154058
patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents:
17004
diff
changeset
|
269 * implementation of sound_clear() |
905e1b154058
patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents:
17004
diff
changeset
|
270 */ |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 void |
17026
905e1b154058
patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents:
17004
diff
changeset
|
272 f_sound_clear(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 { |
31809
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
274 if (context == NULL) |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
275 return; |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
276 ca_context_destroy(context); |
543153d582d5
patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31331
diff
changeset
|
277 context = NULL; |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 } |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
280 # if defined(EXITFREE) || defined(PROTO) |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 void |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
282 sound_free(void) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 { |
17895
d55356da47c1
patch 8.1.1944: leaking memory when using sound callback
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
284 soundcb_queue_T *scb; |
d55356da47c1
patch 8.1.1944: leaking memory when using sound callback
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
285 |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
286 if (context != NULL) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 ca_context_destroy(context); |
17895
d55356da47c1
patch 8.1.1944: leaking memory when using sound callback
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
288 |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 while (first_callback != NULL) |
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 delete_sound_callback(first_callback); |
17895
d55356da47c1
patch 8.1.1944: leaking memory when using sound callback
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
291 |
d55356da47c1
patch 8.1.1944: leaking memory when using sound callback
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
292 while (callback_queue != NULL) |
d55356da47c1
patch 8.1.1944: leaking memory when using sound callback
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
293 { |
d55356da47c1
patch 8.1.1944: leaking memory when using sound callback
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
294 scb = callback_queue; |
d55356da47c1
patch 8.1.1944: leaking memory when using sound callback
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
295 callback_queue = scb->scb_next; |
d55356da47c1
patch 8.1.1944: leaking memory when using sound callback
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
296 delete_sound_callback(scb->scb_callback); |
d55356da47c1
patch 8.1.1944: leaking memory when using sound callback
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
297 vim_free(scb); |
d55356da47c1
patch 8.1.1944: leaking memory when using sound callback
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
298 } |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 } |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
300 # endif |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
301 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
302 #elif defined(MSWIN) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
303 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
304 /* |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
305 * Sound implementation for MS-Windows. |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
306 */ |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
307 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
308 static HWND g_hWndSound = NULL; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
309 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
310 static LRESULT CALLBACK |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
311 sound_wndproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
312 { |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
313 soundcb_T *p; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
314 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
315 switch (message) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
316 { |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
317 case MM_MCINOTIFY: |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
318 for (p = first_callback; p != NULL; p = p->snd_next) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
319 if (p->snd_device_id == (MCIDEVICEID) lParam) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
320 { |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
321 char buf[32]; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
322 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
323 vim_snprintf(buf, sizeof(buf), "close sound%06ld", |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
324 p->snd_id); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
325 mciSendString(buf, NULL, 0, 0); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
326 |
30719
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
327 long result = wParam == MCI_NOTIFY_SUCCESSFUL ? 0 |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
328 : wParam == MCI_NOTIFY_ABORTED ? 1 : 2; |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
329 call_sound_callback(p, p->snd_id, result); |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
330 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
331 delete_sound_callback(p); |
26466
d413104a94c8
patch 8.2.3763: when editing the cmdline a callback may cause a scroll up
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
332 redraw_after_callback(TRUE, FALSE); |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
333 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
334 } |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
335 break; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
336 } |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
337 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
338 return DefWindowProc(hwnd, message, wParam, lParam); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
339 } |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
340 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
341 static HWND |
32009
4545f58c8490
patch 9.0.1336: functions without arguments are not always declared properly
Bram Moolenaar <Bram@vim.org>
parents:
31809
diff
changeset
|
342 sound_window(void) |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
343 { |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
344 if (g_hWndSound == NULL) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
345 { |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
346 LPCSTR clazz = "VimSound"; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
347 WNDCLASS wndclass = { |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
348 0, sound_wndproc, 0, 0, g_hinst, NULL, 0, 0, NULL, clazz }; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
349 RegisterClass(&wndclass); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
350 g_hWndSound = CreateWindow(clazz, NULL, 0, 0, 0, 0, 0, |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
351 HWND_MESSAGE, NULL, g_hinst, NULL); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
352 } |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
353 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
354 return g_hWndSound; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
355 } |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
356 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
357 void |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
358 f_sound_playevent(typval_T *argvars, typval_T *rettv) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
359 { |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
360 WCHAR *wp; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
361 |
25356
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24842
diff
changeset
|
362 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) |
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24842
diff
changeset
|
363 return; |
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24842
diff
changeset
|
364 |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
365 wp = enc_to_utf16(tv_get_string(&argvars[0]), NULL); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
366 if (wp == NULL) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
367 return; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
368 |
24842
237dace53473
patch 8.2.2959: sound_playfile() is not tested on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
369 if (PlaySoundW(wp, NULL, SND_ASYNC | SND_ALIAS)) |
237dace53473
patch 8.2.2959: sound_playfile() is not tested on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
370 rettv->vval.v_number = ++sound_id; |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
371 free(wp); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
372 } |
17004
353ed7ef78df
patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
374 void |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
375 f_sound_playfile(typval_T *argvars, typval_T *rettv) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
376 { |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
377 long newid = sound_id + 1; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
378 size_t len; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
379 char_u *p, *esc; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
380 WCHAR *wp; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
381 soundcb_T *soundcb; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
382 char buf[32]; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
383 MCIERROR err; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
384 |
25356
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24842
diff
changeset
|
385 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) |
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24842
diff
changeset
|
386 return; |
1cde96e768e4
patch 8.2.3215: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24842
diff
changeset
|
387 |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
388 esc = vim_strsave_shellescape(tv_get_string(&argvars[0]), FALSE, FALSE); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
389 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
390 len = STRLEN(esc) + 5 + 18 + 1; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
391 p = alloc(len); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
392 if (p == NULL) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
393 { |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
394 free(esc); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
395 return; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
396 } |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
397 vim_snprintf((char *)p, len, "open %s alias sound%06ld", esc, newid); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
398 free(esc); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
399 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
400 wp = enc_to_utf16((char_u *)p, NULL); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
401 free(p); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
402 if (wp == NULL) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
403 return; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
404 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
405 err = mciSendStringW(wp, NULL, 0, sound_window()); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
406 free(wp); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
407 if (err != 0) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
408 return; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
409 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
410 vim_snprintf(buf, sizeof(buf), "play sound%06ld notify", newid); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
411 err = mciSendString(buf, NULL, 0, sound_window()); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
412 if (err != 0) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
413 goto failure; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
414 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
415 sound_id = newid; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
416 rettv->vval.v_number = sound_id; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
417 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
418 soundcb = get_sound_callback(&argvars[1]); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
419 if (soundcb != NULL) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
420 { |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
421 vim_snprintf(buf, sizeof(buf), "sound%06ld", newid); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
422 soundcb->snd_id = newid; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
423 soundcb->snd_device_id = mciGetDeviceID(buf); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
424 } |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
425 return; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
426 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
427 failure: |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
428 vim_snprintf(buf, sizeof(buf), "close sound%06ld", newid); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
429 mciSendString(buf, NULL, 0, NULL); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
430 } |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
431 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
432 void |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
433 f_sound_stop(typval_T *argvars, typval_T *rettv UNUSED) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
434 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
435 long id; |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
436 char buf[32]; |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
437 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
438 if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
439 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
440 |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25356
diff
changeset
|
441 id = tv_get_number(&argvars[0]); |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
442 vim_snprintf(buf, sizeof(buf), "stop sound%06ld", id); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
443 mciSendString(buf, NULL, 0, NULL); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
444 } |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
445 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
446 void |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
447 f_sound_clear(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
448 { |
18006
5594967b38c5
patch 8.1.1999: calling both PlaySoundW() and PlaySoundA()
Bram Moolenaar <Bram@vim.org>
parents:
17895
diff
changeset
|
449 PlaySoundW(NULL, NULL, 0); |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
450 mciSendString("close all", NULL, 0, NULL); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
451 } |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
452 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
453 # if defined(EXITFREE) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
454 void |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
455 sound_free(void) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
456 { |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
457 CloseWindow(g_hWndSound); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
458 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
459 while (first_callback != NULL) |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
460 delete_sound_callback(first_callback); |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
461 } |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
462 # endif |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
463 |
30719
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
464 #elif defined(MACOS_X_DARWIN) |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
465 |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
466 // Sound implementation for macOS. |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
467 static void |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
468 sound_play_common(typval_T *argvars, typval_T *rettv, bool playfile) |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
469 { |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
470 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
471 return; |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
472 |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
473 char_u *sound_name = tv_get_string(&argvars[0]); |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
474 soundcb_T *soundcb = get_sound_callback(&argvars[1]); |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
475 |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
476 ++sound_id; |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
477 |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
478 bool play_success = sound_mch_play(sound_name, sound_id, soundcb, playfile); |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
479 if (!play_success && soundcb) |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
480 { |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
481 delete_sound_callback(soundcb); |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
482 } |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
483 rettv->vval.v_number = play_success ? sound_id : 0; |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
484 } |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
485 |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
486 void |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
487 f_sound_playevent(typval_T *argvars, typval_T *rettv) |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
488 { |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
489 sound_play_common(argvars, rettv, false); |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
490 } |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
491 |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
492 void |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
493 f_sound_playfile(typval_T *argvars, typval_T *rettv) |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
494 { |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
495 sound_play_common(argvars, rettv, true); |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
496 } |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
497 |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
498 void |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
499 f_sound_stop(typval_T *argvars, typval_T *rettv UNUSED) |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
500 { |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
501 if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL) |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
502 return; |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
503 sound_mch_stop(tv_get_number(&argvars[0])); |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
504 } |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
505 |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
506 void |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
507 f_sound_clear(typval_T *argvars UNUSED, typval_T *rettv UNUSED) |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
508 { |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
509 sound_mch_clear(); |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
510 } |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
511 |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
512 #if defined(EXITFREE) || defined(PROTO) |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
513 void |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
514 sound_free(void) |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
515 { |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
516 sound_mch_free(); |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
517 while (first_callback != NULL) |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
518 delete_sound_callback(first_callback); |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
519 } |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
520 #endif |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
521 |
71137f73c94d
patch 9.0.0694: no native sound support on Mac OS
Bram Moolenaar <Bram@vim.org>
parents:
26466
diff
changeset
|
522 #endif // MACOS_X_DARWIN |
17131
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
523 |
be5a5cfc991a
patch 8.1.1565: MS-Windows: no sound support
Bram Moolenaar <Bram@vim.org>
parents:
17026
diff
changeset
|
524 #endif // FEAT_SOUND |