reciteword alsa 版
reciteword 一直使用 esound 发音,网上有 alsa 版,改了一下,使之适用于 gentoo。
echo ‘PORTDIR_OVERLAY=”$PORTDIR_OVERLAY /usr/local/portage”‘ >> /etc/make.conf
mkdir -p /usr/local/portage/app-text/reciteword/files
新建 /usr/local/portage/app-text/reciteword/reciteword-0.8.4.ebuild
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $inherit eutils autotools
DESCRIPTION=”Reciteword is a education software to help people to study English,
reciting english words. It have very beautiful interface, make reciting word
being a interesting things.”
HOMEPAGE=”http://reciteword.cosoft.org.cn/”
SRC_URI=”http://downloads.sourceforge.net/reciteword/${P}.tar.bz2″LICENSE=”GPL-2″
SLOT=”0″
KEYWORDS=”~amd64 ~ppc ~ppc64 ~sparc ~x86″RDEPEND=”>=x11-libs/gtk+-2.6″
src_unpack() {
unpack ${A}
cd “${S}”
EPATCH_SOURCE=”${FILESDIR}” EPATCH_SUFFIX=”patch” EPATCH_FORCE=”yes” epatch
eautoconf
}src_install() {
einstall || die “aborted.”
dodoc README INSTALL COPYING AUTHORS NEWS TODO
}
两个 patch,放在 /usr/local/portage/app-text/reciteword/files 中
— src/sndserv.cpp.orig 2007-11-05 15:10:47.000000000 +0800
+++ src/sndserv.cpp 2008-04-07 16:31:50.000000000 +0800
@@ -1,121 +1,119 @@
-#include “sndserv.h”
-#include “reciteword.h”
-#include <cstdio>
-#include <cstdlib>
-
-#ifdef G_OS_WIN32
- #include “windows.h”
-#else
- #include <esd.h>
-#endif
-
-extern CReciteWord* g_pReciteWord;
-
-CSndserv::CSndserv()
-{
-#ifdef G_OS_WIN32
- canplay = true;
-#else
- fd=esd_open_sound(NULL);//”localhost”;
- canplay = (fd>=0);
-#endif
- if (!canplay)
- g_print(“esd initialization failed,no sound will be play!\n”);
-}
-
-CSndserv::~CSndserv()
-{
-#ifdef G_OS_WIN32
-#else
- if (fd>=0) esd_close(fd);
-#endif
-}
-
-void
-CSndserv::play(const gchar *filename)
-{
-#ifdef G_OS_WIN32
-#else
- if (fd>=0)
- esd_play_file(NULL,filename,0); // ???
- //esd_play_file (“reciteword”, filename, 1);
-#endif
-}
-
-//static CSndserv sndserv;
-
-#ifndef G_OS_WIN32
-static gpointer play_file_mix(gpointer data)
-{
- g_pReciteWord->sndserv.play((gchar *)data);
- g_free(data);
- return NULL;
-}
-#endif
-
-/*
-static void play_file_after_pre(gpointer data,gpointer user_data)
-{
- g_pReciteWord->sndserv.play((gchar *)user_data);
- return NULL;
-}
-
-class CThreadPool
-{
- GThreadPool *pool;
-public:
- CThreadPool();
- ~CThreadPool();
-};
-
-CThreadPool::CThreadPool()
-{
- pool = g_thread_pool_new(play_file_after_pre,NULL,1,FALSE,NULL);
-}
-
-CThreadPool::~CThreadPool()
-{
- g_thread_pool_free(pool,);
-}
-*/
-
-
-void play_file(const char *filename,PLAY_METHOD method)
-{
- if ((!g_pReciteWord->sndserv.canplay)||(g_pReciteWord->sndserv.disable))
- return;
-
- //esd_play_file (“reciteword”, filename, 1); //it can’t return quicklywhen in typing,press wrong key will cause freezing.
-
- // the system() function is inefficiency, should change to use thread to call esd_play_file().
- /*gchar command[256];
- sprintf(command,”esdplay %s &”,filename);
- system(command);*/
-
- //I tried to use gnome_sound_play() without threading, but it is too slow when you type words fast.
-
- switch (method)
- {
- case PM_MIX:
- {
-#ifdef G_OS_WIN32
- PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
-#else
- GThread * thread;
- gchar *dup_filename = g_strdup(filename); //as in the new thread, filename may have already be freeed.
- thread = g_thread_create(play_file_mix,(gpointer)dup_filename,false,NULL); //use GThreadPool may be more efficient.
-#endif
- break;
- }
- case PM_STOP_PRE: // it is hard to done,may need write my own esd_play_file.
- {
- break;
- }
- case PM_AFTER_PRE: // use GThreadPool can do this,but,it does seems very useful before PM_STOP_PRE is done.
- {
- //GThreadPool *threadpool;
-
- break;
- }
- }
-}
+#include “sndserv.h”
+#include “reciteword.h”
+#include <cstdio>
+#include <cstdlib>
+
+#ifdef G_OS_WIN32
+ #include “windows.h”
+
+#endif
+
+extern CReciteWord* g_pReciteWord;
+
+CSndserv::CSndserv()
+{
+#ifdef G_OS_WIN32
+ canplay = true;
+#else
+ //fd=esd_open_sound(NULL);//”localhost”;
+ //canplay = (fd>=0);
+ canplay = true;
+#endif
+ if (!canplay)
+ g_print(“esd initialization failed,no sound will be play!\n”);
+}
+
+CSndserv::~CSndserv()
+{
+#ifdef G_OS_WIN32
+#else
+// if (fd>=0) esd_close(fd);
+#endif
+}
+
+void
+CSndserv::play(const gchar *filename)
+{
+#ifdef G_OS_WIN32
+#else
+// if (fd>=0)
+// esd_play_file(NULL,filename,0); // ???
+// //esd_play_file (“reciteword”, filename, 1);
+#endif
+}
+
+//static CSndserv sndserv;
+
+static gpointer play_file_mix(gpointer data)
+{
+ g_pReciteWord->sndserv.play((gchar *)data);
+ g_free(data);
+ return NULL;
+}
+
+/*
+static void play_file_after_pre(gpointer data,gpointer user_data)
+{
+ g_pReciteWord->sndserv.play((gchar *)user_data);
+ return NULL;
+}
+
+class CThreadPool
+{
+ GThreadPool *pool;
+public:
+ CThreadPool();
+ ~CThreadPool();
+};
+
+CThreadPool::CThreadPool()
+{
+ pool = g_thread_pool_new(play_file_after_pre,NULL,1,FALSE,NULL);
+}
+
+CThreadPool::~CThreadPool()
+{
+ g_thread_pool_free(pool,);
+}
+*/
+
+
+void play_file(const char *filename,PLAY_METHOD method)
+{
+ if ((!g_pReciteWord->sndserv.canplay)||(g_pReciteWord->sndserv.disable))
+ return;
+
+ //esd_play_file (“reciteword”, filename, 1); //it can’t return quicklywhen in typing,press wrong key will cause freezing.
+
+ // the system() function is inefficiency, should change to use thread to call esd_play_file().
+ /*gchar command[256];
+ sprintf(command,”esdplay %s &”,filename);
+ system(command);*/
+
+ switch (method)
+ {
+ case PM_MIX:
+ {
+#ifdef G_OS_WIN32
+ PlaySound(filename, 0, SND_ASYNC | SND_FILENAME);
+#else
+// GThread * thread;
+// gchar *dup_filename = g_strdup(filename); //as in the new thread, filename may have already be freeed.
+// thread = g_thread_create(play_file_mix,(gpointer)dup_filename,false,NULL); //use GThreadPool may be more efficient.
+ gchar *command=g_strdup_printf(“aplay -B 1 %s &”,filename);
+ system(command);
+#endif
+ break;
+ }
+ case PM_STOP_PRE: // it is hard to done,may need write my own esd_play_file.
+ {
+ break;
+ }
+ case PM_AFTER_PRE: // use GThreadPool can do this,but,it does seems very useful before PM_STOP_PRE is done.
+ {
+ //GThreadPool *threadpool;
+
+ break;
+ }
+ }
+}
\ No newline at end of file
— configure.in.orig 2007-11-28 16:03:48.000000000 +0800
+++ configure.in 2008-07-08 12:38:44.000000000 +0800
@@ -32,7 +32,7 @@
dnl
dnl Start of pkg-config checks
dnl
-PKG_CHECK_MODULES(RECITEWORD, gtk+-2.0 >= 2.2.0 gthread-2.0 >= 2.2.0 esound)
+PKG_CHECK_MODULES(RECITEWORD, gtk+-2.0 >= 2.2.0 gthread-2.0 >= 2.2.0)
RECITEWORD_LIBS=”${RECITEWORD_LIBS}”
RECITEWORD_CFLAGS=”\
-Wall \
安装
ebuild reciteword-0.8.4.ebuild digest
emerge reciteword
This entry was posted on Tuesday, July 8th, 2008 at 2:02 pm and is filed under linux, software. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


