<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6816097083366448184</id><updated>2011-04-21T18:06:35.995-07:00</updated><title type='text'>一车书</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://godenjan.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6816097083366448184/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://godenjan.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>GodenJan</name><uri>http://www.blogger.com/profile/08104591548312912720</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6816097083366448184.post-183331537756549147</id><published>2007-05-20T00:12:00.002-07:00</published><updated>2007-05-20T00:37:49.095-07:00</updated><title type='text'>ubuntu Edgy升级到Feisty后系统没有声音</title><content type='html'>今天通过cn99的源升级到ubuntu 7.04  Feisty后，进入系统发现通过ALSA驱动不能播放声音，而通过OSS驱动却可以播放，开始以为是ALSA的驱动有问题，所以到ALSA的官方网站，下载最新的驱动把ALSA重装了一遍，结果还是没有声音,用mpalyer播放mp3,提示:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;alsa-lib: confmisc.c:1286:(snd_func_refer) Unable to find definition 'defaults.pcm.dmix.device'&lt;/blockquote&gt;&lt;br /&gt;官方ALSA的安装文档(我的声卡是&lt;a href="http://www.nvidia.com/view.asp?PAGE=nforce" class="external text" title="http://www.nvidia.com/view.asp?PAGE=nforce" rel="nofollow"&gt;nForce&lt;/a&gt;芯片的）:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;a href="http://bugtrack.alsa-project.org/main/index.php/Matrix:Module-intel8x0"&gt;http://bugtrack.alsa-project.org/main/index.php/Matrix:Module-intel8x0&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;只执行了上面文档中的"Quick Install"部分，其它部分感觉复杂没有执行。安装完成后，调用alsaconf配置一下，一路按回车就可以了。&lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;br /&gt;后来重启无意中通过root登录到x windows,发现不管是oss还是alsa驱动，声音都可以正常播放。怀疑可能是我那个用户的alsa配置有问题。&lt;br /&gt;&lt;br /&gt;重新切换到我的用户，在$home目录下发现有一个.asoundrc文件(其实上面的安装文档中有这个文件的说明，开始没注意)，里面有一些对alsa的配置,而root用户的$home下却没有这个文件，把这个文件改为.asoundrc.bak后，重启系统，久违的登录声音又可以听到了。&lt;br /&gt;&lt;br /&gt;.asoundrc文件的作用及配置，可以参考官方的说明，一般来讲，如果能正常播放声音，这个文件不需要修改:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.alsa-project.org/alsa-doc/doc-php/asoundrc.php"&gt;&lt;blockquote&gt;http://www.alsa-project.org/alsa-doc/doc-php/asoundrc.php&lt;/blockquote&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6816097083366448184-183331537756549147?l=godenjan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://godenjan.blogspot.com/feeds/183331537756549147/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6816097083366448184&amp;postID=183331537756549147' title='1 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6816097083366448184/posts/default/183331537756549147'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6816097083366448184/posts/default/183331537756549147'/><link rel='alternate' type='text/html' href='http://godenjan.blogspot.com/2007/05/ubuntu-edgyfeisty.html' title='ubuntu Edgy升级到Feisty后系统没有声音'/><author><name>GodenJan</name><uri>http://www.blogger.com/profile/08104591548312912720</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6816097083366448184.post-7683061624500864646</id><published>2007-05-06T23:11:00.000-07:00</published><updated>2007-05-06T23:25:19.175-07:00</updated><title type='text'>wine QQ运行设置</title><content type='html'>wine安装完成后，需要安装IE，再进行设置后就可以运行QQ&lt;br /&gt;1.安装IE&lt;br /&gt;&lt;pre&gt;&lt;blockquote&gt;wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz&lt;br /&gt;tar zxvf ies4linux-latest.tar.gz&lt;br /&gt;cd ies4linux-*&lt;br /&gt;./ies4linux&lt;/blockquote&gt;&lt;/pre&gt;    参考WIN优化进行一些设置:&lt;br /&gt;    &lt;blockquote&gt;&lt;a href="http://www.dualface.com/blog/?p=419"&gt;http://www.dualface.com/blog/?p=419&lt;/a&gt;&lt;/blockquote&gt;&lt;a href="http://www.dualface.com/blog/?p=419"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;2.&lt;span class="postbody"&gt; 设置qq运行环境&lt;br /&gt;   打开winecfg,在Applications选项页下，添加你的qq,exe 主程序，选择Windows Version为 Winxp，否则登录后错误，提示vxd设备找不到。&lt;br /&gt;&lt;br /&gt;3.设置 riched20.dll&lt;br /&gt;   将windows/system32下的riched20.dll和riched32.dll复制到wine的system32目录下。并&lt;br /&gt;打开winecfg,在libraries选项，添加riched20.dll和riched32.dll并设为native ,否则聊天窗口输入的中文是乱码.&lt;br /&gt;&lt;br /&gt;4.将QQ目录下的 TIMPlatform.exe改为 TIMPlatform.exe.bak，可以加快登录速度。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6816097083366448184-7683061624500864646?l=godenjan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://godenjan.blogspot.com/feeds/7683061624500864646/comments/default' title='帖子评论'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6816097083366448184&amp;postID=7683061624500864646' title='0 条评论'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6816097083366448184/posts/default/7683061624500864646'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6816097083366448184/posts/default/7683061624500864646'/><link rel='alternate' type='text/html' href='http://godenjan.blogspot.com/2007/05/wine-qq.html' title='wine QQ运行设置'/><author><name>GodenJan</name><uri>http://www.blogger.com/profile/08104591548312912720</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6816097083366448184.post-7225042106156606430</id><published>2007-05-06T00:20:00.000-07:00</published><updated>2007-05-06T06:47:26.040-07:00</updated><title type='text'>扩充gstreamer for python功能</title><content type='html'>最近编写一个能播放在线音乐的小工具，使用GStreamer做为播放引擎，前端用Python编写 ,使用了gst-python库，该对是对GStreamer的封装。&lt;br /&gt;由于是播放在线音乐，播放前都有几秒的缓冲，程序将捕捉该事件，实时输出缓冲进度.添加事件回调函数on_message，当缓冲或播放结束等事件发生时，该函数会被调用:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt; self.player = gst.element_factory_make("playbin","player");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; bus = self.player.get_bus();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; bus.add_signal_watch();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; bus.connect('message',self.on_message)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;def on_message(self,bus,message);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  if message.type == gst.MESSAGE_BUFFERING:  #缓冲事件&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;      struct = message.structure;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;      print "\nbuffering(%d)" % &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);font-family:courier new;" &gt;struct.get_int("buffer-percent")&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  esif: #处理其它事件&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;GStreamer在缓冲回调on_message时，将信息保存在message中的structure结构中的，该结构将根据不同的事件保存不同值，而gst-python暂时不提供从structure中取出缓冲进度的功能，所以就对gst-python进行了扩充，即为gst-python添加&lt;span style="color: rgb(51, 51, 255);"&gt;structure.get_int()&lt;/span&gt;方法.&lt;br /&gt;&lt;br /&gt;下载gst-python-0.10.7，修改gststructure.override文件，该文件是处理structure的python封装,添加以下函数:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;%%&lt;br /&gt;override gst_structure_get_int kwargs&lt;br /&gt;static PyObject *&lt;br /&gt;_wrap_gst_structure_get_int(PyGObject *self,PyObject *args,PyObject *kwargs)&lt;br /&gt;{&lt;br /&gt;static char *kwlist[] = { "field" ,NULL };&lt;br /&gt;int ret = -1;&lt;br /&gt;char *field;&lt;br /&gt;if (!PyArg_ParseTupleAndKeywords(args, kwargs,&lt;br /&gt;  "s:GstStructure.get_int",kwlist, &amp;field))&lt;br /&gt; return NULL;&lt;br /&gt;&lt;br /&gt;gst_structure_get_int((GstStructure*)self-&gt;obj,field,(gint *)&amp;ret);&lt;br /&gt;return PyInt_FromLong(ret);&lt;br /&gt;}&lt;br /&gt;%%&lt;/blockquote&gt;&lt;br /&gt;override gst_structure_get_int kwargs&lt;br /&gt;告诉代码生成器生成一个 gst_structure_get_int方法，kwargs告诉生成器该函数支持字典调用。&lt;br /&gt;&lt;br /&gt;当python调用该函数时，所有参数都保存在args中,必须调用PyArg_ParseTupleAndKeywords解析参数:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;if (!PyArg_ParseTupleAndKeywords(args, kwargs,&lt;br /&gt;"s:GstStructure.get_int",kwlist, &amp;field))&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;PyArg_ParseTupleAndKeywords的说明，可以参见:&lt;br /&gt;http://www.python.org/doc/1.5.2p2/ext/parseTupleAndKeywords.html&lt;br /&gt;http://www.python.org/doc/1.5.2p2/ext/parseTuple.html&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;gst_structure_get_int((GstStructure*)self-&gt;obj,field,(gint *)&amp;amp;amp;amp;amp;amp;amp;amp;ret);&lt;/blockquote&gt;&lt;br /&gt;将调用GStreamer的C接口，该方法将查询field的值保存到ret中。gst_structure_get_int的说明，可参见C接口说明:&lt;br /&gt;http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstStructure.html&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;最后调用Make编译gst-python,Make程序会调用代码生成器根据*.override生成gst.c文件。&lt;br /&gt;&lt;br /&gt;代码生成器在gst.c中新增的内容:&lt;br /&gt;&lt;blockquote&gt;static const PyMethodDef _PyGstStructure_methods[] = {&lt;br /&gt;...&lt;br /&gt;{ "get_int", (PyCFunction)_wrap_gst_structure_get_int, METH_VARARGS|METH_KEYWORDS,&lt;br /&gt;NULL },&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;#line 65 "gststructure.override"&lt;br /&gt;static PyObject *&lt;br /&gt;_wrap_gst_structure_get_int(PyGObject *self,PyObject *py_key)&lt;br /&gt;{&lt;br /&gt;  ......&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;_PyGstStructure_methods保存python接口到c接口的映射,代码生成器是根据gst.defs文件生成_PyGstStructure_methods的内容,gst.defs文件已经生成好了，所以我们不必修改。&lt;br /&gt;&lt;br /&gt;其中kwargs将生成上面的METH_KEYWORDS表示支持字典调用.另外在gststructure.override中添加的_wrap_gst_structure_get_int方法也会添加到gst.c中.&lt;br /&gt;&lt;br /&gt;最后make会生成_gst.so文件，通过make install完成安装。&lt;br /&gt;&lt;br /&gt;通过以上修改，就可以向上面例子那个通过调用struct.get_int("buffer-percent")来取得进度值了。&lt;br /&gt;&lt;br /&gt;参考:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ibm.com/developerworks/cn/linux/l-wrap/index.html"&gt;在 Python 中封装 GObject&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www-128.ibm.com/developerworks/cn/linux/l-pythc/index.html"&gt;用C语言扩展Python的功能&lt;/a&gt;&lt;br /&gt;&lt;a href="http://my.opera.com/yjfuk/blog/show.dml/459374"&gt;为python编写c/c++ 的extension&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6816097083366448184-7225042106156606430?l=godenjan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6816097083366448184/posts/default/7225042106156606430'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6816097083366448184/posts/default/7225042106156606430'/><link rel='alternate' type='text/html' href='http://godenjan.blogspot.com/2007/05/gstreamer-for-python.html' title='扩充gstreamer for python功能'/><author><name>GodenJan</name><uri>http://www.blogger.com/profile/08104591548312912720</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>
