Subject: bug#74863: closed (Re: bug#74863: 31.0.50; Problems with play-sound on MS-Windows)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 21 Dec 2024 10:38:02 +0000

Your bug report

#74863: 31.0.50; Problems with play-sound on MS-Windows

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
74863: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74863
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#74863: 31.0.50; Problems with play-sound on MS-Windows
From: Eli Zaretskii <[email-masked]>
To: Cecilio Pardo <[email-masked]>
Cc: [email-masked]
Date: Sat, 21 Dec 2024 12:37:37 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> Date: Sun, 15 Dec 2024 19:33:35 +0100
> Cc: [email-masked]
> From: Cecilio Pardo <[email-masked]>
> 
> On 15/12/2024 13:50, Eli Zaretskii wrote:
> 
> >> (defun load-file-into-unibyte-string (file-path)
> >>     (with-temp-buffer
> >>       (set-buffer-multibyte nil)
> >>       (insert-file-contents file-path)
> >>       (buffer-string)))
> >>
> >> (play-sound `(sound :data ,(load-file-into-unibyte-string "awav.wav")
> >> :volume 100))
> > 
> > What's wrong with insert-file-contents-literally?
> 
> Nothing. So many functions...
> 
> > 
> >> +  if (in_memory)
> >> +    i_result = !PlaySound (psz_file_or_data, NULL, SND_MEMORY);
> > 
> > AFAIU, the documentation seems to say that the string passed as the
> > first argument to PlaySound is limited to 256 characters (i.e. bytes)?
> > If so, how do we play longer sounds?
> 
> I think this limitation applies only when the argument points to a 
> string, and not when using SND_MEMORY, which is documented with: "The 
> pszSound parameter points to a sound loaded in memory."
> 
> It's true the documentation doesn't say so, and I haven't found any 
> clarification by Microsoft, but SND_MEMORY would be useless otherwise. 
> Also I see normal usage searching the internet.
> 
> > Should we also use SND_SENTRY flag (on Vista and later)?
> 
> Yes, done in the attached patch.

Thanks, installed on master, and closing the bug.

Subject: 31.0.50; Problems with play-sound on MS-Windows
From: Cecilio Pardo <[email-masked]>
To: [email-masked]
Date: Sat, 14 Dec 2024 00:50:34 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

There are some problems with play-sound, but I didn't find an active bug 
for them. Before working on them I have a couple of questions:

- Is sound playing synchronous on purpose?

- To support :data, we can use the PlaySound function, but we will lose
the ability to play files other than wav. We can maintain the current 
code for files, and use PlaySound for :data. Another option would be to 
simply save data to a temp file and play the file.