[Bug] Win x64 audio static (and other win x64observations)

This is a long one… (sorry for not having diff’s, but some of this is just
pseudo). Also, I understand you don’t currently have developement abilities
for Win x64 and I don’t fully expect you to jump on this right now if you
don’t want to, I’m just trying to help where I can. If you get lost in my
poor explainations, the last to blocks of this message are a generic
summary. I apologize in advance for how poorly I have written this, but I
think all information needed still gets through.

Here’s the related diff, but I don’t see where it would be a problem:
http://www.libsdl.org/cgi/cvsweb.cgi/SDL12/src/audio/windib/SDL_dibaudio.c.diff?r1=1.14&r2=1.15

I assume this is waveout audio, right?

waveout, yes. However, this is not the problem, as I mentioned, a compile
from 2/27 had the static present (I made sure to go back that far because I
saw that patch you just pointed out which wasn’t applied until March 1st).
This appears to have happened either while you were working on getting rid
of c runtimes or the whole SDL_config reorginaztion. When I get more time,
I’ll work on getting it to compile from more timeframes to try and narrow it
down.

I did revert that patch to verify that it does not make the static go away
just in case.

I’d like to see your patch first. I’m leaving casts on data exposed in
the
API to be fixed in 1.3, where we can break binary compatibility. The rest
of
the fixes might apply cleanly to both win32 and win64.

I’m generally leaving WIN32 to refer to windows (should we change it
to
WINDOWS?) and then _WIN32_WCE and _WIN64 are variants on that
platform.

Changing it to WINDOWS would probably be a good idea. A small block for
#ifndef _WIN64 could be placed around SDL_ASSEMBLY_ROUTINES should be the
only thing required assuming the HAVE_LIBC problems will eventually be
resolved.

On a further tangent, will there be non-in-line asm replacements for the
functions made to replace LIBC? As of current, x64 needs HAVE_LIBC 1 and
#undef SDL_ASSEMBLY_ROUTINES, so msvcrt is still needed.

If somebody writes them. :slight_smile: I don’t have an x64 system, so I can’t tell
what needs to be done or test any changes made.

I’ll look to see what I can come up with. Problem for me is I have no
experience with ASM in the first place, which is why I’ve avoided it thus
far. There are often rather simple (though less efficient) C replacements
though. The only problem currently with SDL_ASSEMBLY_ROUTINES undef’d is
SDL_stdlib.c (hence I specifically mentioned LIBC) which only HAVE_LIBC can
get around.

As for LIBC, I left HAVE_LIBC undef’d and bypassed the ASM in SDL_stdlib.c
(knowingly breaking functionality, just to check what problems may exist in
compiling alone) and it is giving unresolved externals for memset and
memcpy, which I can’t figure out as they seem to be set the same as
compiling in win32.

Aside from that, on to castings, I’ll just paste the list of warnings here
and you can decide what you wish to do:

1>…\src\main\win32\SDL_win32_main.c(183) : warning C4267: ‘=’ :
conversion from ‘size_t’ to ‘int’, possible loss of data
1>…\src\main\win32\SDL_win32_main.c(185) : warning C4244: ‘=’ :
conversion from ‘__int64’ to ‘int’, possible loss of data
1>SDLmain - 0 error(s), 2 warning(s)

1>…\src\timer\win32\SDL_systimer.c(191) : warning C4028: formal
parameter 3 different from declaration
1>…\src\timer\win32\SDL_systimer.c(191) : warning C4028: formal
parameter 4 different from declaration
1>…\src\timer\win32\SDL_systimer.c(191) : warning C4028: formal
parameter 5 different from declaration
1>…\src\cdrom\win32\SDL_syscdrom.c(172) : warning C4244: ‘=’ :
conversion from ‘DWORD_PTR’ to ‘int’, possible loss of data
1>…\src\stdlib\SDL_string.c(1193) : warning C4244: ‘return’ : conversion
from ‘__int64’ to ‘int’, possible loss of data
1>…\src\file\SDL_rwops.c(273) : warning C4244: ‘return’ : conversion
from ‘__int64’ to ‘int’, possible loss of data
1>…\src\file\SDL_rwops.c(293) : warning C4267: ‘return’ : conversion
from ‘size_t’ to ‘int’, possible loss of data
1>…\src\file\SDL_rwops.c(298) : warning C4244: ‘=’ : conversion from
’__int64’ to ‘int’, possible loss of data
1>…\src\stdlib\SDL_getenv.c(72) : warning C4267: ‘function’ : conversion
from ‘size_t’ to ‘DWORD’, possible loss of data
1>…\src\stdlib\SDL_getenv.c(83) : warning C4267: ‘function’ : conversion
from ‘size_t’ to ‘DWORD’, possible loss of data
1>…\src\video\windib\SDL_dibevents.c(154) : warning C4244: ‘function’ :
conversion from ‘WPARAM’ to ‘UINT’, possible loss of data
1>…\src\video\windib\SDL_dibevents.c(201) : warning C4244: ‘function’ :
conversion from ‘WPARAM’ to ‘UINT’, possible loss of data
1>SDL - 0 error(s), 12 warning(s)

The only thing that absoletly needs to be changed to avoid errors compiling

  • SDL_lowvideo.h’s WinMessage needs to be updated to LRESULT (to match your
    recent change to SDL_sysevents.c)
  • All instances of GCL_ and GWL_ need to be changed to GCLP_ and GWLP_
    respectively. However, this will cause problems for VC5/6 without platform
    sdk updates (as I believe some of the LONG_PTR / DWORD_PTR stuff you added
    recently do).

If changing to the new LongPointer method is not an option, it can be fixed
with a small bit of work in an #ifdef _WIN64 section in the sdl windows
config (which is what I had done to not get any errors as seen above).

Well, this certainly got dis-organized as I typed it, so I’ll summarize:

  • SDL_lowvideo.h’s WinMessage needs to be updated to LRESULT (to match your
    recent change to SDL_sysevents.c)
  • GCL_ & GWL_ needs to be changed in some form to the LongPointer friendly
    versions
    SDL_ASSEMBLY_ROUTINES must be undef’d

In order for runtime free compilation:

  • memset & memcpy need to be resolved
  • non-in-line asm replacements (as well as a SDL_ASSEMBLY_ROUTINES check)
    need to be added to SDL_stdlib.c

–William

This appears to have happened either while you were working on getting rid
of c runtimes or the whole SDL_config reorginaztion. When I get more time,
I’ll work on getting it to compile from more timeframes to try and narrow it
down.

Thanks, let me know what you find out.

A small block for
#ifndef _WIN64 could be placed around SDL_ASSEMBLY_ROUTINES should be the
only thing required assuming the HAVE_LIBC problems will eventually be
resolved.

I know a bunch of the assembly routines do work on Win64 - do you know which
ones are broken offhand?

1>…\src\main\win32\SDL_win32_main.c(183) : warning C4267: ‘=’ :
conversion from ‘size_t’ to ‘int’, possible loss of data
1>…\src\main\win32\SDL_win32_main.c(185) : warning C4244: ‘=’ :
conversion from ‘__int64’ to ‘int’, possible loss of data
1>SDLmain - 0 error(s), 2 warning(s)

These should be fixed in CVS.

1>…\src\timer\win32\SDL_systimer.c(191) : warning C4028: formal
parameter 3 different from declaration
1>…\src\timer\win32\SDL_systimer.c(191) : warning C4028: formal
parameter 4 different from declaration
1>…\src\timer\win32\SDL_systimer.c(191) : warning C4028: formal
parameter 5 different from declaration

Can you point out what needs to be fixed here?

1>…\src\cdrom\win32\SDL_syscdrom.c(172) : warning C4244: ‘=’ :
conversion from ‘DWORD_PTR’ to ‘int’, possible loss of data
1>…\src\stdlib\SDL_string.c(1193) : warning C4244: ‘return’ : conversion
from ‘__int64’ to ‘int’, possible loss of data
1>…\src\file\SDL_rwops.c(273) : warning C4244: ‘return’ : conversion
from ‘__int64’ to ‘int’, possible loss of data
1>…\src\file\SDL_rwops.c(293) : warning C4267: ‘return’ : conversion
from ‘size_t’ to ‘int’, possible loss of data
1>…\src\file\SDL_rwops.c(298) : warning C4244: ‘=’ : conversion from
’__int64’ to ‘int’, possible loss of data

These are all limitations in the SDL API, to be remedied in 1.3

1>…\src\stdlib\SDL_getenv.c(72) : warning C4267: ‘function’ : conversion
from ‘size_t’ to ‘DWORD’, possible loss of data
1>…\src\stdlib\SDL_getenv.c(83) : warning C4267: ‘function’ : conversion
from ‘size_t’ to ‘DWORD’, possible loss of data

It seems that the Win32 environment variable functions weren’t updated for
Win64 here. The types really should be 64-bit safe, so I wrote the SDL code
correctly. I just added casts to CVS, so this should be okay now.

1>…\src\video\windib\SDL_dibevents.c(154) : warning C4244: ‘function’ :
conversion from ‘WPARAM’ to ‘UINT’, possible loss of data
1>…\src\video\windib\SDL_dibevents.c(201) : warning C4244: ‘function’ :
conversion from ‘WPARAM’ to ‘UINT’, possible loss of data
1>SDL - 0 error(s), 12 warning(s)

This should be fixed in CVS.

The only thing that absoletly needs to be changed to avoid errors compiling

  • SDL_lowvideo.h’s WinMessage needs to be updated to LRESULT (to match your
    recent change to SDL_sysevents.c)
  • All instances of GCL_ and GWL_ need to be changed to GCLP_ and GWLP_
    respectively. However, this will cause problems for VC5/6 without platform
    sdk updates (as I believe some of the LONG_PTR / DWORD_PTR stuff you added
    recently do).

This should be fixed in CVS.

  • SDL_lowvideo.h’s WinMessage needs to be updated to LRESULT (to match your
    recent change to SDL_sysevents.c)
  • GCL_ & GWL_ needs to be changed in some form to the LongPointer friendly
    versions

This should be fixed in CVS.

Can you check these out and make sure they’re taken care of?

Thanks for your help! :slight_smile:

-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

This appears to have happened either while you were working on getting
rid
of c runtimes or the whole SDL_config reorginaztion. When I get more
time,
I’ll work on getting it to compile from more timeframes to try and narrow
it
down.

Thanks, let me know what you find out.

Still haven’t had a chance to do that (you know you made a nice mess in that
libc changing period, right? :wink:
I haven’t had the time to get into digging into this yet, it honestly has me
a bit frightened :slight_smile:
I have since found that it isn’t truely just static, but rather its
distorted so much it sounds like it, but there are basic forms of high and
low tones still.

I know a bunch of the assembly routines do work on Win64 - do you know
which
ones are broken offhand?

http://msdn.microsoft.com/chats/transcripts/windows/windows_111104.aspx
" Q: In an x64 device driver can I have an “_asm” subroutine? Are there
different intrinsics (??) for the AMD64 opcodes versus EMT64 opcodes? Do
both sets come with the DDK?
compilers do not (by design). Asm code for these platforms must reside in a
separate .asm source module. Because the x64 instruction set is so similar
to the x86 instruction set, there is a temptation to “cut-n-paste” x86 code
to x64 and fix it up until it assembles cleanly. The problem here is that
the calling standard is quite different on x64, particularly w.r.t. stack
use and well-formed prologues and epilogues required for proper exception
handling. The x64 calling standard document is included in the SDK and DDK."

I know this is refering to the DDK, but the same is true of the SDK and
VC2005 from what I have seen. It doesn’t take _asm at all, all asm code
must be placed in an .asm file and compiled with ml64 (available in the 2003
SP1 SDK) before compiling the project. It appears Ryan may have more
information on this subject than I?

1>…\src\timer\win32\SDL_systimer.c(191) : warning C4028: formal
parameter 3 different from declaration
1>…\src\timer\win32\SDL_systimer.c(191) : warning C4028: formal
parameter 4 different from declaration
1>…\src\timer\win32\SDL_systimer.c(191) : warning C4028: formal
parameter 5 different from declaration

Can you point out what needs to be fixed here?

That one has me slightly baffeled as well. Casting the last 3 declarations
to what timeSetEvent needs (LPTIMECALLBACK, DWORD_PTR, and UINT
respectively) hush the warnings, but I have no idea what impact that may
have. Why this is spitting warnings in win64 and not win32 is beyond me, as
they appear no different.

1>…\src\stdlib\SDL_getenv.c(72) : warning C4267: ‘function’ :
conversion
from ‘size_t’ to ‘DWORD’, possible loss of data
1>…\src\stdlib\SDL_getenv.c(83) : warning C4267: ‘function’ :
conversion
from ‘size_t’ to ‘DWORD’, possible loss of data

It seems that the Win32 environment variable functions weren’t updated for
Win64 here. The types really should be 64-bit safe, so I wrote the SDL
code
correctly. I just added casts to CVS, so this should be okay now.

Yes, they are now hushed. You are correct, the environement varible
functions were untouched.

And with turning those leaves, we unearth more warnings.
1>…\src\timer\win32\SDL_systimer.c(191) : warning C4028: formal
parameter 3 different from declaration
1>…\src\timer\win32\SDL_systimer.c(191) : warning C4028: formal
parameter 4 different from declaration
1>…\src\timer\win32\SDL_systimer.c(191) : warning C4028: formal
parameter 5 different from declaration

as before, only way to hush them is by casting (as explained above)

1>…\src\video\wincommon\SDL_sysevents.c(565) : warning C4244: ‘=’ :
conversion from ‘LONG_PTR’ to ‘int’, possible loss of data

pretty sure that can just be int casted

1>…\src\cdrom\win32\SDL_syscdrom.c(172) : warning C4244: ‘=’ :
conversion from ‘DWORD_PTR’ to ‘int’, possible loss of data
1>…\src\stdlib\SDL_string.c(1193) : warning C4244: ‘return’ : conversion
from ‘__int64’ to ‘int’, possible loss of data
1>…\src\file\SDL_rwops.c(273) : warning C4244: ‘return’ : conversion
from ‘__int64’ to ‘int’, possible loss of data
1>…\src\file\SDL_rwops.c(293) : warning C4267: ‘return’ : conversion
from ‘size_t’ to ‘int’, possible loss of data
1>…\src\file\SDL_rwops.c(298) : warning C4244: ‘=’ : conversion from
’__int64’ to ‘int’, possible loss of data

As you said, todo for 1.3

1>…\src\video\windx5\SDL_dx5video.c(1126) : warning C4244: ‘=’ :
conversion from ‘LONG_PTR’ to ‘DWORD’, possible loss of data
1>…\src\video\windx5\SDL_dx5video.c(1181) : warning C4244: ‘function’ :
conversion from ‘LONG_PTR’ to ‘DWORD’, possible loss of data
1>…\src\video\windx5\SDL_dx5video.c(1220) : warning C4244: ‘=’ :
conversion from ‘LONG_PTR’ to ‘DWORD’, possible loss of data
1>…\src\video\windx5\SDL_dx5video.c(1267) : warning C4244: ‘function’ :
conversion from ‘LONG_PTR’ to ‘DWORD’, possible loss of data
1>…\src\video\windx5\SDL_dx5video.c(1584) : warning C4244: ‘function’ :
conversion from ‘LONG_PTR’ to ‘DWORD’, possible loss of data
1>…\src\video\windib\SDL_dibvideo.c(650) : warning C4244: ‘=’ :
conversion from ‘LONG_PTR’ to ‘DWORD’, possible loss of data
1>…\src\video\windib\SDL_dibvideo.c(783) : warning C4244: ‘function’ :
conversion from ‘LONG_PTR’ to ‘DWORD’, possible loss of data

These need to be changed back to GetWindowLong

1>…\src\video\windib\SDL_dibevents.c(395) : warning C4244: ‘function’ :
conversion from ‘WPARAM’ to ‘UINT’, possible loss of data

I’m pretty sure this can just be casted to (UINT).

1>SDL - 0 error(s), 17 warning(s)

–WilliamA: While the 32-bit x86 compiler supports inline _asm, the x64 and IA64

I know this is refering to the DDK, but the same is true of the SDK and
VC2005 from what I have seen. It doesn’t take _asm at all, all asm code
must be placed in an .asm file and compiled with ml64 (available in the 2003
SP1 SDK) before compiling the project. It appears Ryan may have more
information on this subject than I?

Thanks for the info, I’ve disabled inline assembly on Win64 for now.

1>…\src\timer\win32\SDL_systimer.c(191) : warning C4028: formal
parameter 3 different from declaration
1>…\src\timer\win32\SDL_systimer.c(191) : warning C4028: formal
parameter 4 different from declaration
1>…\src\timer\win32\SDL_systimer.c(191) : warning C4028: formal
parameter 5 different from declaration

Can you point out what needs to be fixed here?

That one has me slightly baffeled as well. Casting the last 3 declarations
to what timeSetEvent needs (LPTIMECALLBACK, DWORD_PTR, and UINT
respectively) hush the warnings, but I have no idea what impact that may
have. Why this is spitting warnings in win64 and not win32 is beyond me, as
they appear no different.

I fixed the prototype of the callback. I’m not sure why 0 wouldn’t be
DWORD_PTR, is there a way of specifying a constant zero DWORD_PTR? The
TIME_PERIODIC flag is being warned about because it’s defined as a 16 bit
constant. It should be safe to cast, but I’m guessing the Win64 SDK will
be fixed.

1>…\src\video\windib\SDL_dibvideo.c(783) : warning C4244: ‘function’ :
conversion from ‘LONG_PTR’ to ‘DWORD’, possible loss of data

These need to be changed back to GetWindowLong

Fixed.

1>…\src\video\windib\SDL_dibevents.c(395) : warning C4244: ‘function’ :
conversion from ‘WPARAM’ to ‘UINT’, possible loss of data

I’m pretty sure this can just be casted to (UINT).

Fixed in CVS…

Thanks!
-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

One last small patch, appears some stuff slipped through from your first
win64 patch and my local changes streamed in. I refreshed the entire
checkout, and this is what still needs updated (see attached)

As for the audio problem, appears one of my test applications had some
faulty code, I tested loopwave and it works fine.

–William

-------------- next part --------------
A non-text attachment was scrubbed…
Name: sdl12_x64.diff
Type: application/octet-stream
Size: 1309 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060307/250ebda3/attachment.obj

As for the audio problem, appears one of my test applications had some
faulty code, I tested loopwave and it works fine.

Now I’m slightly at a loss… no code change to the other test program, and
it works fine… not that that’s a complaint!

–William

One last small patch, appears some stuff slipped through from your first
win64 patch and my local changes streamed in. I refreshed the entire
checkout, and this is what still needs updated (see attached)

Great, this is in CVS, thanks!

As for the audio problem, appears one of my test applications had some
faulty code, I tested loopwave and it works fine.

Glad to hear it.

-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment