QEMU-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: KJ Liew <liewkj@yahoo.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Fixed unknown audio format with SDL2
Date: Thu, 16 Jan 2020 10:27:54 -0800
Message-ID: <E1is9u1-0000BR-Th@eggs.gnu.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 920 bytes --]


SDL2 (version >=2.0) prefers float32 audio format over integer audio format. QEMU sdlaudio.c does not handle any kind of AUDIO_F32 formats, but SDL_OpenAudio(req, obt) will return float32 audio format in obt and QEMU prints error about unknown format 33056 (0x8120).

The following simple patch fix the error by forcing SDL2 internal audio format conversion.

diff -ru ../orig/qemu-4.2.0/audio/sdlaudio.c ../qemu-4.2.0/audio/sdlaudio.c
--- ../orig/qemu-4.2.0/audio/sdlaudio.c 2019-12-12 10:20:47.000000000 -0800
+++ ../qemu-4.2.0/audio/sdlaudio.c      2020-01-15 15:56:25.059841600 -0800
@@ -147,10 +147,11 @@
     }
 #endif

-    status = SDL_OpenAudio (req, obt);
+    status = SDL_OpenAudio (req, NULL);
     if (status) {
         sdl_logerr ("SDL_OpenAudio failed\n");
     }
+    memcpy(obt, req, sizeof(SDL_AudioSpec));

 #ifndef _WIN32
     err = pthread_sigmask (SIG_SETMASK, &old, NULL);

[-- Attachment #2: Type: text/html, Size: 2578 bytes --]

<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:DengXian;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:"\@DengXian";
	panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
.MsoChpDefault
	{mso-style-type:export-only;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style></head><body lang=EN-US><div class=WordSection1><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>SDL2 (version &gt;=2.0) prefers float32 audio format over integer audio format. QEMU sdlaudio.c does not handle any kind of AUDIO_F32 formats, but SDL_OpenAudio(req, obt) will return float32 audio format in obt and QEMU prints error about unknown format 33056 (0x8120).</p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>The following simple patch fix the error by forcing SDL2 internal audio format conversion.</p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>diff -ru ../orig/qemu-4.2.0/audio/sdlaudio.c ../qemu-4.2.0/audio/sdlaudio.c</p><p class=MsoNormal>--- ../orig/qemu-4.2.0/audio/sdlaudio.c 2019-12-12 10:20:47.000000000 -0800</p><p class=MsoNormal>+++ ../qemu-4.2.0/audio/sdlaudio.c      2020-01-15 15:56:25.059841600 -0800</p><p class=MsoNormal>@@ -147,10 +147,11 @@</p><p class=MsoNormal>     }</p><p class=MsoNormal> #endif</p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>-    status = SDL_OpenAudio (req, obt);</p><p class=MsoNormal>+    status = SDL_OpenAudio (req, NULL);</p><p class=MsoNormal>     if (status) {</p><p class=MsoNormal>         sdl_logerr (&quot;SDL_OpenAudio failed\n&quot;);</p><p class=MsoNormal>     }</p><p class=MsoNormal>+    memcpy(obt, req, sizeof(SDL_AudioSpec));</p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal> #ifndef _WIN32</p><p class=MsoNormal>     err = pthread_sigmask (SIG_SETMASK, &amp;old, NULL);</p></div></body></html>

                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1is9u1-0000BR-Th@eggs.gnu.org \
    --to=liewkj@yahoo.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

QEMU-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/qemu-devel/0 qemu-devel/git/0.git
	git clone --mirror https://lore.kernel.org/qemu-devel/1 qemu-devel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 qemu-devel qemu-devel/ https://lore.kernel.org/qemu-devel \
		qemu-devel@nongnu.org
	public-inbox-index qemu-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.nongnu.qemu-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git