bug-gnubg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: [Bug-gnubg] libcanberra instead of QuickTime


From: Louis Zulli
Subject: Fwd: [Bug-gnubg] libcanberra instead of QuickTime
Date: Fri, 15 Jan 2010 09:43:03 -0500


Oops. Forgot to copy this to the list.

Begin forwarded message:

From: Louis Zulli <address@hidden>
Date: January 15, 2010 6:39:05 AM EST
To: Christian Anthon <address@hidden>
Subject: Re: [Bug-gnubg] libcanberra instead of QuickTime


Hi Christian,

Yes, HAVE_CANBERRA is 1. 

Here's the modified sound.c I used:

/*
 * sound.c from GAIM.
 *
 * Copyright (C) 1998-1999, Mark Spencer <address@hidden>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 or later of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * File modified by Joern Thyssen <address@hidden> for use with
 * GNU Backgammon.
 *
 * $Id: sound.c,v 1.81 2009/09/24 08:01:11 c_anthon Exp $
 */

#include "config.h"
#include <string.h>
#if USE_GTK
#include "gtkgame.h"
#else
#include "backgammon.h"
#include <glib.h>
#endif

#include "sound.h"
#include "util.h"
#include <canberra.h>
#include <canberra-gtk.h>


const char *sound_description[ NUM_SOUNDS ] = {
  N_("Starting GNU Backgammon"),
  N_("Exiting GNU Backgammon"),
  N_("Agree"),
  N_("Doubling"),
  N_("Drop"),
  N_("Chequer movement"),
  N_("Move"),
  N_("Redouble"),
  N_("Resign"),
  N_("Roll"),
  N_("Take"),
  N_("Human fans"),
  N_("Human wins game"),
  N_("Human wins match"),
  N_("Bot fans"),
  N_("Bot wins game"),
  N_("Bot wins match"),
  N_("Analysis is finished")
};

const char *sound_command[ NUM_SOUNDS ] = {
  "start",
  "exit",
  "agree",
  "double",
  "drop",
  "chequer",
  "move",
  "redouble",
  "resign",
  "roll",
  "take",
  "humanfans",
  "humanwinsgame",
  "humanwinsmatch",
  "botfans",
  "botwinsgame",
  "botwinsmatch",
  "analysisfinished"
};

int fSound = TRUE;
int fQuiet = FALSE;
static char *sound_cmd = NULL;

void
playSoundFile (char *file, /*lint -e{715}*/gboolean sync)
{
    GError *error = NULL;
    if (!g_file_test(file, G_FILE_TEST_EXISTS))
    {
            outputf(_("The sound file (%s) doesn't exist.\n"), file);
            return;
    }

    if (sound_cmd && *sound_cmd)
{
char *commandString;

commandString = g_strdup_printf ("%s %s", sound_cmd, file);
if (!g_spawn_command_line_async (commandString, &error))
{
outputf (_("sound command (%s) could not be launched: %s\n"),
commandString, error->message);
g_error_free (error);
}
return;
}

ca_context_play(ca_gtk_context_get(), 0, CA_PROP_MEDIA_FILENAME, file, NULL);

}

extern void playSound(const gnubgsound gs)
{
char *sound;

if (!fSound || fQuiet)
/* no sounds for this user */
return;

sound = GetSoundFile(gs);
if (!*sound) {
g_free(sound);
return;
}
#if USE_GTK
if (!fX || gs == SOUND_EXIT)
playSoundFile(sound, TRUE);
else
playSoundFile(sound, FALSE);
#else
playSoundFile(sound, TRUE);
#endif

g_free(sound);
}


extern void SoundWait( void )
{
if (!fSound)
return;
}

char *sound_file[ NUM_SOUNDS ] = {0};

extern char *GetDefaultSoundFile(gnubgsound sound)
{
  static char aszDefaultSound[ NUM_SOUNDS ][ 80 ] = {
  /* start and exit */
  "fanfare.wav",
  "haere-ra.wav",
  /* commands */
  "drop.wav",
  "double.wav",
  "drop.wav",
  "chequer.wav",
  "move.wav",
  "double.wav",
  "resign.wav",
  "roll.wav",
  "take.wav",
  /* events */
  "dance.wav",
  "gameover.wav",
  "matchover.wav",
  "dance.wav",
  "gameover.wav",
  "matchover.wav",
  "fanfare.wav"
  };

return BuildFilename2("sounds", aszDefaultSound[sound]);
}

extern char *GetSoundFile(gnubgsound sound)
{
if (!sound_file[sound])
return GetDefaultSoundFile(sound);

if (!(*sound_file[sound]))
return g_strdup("");

if (g_file_test(sound_file[sound], G_FILE_TEST_EXISTS))
return g_strdup(sound_file[sound]);

if (g_path_is_absolute(sound_file[sound]))
return GetDefaultSoundFile(sound);

return BuildFilename(sound_file[sound]);
}

extern void SetSoundFile(const gnubgsound sound, const char *file)
{
char *old_file = GetSoundFile(sound);
const char *new_file = file ? file : "";
if (!strcmp(new_file, old_file))
{
g_free(old_file);
return; /* No change */
}
g_free(old_file);

if (!*new_file) {
outputf(_("No sound played for: %s\n"),
gettext(sound_description[sound]));
} else {
outputf(_("Sound for: %s: %s\n"),
gettext(sound_description[sound]),
new_file);
}
g_free(sound_file[sound]);
sound_file[sound] = g_strdup(new_file);
}

extern const char *sound_get_command(void)
{
return (sound_cmd ? sound_cmd : "");
}

extern char *sound_set_command(const char *sz)
{
g_free(sound_cmd);
sound_cmd = g_strdup(sz ? sz : "");
return sound_cmd;
}

extern void SetExitSoundOff(void)
{
sound_file[SOUND_EXIT] = g_strdup("");
}



On Jan 15, 2010, at 6:28 AM, Christian Anthon wrote:

Is HAVE_CANBERRA defined as 1 in config.h? If not, configure doesn't
find libcanberra. If it is, can you send me your modified sound.c. If
that looks right, I guess you have to setup libcanberra in some way,
libcanberra is mainly tested for linux.

Christian.

On Fri, Jan 15, 2010 at 11:50 AM, Louis Zulli <address@hidden> wrote:
I'd like to build a 64-bit gnubg on OS X 10.6.2 Snow Leopard. So I can't use
the QuickTime framework, which isn't 64-bit. I've built all the gnubg
dependencies as 64-bit, including libcanberra (used MacPorts).
What modifications to the gnubg source are needed to use libcanberra instead
of QuickTime? I modified sound.c in what seemed the obvious ways, but I get
no sound at all. Probably missing something easy.
Thanks,
Louis
By the way, this came up before, but I don't know what became of it. From
Mike Petch, I think:

Okay, I have had caffeine and here is the answer to our question (it was in
a
macports thread):

"Quicktime/mov file support is removed due to Carbon QuickTime framework
being 32 bit only. As far as I can gather the only way to fix this without
forcing a 32 bit compile of the library (which would be useless for linking
other 64 bit ports against) would be to re-write the Mac OS specific parts
of the library to use the Cocoa x64 framework equivalents (if possible)."

It makes me wonder if we could build libcanberra with OS/X macports and use
that to play sounds, allowing us to remove all the Apple OS/X
specific sound
code. The other option is the check for 64 Bit OS/X and put ifdefs in for
the Cocoa x64 format. Maybe for the time being just turn sound off?

Clearly this is Snow Leopard and x64 related.

_______________________________________________
Bug-gnubg mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/bug-gnubg





reply via email to

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