Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


#143 SDL_sound support for Win32

Alan LeVee

I have managed to get DOSBox to utilize SDL_sound
support win32. Originally if one tried to do this 3
things would occur:

VS.NET would die explaining that there was a non-
existant function lround() in cdrom_image.cpp. This is
because the mathematical library Microsoft provides
does not contain lround().

VS.NET would die explaining there was an error
containing a ) after :: in cdrom_image.cpp.

VS.NET would die about a linking error due to missing
sdl_sound.lib (due to the fact SDL sound support was
not enabled originally requiring modification of the
Solution file).

I have managed to fix all this and it compiles
beautifully on Visual Studio .NET 2005 Professional
Final. Included is a patch that fixes the 2 code
errors in cdrom_image.cpp that VS.NET does not
understand, however it does not show the modifications
to the solutions file since I converted the one
included with DOSBox to Visual Studio .NET 2005

An example of a successfully built DOSBox from CVS is
at http://www.prometheus-
Installer.msi which includes the new SDL_sound.dll and
built on VS.NET 2005. Enjoy!


  • `Moe`

    Logged In: YES

    Why not just use floor(...+.5) for all platforms? floor is ANSI C. No need to #ifdef anything.

  • Alan LeVee
    Alan LeVee

    Logged In: YES

    This is true, I hadn't thought of it at the time since it
    was a half-arsed patch. I should probably update it anyway
    since Microsoft Visual Studio has to have the includes in
    cdrom_image.cpp funny in order to compile. Proof:

    include <limits.h>

    MSVC 2005 cannot understand this include due to changes in
    the std namespace. Solution fix is this:

    include <limits>

    After which it works perfectly fine.

  • Logged In: YES

    Speaking of which... that reminds me, we should be using
    Sound_GetDuration() instead of trying to seek into the
    sound until it fails.
    At least under Windows, and using MP3 files, SDL_sound
    always succeeds at seeking, and this makes the mounting of
    MP3/CUE files impossible.

    I think the universal and working function should be:

    int CDROM_Interface_Image::AudioFile::getLength()
    int length = Sound_GetDuration(sample);
    return floor((double)length * 176.4f + 0.5f);

    That function works under Windows and also it's a lot
    faster than seeking.