[Freeciv-Dev] (PR#40582) GStreamer audio plugin

2008-11-26 Thread Thijs Vermeir

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40582 

Hello all,

I tried to make a GStreamer audio plugin for Freeciv. It's a work in
progress but it already works well. It's my first contribution so,
please let me know if there are any rules I break.
I'm working on a Linux machine so I didn't test this on other
platforms but because GStreamer can run on all the other supported
platforms it should not be a problem I think.

Gr,
Thijs

---
 client/Makefile.am |   20 -
 client/audio.c |   17 -
 client/audio_gst.c |  180 +
 client/audio_gst.h |   18 +
 configure.ac   |   13 +++
 5 files changed, 240 insertions(+), 8 deletions(-)

--- freeciv.orig/client/Makefile.am
+++ freeciv/client/Makefile.am
@@ -33,11 +33,17 @@
 AUDIO_SDL_FILES=$(ALL_AUDIO_SDL_FILES)
 endif
 
+ALL_AUDIO_GST_FILES=audio_gst.c audio_gst.h
+
+if AUDIO_GST
+AUDIO_GST_FILES=$(ALL_AUDIO_GST_FILES)
+endif
+
 if MINGW32
 CLIENTICON=../win32/clienticon.o
 endif
 
-EXTRA_DIST= $(ALL_AUDIO_SDL_FILES)
+EXTRA_DIST= $(ALL_AUDIO_SDL_FILES) $(ALL_AUDIO_GST_FILES)
 
 ## This is usually false, so include is not recursed into 
 ## by 'make', but it can be enabled in configure, and it is
@@ -53,9 +59,10 @@
 
 bin_PROGRAMS = civclient
 
-AM_CPPFLAGS = -I$(top_srcdir)/utility -I$(srcdir)/include -I$(top_srcdir)/common -I$(top_srcdir)/common/aicore -I$(srcdir)/agents $(CLIENT_CFLAGS) $(SOUND_CFLAGS) $(LIBGGZ_INCLUDES) $(GGZMOD_INCLUDES) $(GGZ_GTK_INCLUDES)
+AM_CPPFLAGS = -I$(top_srcdir)/utility -I$(srcdir)/include -I$(top_srcdir)/common -I$(top_srcdir)/common/aicore -I$(srcdir)/agents $(CLIENT_CFLAGS) $(SOUND_CFLAGS) $(LIBGGZ_INCLUDES) $(GGZMOD_INCLUDES) $(GGZ_GTK_INCLUDES) $(GSTREAMER_CFLAGS)
 
 civclient_SOURCES = $(AUDIO_SDL_FILES) \
+	$(AUDIO_GST_FILES)	\
 	attribute.h	\
 	attribute.c	\
 	citydlg_common.c \
@@ -114,9 +121,9 @@
 	themes_common.h	\
 	tilespec.c	\
 	tilespec.h	\
-	audio.c \
-	audio.h \
-	audio_none.c\
+	audio.c	\
+	audio.h	\
+	audio_none.c	\
 	audio_none.h
 
 # packhand_gen.c  packhand_gen.h are generated files, but as they are
@@ -132,7 +139,8 @@
 		 	$(gui_sources)/libguiclient.a
 civclient_DEPENDENCIES = $(fc_civclient_libs)
 civclient_LDADD= $(fc_civclient_libs) $(fc_civclient_libs) \
-	$(INTLLIBS) $(CLIENT_LIBS) $(SOUND_LIBS) $(LIB_GGZMOD) $(CLIENTICON)
+	$(INTLLIBS) $(CLIENT_LIBS) $(SOUND_LIBS) $(LIB_GGZMOD) $(CLIENTICON) \
+	$(GSTREAMER_LIBS)
 desktopfiledir = $(prefix)/share/applications
 desktopfile_DATA = \
 	freeciv.desktop
--- freeciv.orig/client/audio.c
+++ freeciv/client/audio.c
@@ -29,13 +29,18 @@
 #include support.h
 
 #include audio_none.h
+
+#ifdef AUDIO_GST
+#include audio_gst.h
+#endif
+
 #ifdef AUDIO_SDL
 #include audio_sdl.h
 #endif
 
 #include audio.h
 
-#define MAX_NUM_PLUGINS		2
+#define MAX_NUM_PLUGINS		3
 #define SNDSPEC_SUFFIX		.soundspec
 
 /* keep it open throughout */
@@ -142,6 +147,10 @@
   assert(num_plugins_used == 1);
   selected_plugin = 0;
 
+#ifdef AUDIO_GST
+  audio_gst_init ();
+#endif
+
 #ifdef AUDIO_SDL
   audio_sdl_init();
 #endif
@@ -248,8 +257,12 @@
 return;
   }
 
+#ifdef AUDIO_GST
+  if (audio_select_plugin (gst)) return;
+#endif
+
 #ifdef AUDIO_SDL
-  if (audio_select_plugin(sdl)) return; 
+  if (audio_select_plugin(sdl)) return;
 #endif
   freelog(LOG_NORMAL, _(No real audio subsystem managed to initialize!));
   freelog(LOG_NORMAL,
--- /dev/null
+++ freeciv/client/audio_gst.c
@@ -0,0 +1,180 @@
+/**
+ Freeciv - Copyright (C) 2008 Thijs Vermeir [EMAIL PROTECTED]
+   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 2, 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.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include string.h
+
+#include support.h
+
+#include audio.h
+#include gui_main_g.h
+
+#include audio_gst.h
+
+#include gst/gst.h
+
+static void my_stop(void);
+static void my_wait(void);
+
+GstElement *pipeline;
+GstElement *playbin;
+gchar *last_fullpath;
+GMutex *audio_lock;
+
+static void my_shutdown(void)
+{
+  GstState new_state;
+  GstStateChangeReturn ret;
+
+  gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
+  gst_element_get_state (pipeline, new_state, NULL, GST_CLOCK_TIME_NONE);
+
+  gst_object_unref (pipeline);
+  gst_object_unref (playbin);
+  if (last_fullpath)
+g_free (last_fullpath);
+  if (audio_lock)
+g_mutex_free (audio_lock);
+}
+
+static void my_stop(void)
+{
+  g_mutex_lock (audio_lock);
+  

[Freeciv-Dev] (PR#40479) Connection list does not update when command level changes.

2008-11-26 Thread Madeline Book

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40479 

 [book - Fri Sep 05 22:13:20 2008]:
 
 The connection list in the pregame page does not
 remove the '*' after a player's name when their
 command level changes from 'hack' to something
 less.

Attached patch adds the required connection info
sends to the cmdlevel command.


---
「地球温暖化の所為だろう」と私が答えた。
diff --git a/server/stdinhand.c b/server/stdinhand.c
index 5195a5c..7c10456 100644
--- a/server/stdinhand.c
+++ b/server/stdinhand.c
@@ -1325,6 +1325,7 @@ static bool cmdlevel_command(struct connection *caller, char *str, bool check)
 	cmd_reply(CMD_CMDLEVEL, caller, C_OK,
 		  _(Command access level set to '%s' for connection %s.),
 		  cmdlevel_name(level), pconn-username);
+send_conn_info(pconn-self, NULL);
   } else {
 	cmd_reply(CMD_CMDLEVEL, caller, C_FAIL,
 		  _(Command access level could not be set to '%s' for 
@@ -1373,6 +1374,7 @@ static bool cmdlevel_command(struct connection *caller, char *str, bool check)
   cmd_reply(CMD_CMDLEVEL, caller, C_OK,
 		_(Command access level set to '%s' for connection %s.),
 		cmdlevel_name(level), ptarget-username);
+  send_conn_info(ptarget-self, NULL);
 } else {
   cmd_reply(CMD_CMDLEVEL, caller, C_FAIL,
 		_(Command access level could not be set to '%s'
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40582) GStreamer audio plugin

2008-11-26 Thread Madeline Book

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40582 

 [EMAIL PROTECTED] - Thu Nov 27 00:35:28 2008]:
 
 Hello all,
 
 I tried to make a GStreamer audio plugin for Freeciv. It's a work in
 progress but it already works well. It's my first contribution so,
 please let me know if there are any rules I break.

When compiling with --enable-debug I get the following errors:

audio_gst.c: In function `my_shutdown':
audio_gst.c:40: warning: unused variable `ret'
audio_gst.c: In function `my_play':
audio_gst.c:83: warning: implicit declaration of function `g_strcmp0'

These can be easily fixed (please always use --enable-debug
for testing patches).


When I use the gst plugin and a sound should be played, instead
no sound is produced and I get the following error messages
from the client:

(unknown:18419): GStreamer-CRITICAL **: gst_object_ref: assertion 
`object != NULL' failed

(unknown:18419): GStreamer-CRITICAL **: gst_bin_add: assertion 
`GST_IS_ELEMENT (element)' failed

(unknown:18419): GLib-GObject-CRITICAL **: g_object_set: assertion 
`G_IS_OBJECT (object)' failed

It could be that my system is not setup right for gstreamer
(I had to install gstreamer-0.10.21 from source to get configure
to recognize it). Maybe I need some specific gstreamer plugins
or something?


The style is good, it is just not the freeciv coding style. :)
Check out: http://freeciv.wikia.com/wiki/Coding_Style

If in doubt look at recent patches that were committed and
try to match their style (or just ask if the guide is not
clear).


---
すみません、急いでいるんです。

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40570) [Patch] marine explorers try to violate peace treaties and thus are stoped

2008-11-26 Thread Thomas Kuehne

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40570 

On Monday 24 November 2008, Madeline Book wrote:
  1) it doesn't work for non_allied_unit_tiles that have only
  allied units on them

 I may be mistaken but, do you mean that the explorer can
 move to a tile in territory it cannot enter (by peace
 treaty) if there are allied units on that tile (and
 presumably the owner of those units is allowed to enter
 that territory)?

 As far as I know, allied units cannot be used in this way
 to sneak past borders (but a demonstrating savegame would
 convince me).

You are right, below the situation I was observing - but notice that 
A's units are NonMil...

A and B are at peace.
A and C are allies without map sharing.
B and C aren't at peace.
C's unit - and only C's unit - is on one of B's tiles.
At least A's Engineers and Settlers can access that tile.

  2) fails for units that ignore controll zones (e.g. Diplomats)

 This confuses me, since zones of control (zoc) do not have
 anything to do with allowing units to enter a territory.
 Rather, they prevent non-ally units from moving into tiles
 in each others' zones of control (to summarise crudely).

 Maybe what you mean is that non-military units (unit flag
 NonMil) can enter peaceful territory, while military units
 cannot? So a unit with the non-military flag set to explore
 should consider peaceful territory allowed for the purpose
 of exploration?

Actually Partisans aren't NonMil and still can enter peace tiles.

 Well, if the unit is a diplomat or spy, the other player
 could interpret the move as some kind of provocation, since
 they cannot see the 'X' showing that the unit is just there
 to explore.

 So I'm not sure that allowing the explorer AI to do that is
 such a good idea. I guess it is debatable, and I would
 accept a patch that has this behaviour.

Atleast Explorer should be allowed to auto explore peace tiles.

The really interresting case are diplomatic lanes - see the sea 
lane bug and substitute trimes with diplomats.

  3) explorer_desirable doesn't check no_fights
  4) explorer_desirable fails to handle allied cities

 Hmm, are you sure that explorer_desirable is called
 on tiles for which no_fights returns TB_IGNORE? I mean
 the tiles that are passed into explorer_desirable
 are read from the path finding map which uses no_fights
 already to prune away those tiles, it would seem to me.

If so, this pruning was introduced after the 2.1.6 release (haven't 
checked).

 Well, in any case perhaps best is to make a new tb function
 structured specifically for explorers and put it in
 common/aicore/pf_tools.c. This function should be used in
 ai_fill_unit_param (instead of having to be set after the
 call and clobbering the existing get_TB pointer), and also
 in explorer_desirable (if indeed it is the case that it
 considers tiles that might have to be ignored) so that the
 checking code is not duplicated in more than one place.

Yes.

One problem with the no_fight change is what happens to ai units on a 
tile that just become a peace tile. Can they still move (2.1.6) or 
are they frosen?



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40580) cut command problems

2008-11-26 Thread Madeline Book

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40580 

 [pepeto - Mon Nov 24 22:27:47 2008]:
 
  [book - Mon Nov 24 22:05:02 2008]:
  
  If a connection cuts itself, there is an error in the server:
  
  WARNING: trying to send data to the closed connection
  
  and it becomes impossible to use that connection slot to
  reconnect. The client just waits forever at the connect
  page, presumably because it never gets the packets to telling
  it that it entered the server successfully. Other slots
  are unaffected, so for example users on the server before
  the cut can reconnect, as can other users if someone is
  stuck on the bad connection slot.
 
 See PR#39131.
 
  Also, when a global observer or detached connection is cut,
  the pregame player list is not updated, leaving a ghost
  entry for the cut user.
 
 See PR#39613.

Thanks, I'll use those tickets and base my patches on
the information in them.


---
では、行きます。

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#39613) Left user in client connection list

2008-11-26 Thread Madeline Book

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39613 

 [pepeto - Sat Aug 25 15:15:14 2007]:
 
 When a user which is detached loses connection or leaves, the
 client is not informed of it. The connection is still in the
 visible connection list. I fixed this bug a long time ago for
 warserver by a hack. You should resolve this by a good code.
 
 I added in sernet.c:
 void close_connection(struct connection *pconn)
 {
 [...]
 +  send_conn_info(pconn-self, game.est_connections);
 }

 to be sure the connection will be removed in the client list.
 (send_conn_info(pconn-self, game.est_connections); in 2.0)

This does work, but I think the possible recursion between
the high-level send_conn_info and low-level close_connection
could cause weird problems in special circumstances. :S

Anyway, it would seem to me that this problem is just caused
by a mistake in lost_connection_to_client; it was not updated
when it became necessary to send connection info when a
connection was lost (e.g. for the client's pregame list).

The attached patches for S2_1 and trunk move some stuff around
in that function and appear to fix the problem.


---
光の速度で走って
diff --git a/server/connecthand.c b/server/connecthand.c
index 94ce9d5..910a096 100644
--- a/server/connecthand.c
+++ b/server/connecthand.c
@@ -343,15 +343,15 @@ void lost_connection_to_client(struct connection *pconn)
   notify_conn(game.est_connections, NULL, E_CONNECTION,
 	  _(Lost connection: %s.), desc);
 
+  unattach_connection_from_player(pconn);
+  send_conn_info_remove(pconn-self, game.est_connections);
+  notify_if_first_access_level_is_available();
+
   if (!pplayer) {
 delayed_disconnect--;
 return;
   }
 
-  unattach_connection_from_player(pconn);
-  send_conn_info_remove(pconn-self, game.est_connections);
-  notify_if_first_access_level_is_available();
-
   if (game.info.is_new_game
!pplayer-is_connected /* eg multiple controllers */
!pplayer-ai.control/* eg created AI player */
diff --git a/server/connecthand.c b/server/connecthand.c
index 13d1407..f2630ca 100644
--- a/server/connecthand.c
+++ b/server/connecthand.c
@@ -330,15 +330,15 @@ void lost_connection_to_client(struct connection *pconn)
   notify_conn(game.est_connections, NULL, E_CONNECTION,
 	  _(Lost connection: %s.), desc);
 
+  detach_connection_to_player(pconn, FALSE);
+  send_conn_info_remove(pconn-self, game.est_connections);
+  notify_if_first_access_level_is_available();
+
   if (!pplayer) {
 delayed_disconnect--;
 return;
   }
 
-  detach_connection_to_player(pconn, FALSE);
-  send_conn_info_remove(pconn-self, game.est_connections);
-  notify_if_first_access_level_is_available();
-
   if (game.info.is_new_game
!pplayer-is_connected /* eg multiple controllers */
!pplayer-ai.control/* eg created AI player */
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#39131) Connection troubles

2008-11-26 Thread Madeline Book

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39131 

 [pepeto - Wed Jun 25 11:30:21 2008]:
 
 It actually occurs when the client connection is broken by the server
 whereas the server is reading a packet from. A simple example is when
 you attempt to cut yourself from the server. Then, your chat packet is
 parsed by the server, server breaks your connection and tries to send
 you processing_finished packet.
 
 For an unknown reason by me, the client is not able to recognize
 anymore it is connected to the server after reconnection.
 
 So it seems a double bug between the server and client side.

I traced the bug back to a missing initialization in
common/connection.c. The compression.frozen_level field
was not being cleared for new connections. So if it was
non-zero when a connection was lost, it would cause all
data to be stored into the compression buffer instead of
being sent for new connections.


---
絶やした。
diff --git a/common/connection.c b/common/connection.c
index ded24e4..48fc429 100644
--- a/common/connection.c
+++ b/common/connection.c
@@ -630,6 +630,7 @@ void connection_common_init(struct connection *pconn)
 
 #ifdef USE_COMPRESSION
   byte_vector_init(pconn-compression.queue);
+  pconn-compression.frozen_level = 0;
 #endif
 }
 
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#39131) Connection troubles

2008-11-26 Thread Pepeto

URL: http://bugs.freeciv.org/Ticket/Display.html?id=39131 

Unfortunately, this patch wouldn't remove the useless warning WARNING:
trying to send data to the closed connection.

It needs also to check after command_ok = handle_packet_input(pconn,
packet.data, packet.type); (sernet.c, sniff_packets), if the connection
is still used or not to avoid to continue to send packet to it.


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev