Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2002:
[Freeciv-Dev] Re: cygwin audio
Home

[Freeciv-Dev] Re: cygwin audio

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: cygwin audio
From: swamp-dog@xxxxxxxxxxxx (Guy Harrison)
Date: Mon, 10 Jun 2002 17:26:46 GMT

On Sun, 9 Jun 2002 12:59:32 +0200, Andreas Kemnade
<akemnade@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:

>Guy Harrison writes:
> > 
> > Hi Folks,
> > 
> > Anyone else here familiar with CygWin (GTK) FreeCiv compiled for X (ie
> > not MINGW)? I've added a bit of code to audio_winmm.c so that
> > ::sndPlaySound() can find the sound files (failing because it gets a
> > unix path), but it will require an option for 'configure' to allow the
> > user to force "-lwinmm". Perhaps this option already exists and I've
> > missed it. Scripts are not my strongpoint!
> > 
>That option does not exists. Perhaps that can be added after the
>1.13.0 release. 

Understood. This is what I've got atm. It doesn't really want to live in
audio_winmm.c but as FreeCiv/XFree compiles OOTB there's even less
reason to put it anywhere else. Please feel free to use or ignore it as
you see fit. ;-)

I gleamed the test that sets CYG_WANTS_WINMM from 'specs' - I noticed
that '-mnocygwin' has -D__MINGW32__ whereas without it __MINGW32__
remains undefined.

<audio_winmm.c>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <string.h>
#include <assert.h>
#include <windows.h>
#include <mmsystem.h>

/*~~~*/
#if defined(__CYGWIN__) && !defined(__MINGW32__)
#       define CYG_WANTS_WINMM
#endif

#ifdef CYG_WANTS_WINMM
#       include <sys/cygwin.h>
#endif
/*~~~*/

#include "log.h"
#include "fcintl.h"
#include "support.h"
#include "audio.h"

#include "audio_winmm.h"

/*~~~*/
static void
sndPlaySoundWrapper(const char fullpath[], const DWORD flags)
{
 #ifdef CYG_WANTS_WINMM

 const int                      bs
=cygwin_posix_to_win32_path_list_buf_size(fullpath);
 char           *const  bp      =alloca(bs);

 cygwin_conv_to_full_win32_path(fullpath,bp);

 #else

 const char     *const  bp      =fullpath;

 #endif

 sndPlaySound(bp,flags);
}
/*~~~*/

[skip]

static bool play(const char *const tag, const char *const fullpath,
                 bool repeat)
{
  if (!fullpath) {
    return FALSE;
  }
/*~~~*/
  sndPlaySoundWrapper(fullpath, SND_ASYNC | (repeat ? SND_LOOP : 0));
/*~~~*/
  return TRUE;
}
</audio_winmm.c>

I see from the FAQ that CYG_WANTS_WINMM ought to be in config.h also.
That changes things a bit. It may be better if my "configure
--with-winmmm" idea is dropped in favour of a cygwin specific option.
"configure --with-cygwinmm" perhaps. Both CYG_WANTS_WINMM and WINMM can
both be inserted into config.h at the same time.


As for actually enabling it, all I'm doing is hacking the generated
'configure' after the SDL and MINGW tests (approx line 10470) without
any test at all...

    if test x"$MINGW32" = "xyes"; then
    SOUND_LIBS="$SOUND_LIBS -lwinmm"

cat >>confdefs.h <<\_ACEOF
#define WINMM 1
_ACEOF

    WINMM="yes"
  fi

#~~~<hack>
        echo "Forcing -lwinmm"
        SOUND_LIBS="$SOUND_LIBS -lwinmm"

cat >>confdefs.h <<\_ACEOF
#define WINMM 1
_ACEOF

        WINMM="yes"
#~~~</hack>

  gui_sources="gui-$client"
fi

Pathetic - but it's all I can manage in the script department!


-- 
swamp-dog@xxxxxxxxxxxx


[Prev in Thread] Current Thread [Next in Thread]