Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Coudoin <bcoudoin@src.gnome.org>2006-11-04 20:03:54 (GMT)
committer Bruno Coudoin <bcoudoin@src.gnome.org>2006-11-04 20:03:54 (GMT)
commitc3a6f5abbf48ccef5d291fcda574031289dc9fc5 (patch)
tree9de1a9365098efac95c5e4ba6c50abe8a845770a
parentf835c7d1dde4020c8e5ebecd6eed7c80f6bc9a88 (diff)
Support for autopackage 1.2
* INSTALL: * autopackage/default.apspec.in: Support for autopackage 1.2 * src/boards/clickgame.c: (canvas_event), (clickgame_start), (clickgame_next_level): A little bit speady, patched by Joshua * src/gcompris/gcompris.c: (gc_activation_check), (gc_init): changed the way --database and --create-db work. Now if the file pointed to --database does not exist, it is created. Now if --create-db is given and the base we point to already exist we erase it first and recreate it. * src/gcompris/sdlplayer.c: (sdlplayer_init), (sdlplayer_quit), (sdlplayer_bg), (sdlplayer), (sdlplayer_halt), (sdlplayer_close), (sdlplayer_reopen), (sdlplayer_pause), (sdlplayer_resume): * src/gcompris/soundutil.c: (gc_sound_init), (gc_sound_close), (gc_sound_reopen), (scheduler_bgnd), (thread_play_ogg): * src/gcompris/soundutil.h: Fixed random freeze when unsetting sounds in the config pannel.
-rw-r--r--ChangeLog22
-rw-r--r--INSTALL7
-rw-r--r--autopackage/default.apspec.in2
-rw-r--r--src/boards/clickgame.c22
-rw-r--r--src/gcompris/gcompris.c56
-rw-r--r--src/gcompris/sdlplayer.c46
-rw-r--r--src/gcompris/soundutil.c15
-rw-r--r--src/gcompris/soundutil.h3
8 files changed, 119 insertions, 54 deletions
diff --git a/ChangeLog b/ChangeLog
index 74033b9..bc3ce88 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
2006-11-04 Bruno coudoin <bruno.coudoin@free.fr>
+ * INSTALL:
+ * autopackage/default.apspec.in: Support for autopackage 1.2
+
+ * src/boards/clickgame.c: (canvas_event), (clickgame_start),
+ (clickgame_next_level): A little bit speady, patched by Joshua
+
+ * src/gcompris/gcompris.c: (gc_activation_check), (gc_init):
+ changed the way --database and --create-db work. Now if the
+ file pointed to --database does not exist, it is created.
+ Now if --create-db is given and the base we point to already exist
+ we erase it first and recreate it.
+
+ * src/gcompris/sdlplayer.c: (sdlplayer_init), (sdlplayer_quit),
+ (sdlplayer_bg), (sdlplayer), (sdlplayer_halt), (sdlplayer_close),
+ (sdlplayer_reopen), (sdlplayer_pause), (sdlplayer_resume):
+ * src/gcompris/soundutil.c: (gc_sound_init), (gc_sound_close),
+ (gc_sound_reopen), (scheduler_bgnd), (thread_play_ogg):
+ * src/gcompris/soundutil.h: Fixed random freeze when unsetting
+ sounds in the config pannel.
+
+2006-11-04 Bruno coudoin <bruno.coudoin@free.fr>
+
- Added Somali voices by M. I. Mursal
* boards/sounds/so/alphabet/10.ogg:
diff --git a/INSTALL b/INSTALL
index ab8d657..729be5a 100644
--- a/INSTALL
+++ b/INSTALL
@@ -61,6 +61,13 @@ urpmi libsqlite3_0 libsqlite3_0-devel
urpmi python-sqlite2
urpmi libxxf86vm1-devel
+WARNING
+=======
+ We are using sqlite but it doesn't work on NFS mounted partitions.
+ If you home directory is on a remote server, then use run GCompris
+ with a local file for its database like:
+ gcompris --database=/tmp/gcompris.db
+
Basic Installation
==================
diff --git a/autopackage/default.apspec.in b/autopackage/default.apspec.in
index 05c23aa..6516108 100644
--- a/autopackage/default.apspec.in
+++ b/autopackage/default.apspec.in
@@ -13,6 +13,7 @@ CPUArchitectures: x86
AutopackageTarget: 1.2
License: GNU General Public License (GPL)
PackageFileName: gcompris-$SOFTWAREVERSION.x86.package
+PackageDesktop: share/applications/gcompris.desktop
[BuildPrepare]
# If you're using autotools, the default should be enough.
@@ -49,7 +50,6 @@ installLocale share/locale/
# You probably need to change the category
installMenuItem "Edutainment" share/applications/gcompris.desktop
installMenuItem "Edutainment" share/applications/gcompris-edit.desktop
-PackageDesktop: share/applications/gcompris.desktop
[Uninstall]
# Leaving this at the default is safe unless you use custom commands in
diff --git a/src/boards/clickgame.c b/src/boards/clickgame.c
index a82a648..117aae2 100644
--- a/src/boards/clickgame.c
+++ b/src/boards/clickgame.c
@@ -268,14 +268,14 @@ canvas_event(GnomeCanvas *canvas, GdkEvent *event)
dy = (mouse_y - (y1 + (y2 - y1) / 2)) / ((y2 - y1) / 2);
//printf("dy = %.2f\n", dy);
- if (fabs(dy) > 2) continue;
+ if (fabs(dy) > 3) continue;
dx = (mouse_x - (x1 + (x2 - x1) / 2)) / ((x2 - x1) / 2);
//printf("dx = %.2f\n", dx);
- if (fabs(dx) > 2) continue;
+ if (fabs(dx) > 3) continue;
// 0 to .9
- near = (2.83 - sqrt(dx*dx + dy*dy)) / 3.15;
+ near = (sqrt(2*3*3) - sqrt(dx*dx + dy*dy))/(1.11 * sqrt(2*3*3));
//printf("near = %.2f\n", near);
react = ((rand() % 1000 < near * 1000) +
@@ -422,16 +422,6 @@ static void clickgame_start (GcomprisBoard *agcomprisBoard)
(GtkSignalFunc) canvas_event, 0);
clickgame_next_level();
- {
- int ii;
- for (ii=0; ii < 3; ii++) {
- FishItem *fish = clickgame_create_item();
- if (!fish) continue;
- gnome_canvas_item_move(fish->rootitem,
- fish->speed * (rand() % 200), 0.0);
- }
- }
-
clickgame_pause(FALSE);
}
@@ -520,6 +510,12 @@ static void clickgame_next_level()
gcomprisBoard->sublevel=0;
gc_score_set(gcomprisBoard->sublevel);
+ while (g_list_length (item_list) < 3) {
+ FishItem *fish = clickgame_create_item();
+ if (!fish) break;
+ gnome_canvas_item_move(fish->rootitem,
+ fish->speed * (rand() % 200), 0.0);
+ }
}
diff --git a/src/gcompris/gcompris.c b/src/gcompris/gcompris.c
index 49166e3..656c62a 100644
--- a/src/gcompris/gcompris.c
+++ b/src/gcompris/gcompris.c
@@ -872,19 +872,19 @@ int gc_activation_check(char *code)
value = value >> 3;
crc1 = 0x30 | crc1;
crc2 = 0x30 | (code[2] ^ code[3]);
-
+
crc1 != code[4] ? return(-1);
crc2 != code[5] ? return(-1);
codeddate[3] = 0x30 | value & 0x000F;
value = value >> 4;
-
+
codeddate[2] = 0x30 | value & 0x0001;
value = value >> 1;
-
+
codeddate[1] = 0x30 | value & 0x000F;
value = value >> 4;
-
+
codeddate[0] = 0x30 | value & 0x0003;
codeddate[4] = '\0';
@@ -1598,28 +1598,36 @@ gc_init (int argc, char *argv[])
properties->users_dir,
properties->database);
- if (popt_database){
- if (g_file_test(popt_database, G_FILE_TEST_EXISTS)) {
- if (access(popt_database,R_OK)==-1){
- g_warning("%s exists but is not readable or writable", popt_database);
- exit(0);
- } else {
- g_warning("Using %s as database", popt_database);
- properties->database = g_strdup(popt_database);
- }
- } else if (popt_create_db) {
- gchar *dirname = g_path_get_dirname (popt_database);
- if (access(dirname, W_OK)==-1){
- g_warning("Cannot create %s : %s is not writable !", popt_database, dirname);
- exit (0);
- }
- g_warning("Using %s as database.", popt_database);
+ if (popt_database)
+ {
properties->database = g_strdup(popt_database);
- } else {
- g_warning("Alternate database %s does not exists.\n Use --create-db to force creation !", popt_database);
- exit(0);
+
+ if (g_file_test(properties->database, G_FILE_TEST_EXISTS))
+ {
+ if (access(properties->database, R_OK)==-1)
+ {
+ g_warning("%s exists but is not readable or writable", properties->database);
+ exit(0);
+ }
+ else
+ {
+ g_warning("Using %s as database", properties->database);
+ }
+ }
+ }
+
+ if (popt_create_db)
+ {
+ gchar *dirname = g_path_get_dirname (properties->database);
+ if (access(dirname, W_OK)==-1)
+ {
+ g_warning("Cannot create %s : %s is not writable !", properties->database, dirname);
+ exit (0);
+ }
+ /* We really want to recreate it, erase the old one */
+ g_warning("Removing %s database.", properties->database);
+ unlink(properties->database);
}
- }
if (popt_administration){
if (popt_database){
diff --git a/src/gcompris/sdlplayer.c b/src/gcompris/sdlplayer.c
index f17b56d..d7cbab4 100644
--- a/src/gcompris/sdlplayer.c
+++ b/src/gcompris/sdlplayer.c
@@ -79,7 +79,7 @@ int sdlplayer_init()
// initialize SDL for audio
if(SDL_Init(SDL_INIT_AUDIO)<0)
return(cleanExit("SDL_Init"));
-
+
// initialize sdl mixer, open up the audio device
if(Mix_OpenAudio(44100,MIX_DEFAULT_FORMAT,2,audio_buffers)<0)
return(cleanExit("Mix_OpenAudio"));
@@ -97,10 +97,10 @@ int sdlplayer_init()
int sdlplayer_quit(Mix_Music *music)
{
// free & close
- Mix_FreeMusic(music);
- Mix_CloseAudio();
- g_warning("SDL PLAYER SDL_Quit\n");
- SDL_Quit();
+ Mix_FreeMusic(music);
+ Mix_CloseAudio();
+ g_warning("SDL PLAYER SDL_Quit\n");
+ SDL_Quit();
return 0;
}
@@ -109,15 +109,15 @@ int sdlplayer_bg(char *filename, int volume)
{
Mix_Music *music;
- while (sound_paused)
- SDL_Delay(50);
+ if(sound_paused)
+ return(0);
g_warning("sdlplayer_bg %s\n", filename);
// load the song
if(!(music=Mix_LoadMUS(filename)))
return(cleanExit("Mix_LoadMUS(\"%s\")",filename));
-
+
if(Mix_PlayMusic(music, 1)==-1) {
return(cleanExit("Mix_LoadMUS(0x%p,1)",music));
}
@@ -129,7 +129,7 @@ int sdlplayer_bg(char *filename, int volume)
{
SDL_Delay(50);
}
-
+
return(0);
}
@@ -140,6 +140,9 @@ int sdlplayer(char *filename, int volume)
g_warning("sdlplayer %s\n", filename);
+ if(sound_paused)
+ return(0);
+
Mix_PauseMusic();
sample=Mix_LoadWAV_RW(SDL_RWFromFile(filename, "rb"), 1);
@@ -158,13 +161,13 @@ int sdlplayer(char *filename, int volume)
{
SDL_Delay(50);
}
-
+
// fade in music. Removed, eats too much CPU on low end PCs
/* for(i=32; i<=128; i+=10) { */
/* Mix_VolumeMusic(i); */
/* SDL_Delay(20); */
/* } */
-
+
// resume music playback
if ((!sound_closed) && (!sound_paused))
Mix_ResumeMusic();
@@ -177,23 +180,37 @@ int sdlplayer(char *filename, int volume)
return(0);
}
+
+void sdlplayer_halt()
+{
+ sound_paused = TRUE;
+ sound_closed = TRUE;
+
+ Mix_HaltMusic();
+ Mix_HaltChannel(-1);
+}
+
void sdlplayer_close()
{
+ sound_paused = TRUE;
+ sound_closed = TRUE;
+
Mix_HaltMusic();
- SDL_PauseAudio(1);
+ Mix_HaltChannel(-1);
Mix_CloseAudio();
- sound_closed = TRUE;
}
void sdlplayer_reopen()
{
Mix_OpenAudio(44100,MIX_DEFAULT_FORMAT,2,audio_buffers);
- SDL_PauseAudio(0);
+ Mix_ResumeMusic();
+ Mix_Resume(-1);
sound_closed = FALSE;
sound_paused = FALSE;
}
void sdlplayer_pause(){
Mix_PauseMusic();
+ Mix_Pause(-1);
sound_paused = TRUE;
}
@@ -201,6 +218,7 @@ void sdlplayer_resume(){
// resume music playback
if (!sound_closed){
Mix_ResumeMusic();
+ Mix_Resume(-1);
sound_paused = FALSE;
}
}
diff --git a/src/gcompris/soundutil.c b/src/gcompris/soundutil.c
index 033bb05..57b799e 100644
--- a/src/gcompris/soundutil.c
+++ b/src/gcompris/soundutil.c
@@ -33,6 +33,8 @@ static gboolean sound_closed = FALSE;
/* mutex */
GMutex *lock = NULL;
+GMutex *lock_music = NULL;
+GMutex *lock_fx = NULL;
GCond *cond = NULL;
/* Singleton */
@@ -82,6 +84,8 @@ gc_sound_init()
if (!g_thread_supported ()) g_thread_init (NULL);
lock = g_mutex_new ();
+ lock_music = g_mutex_new ();
+ lock_fx = g_mutex_new ();
cond = g_cond_new ();
sound_policy = PLAY_AFTER_CURRENT;
@@ -109,10 +113,13 @@ gc_sound_close()
{
if ( !sound_closed )
{
- g_mutex_lock(lock);
+ sdlplayer_halt();
+ g_mutex_lock(lock_fx);
+ g_mutex_lock(lock_music);
sdlplayer_close();
sound_closed = TRUE;
}
+ printf("gc_sound_close done\n");
}
void
gc_sound_reopen()
@@ -121,6 +128,7 @@ gc_sound_reopen()
{
sdlplayer_reopen();
g_mutex_unlock(lock);
+ g_mutex_unlock(lock_music);
sound_closed = FALSE;
}
}
@@ -222,10 +230,13 @@ scheduler_bgnd (gpointer user_data)
/* WARNING Displaying stuff in a thread seems to make gcompris unstable */
/* display_ogg_file_credits((char *)g_list_nth_data(musiclist, i)); */
// if(decode_ogg_file((char *)g_list_nth_data(musiclist, i))!=0)
+ g_mutex_lock(lock_music);
if(sdlplayer_bg((char *)g_slist_nth_data(musiclist, i), 128)!=0){
g_warning("Stopping music, sdlplayer_bg failed, try again in 5 seconds");
g_usleep(5000000);
}
+ g_mutex_unlock(lock_music);
+
}
}
@@ -282,7 +293,9 @@ thread_play_ogg (gchar *file)
return NULL;
g_warning(" Calling gcompris internal sdlplayer_file (%s)", absolute_file);
+ g_mutex_lock(lock_fx);
sdlplayer(absolute_file, 128);
+ g_mutex_unlock(lock_fx);
g_signal_emit (gc_sound_controller,
GCOMPRIS_SOUND_GET_CLASS (gc_sound_controller)->sound_played_signal_id,
0 /* details */,
diff --git a/src/gcompris/soundutil.h b/src/gcompris/soundutil.h
index b5fe904..e805ab0 100644
--- a/src/gcompris/soundutil.h
+++ b/src/gcompris/soundutil.h
@@ -54,6 +54,7 @@ void display_ao_devices();
*/
int sdlplayer_init();
int sdlplayer_bg();
+void sdlplayer_halt();
void sdlplayer_close();
void sdlplayer_reopen();
void sdlplayer_pause();
@@ -90,7 +91,7 @@ struct _GcomprisSound {
struct _GcomprisSoundClass {
GObjectClass parent;
-
+
guint sound_played_signal_id;
void (*sound_played) (GcomprisSound *self, gchar *file, gpointer user_data);
};