Thursday, 29 September 2011

Ubuntu 11.04 natty 下安装 qq for linux 失败

  终于闲了下,准备在我的PC上安装个QQ。结果失败:

dpkg: error processing linuxqq_v1.0.2-beta1_i386.deb (--install):
 parsing file '/var/lib/dpkg/tmp.ci/control' near line 7 package 'linuxqq':
 error in Version string 'v1.0.2-beta1': version number does not start with digit
Errors were encountered while processing:
 linuxqq_v1.0.2-beta1_i386.deb

于是google下找到了答案:
原版LinuxQQ下载地址: http://im.qq.com/qq/linux/download.shtml
 
忍不住抱怨下,腾讯,难道你就没有linux工程师了?
 

Monday, 16 May 2011

How to read the source code

  Some workmates talked about how to read the source this afternoon. I found that I don't know how to read the source exactly.
  In my opninion, read source is to know everything of the source. Such as: how a fuction works, why a variable plus one, how to implement an algorithm, and so on. So when I read a source, I chose a part to begin, and from that part, I went into the code as deeply as I could. It took me a lot of time, and also very difficult, but I got a little. Even several days later, I forgot everything totaly.
  I found the following words about how to read source code:
  1. It's boring and hard, so must carry on.
  2. If it's really too difficult, read some related books or documents first. It helps you to know the source code better.
  3. Write down your thinking after reading the source. It's very easy to forget what you get from the source.
  4. Know the priority of every parts. first need, first study.
  5. Know the importance of every parts. some parts need to know the details, while other only need to know the functions.

my thinking after reading Ubuntu Pocket Guide and Reference

It took me sometime to finish reading this book:
Ubuntu Pocket Guide and Reference


It's nice especial for the beginners.

You can download here for free.

How to get your wireless card working under Linux?
“Getting the card to work is simple! Just grab the
source code for the module and compile it against
the kernel. insmod it and then use iwconfig to configure a
WEP password—”

That's why Linux was “for techies only“.
Now it's so easy.

Desktop Linux systems changed everything.
Ubuntu is one of them.
If you can use Windows, you can use Ubuntu.
For it free, safe, faster and ease of use. why not use Linux? 

chapter 1 installation 
Skip, for It's really easy now, just follow the steps.

chapter 2 Configuring Ubuntu 
Every major area of hardware. Make them works.

chapter 3 Getting to grips with the desktop
The basic knowledge to use this desktop.

chapter 4 Users and the filesystem
The purpose of this chapter is tell you the file& folder:
 names, paths, permissions, locations...

chapter 5 Hands‐on at the command‐line
From zero to hero studying Shell/Bash in this chapter. It's great, not too hard, and contain lots of useful commands, suitable for the beginners. I wrote a PPT to introduce bash to the beginners, I felt that PPT is so ugly after I read this chapter. I can get more information from this book to update my PPT when needed. 


chapter 6 Software management
Almost tells the two tools: the Advanced Packaging Tool (APT), and the Debian Package system (dpkg), and use APT or dpkg installing/uninstalling packages.
This chapter also introduces the: software repositories. I only want to say: "change it to get the best download speed!"

chapter 7  Securing the system
This chapter tells you:
How to use  Update Manager to update the system? need it ?
Configuring the firewall.
Need an antivirus program? I don't think so, Linux is much safer than Windows even without an antivirus program.

From this book, I got the name of some books I want to read:

The Pragmatic Programmers -- Ubuntu Kung Fu
www.pragprog.com/titles/ktuk/ubuntu‐kung‐fu
Paper Book ($34.95)
eBook ($22.00) 
too expensive for me...


Free Software Magazine, published in a free PDF
edition roughly every two months and covering matters relating to the
world of Free Software, including but not limited to Linux. www.freesoftwaremagazine.com.

Wednesday, 4 May 2011

Practice Trac on CentOS 5 x86_64

Trac is written in the Python programming language(Open Source)

Python: python-2.4.3-43.el5
Database: SQLite  (python-sqlite-1.1.7-1.2.1)
Version Control System: Subversion  (subversion-1.6.11-7.el5_6.3)
Web Server: Apache (httpd-2.2.3-45.el5.centos)

Creating a Project Environment:
After install, create a new environment using trac-admin: 
#trac-admin /path/to/myproject initenv 
make sure the apache can access project folder
#chown -R apache.apache /path/to/myproject
  
Trac Configuration File:
My <projectenv> /var/trac/test/
The Trac Configuration File: /var/trac/test/conf/trac.ini
Changes to the configuration are usually reflected immediately, though changes to the [components] or [logging] sections will require restarting the web server. You may also need to restart the web server after creating a global configuration file when none was previously present.
See the details of all the sections here.

Install plugins:
Download the source and run "python ./setup.py bdist_egg" and
copy the resulting .egg file from the "dist" directory to the
"plugins" directory of your Trac project.

enable the plugin is done in the [components] section of the configuration file, for example, enable tractoc plugin:

[components]
tractoc.* = enabled

Note: After installing the plugin, you need to restart your web server. 
#sudo /etc/init.d/httpd restart

Friday, 8 April 2011

N900 install NITDroid Gingerbread on SDcard simply

N900 install NITDroid Gingerbread on SDcard simply
   
    I tried to use N900-Autoinstaller here: http://wiki.nitdroid.com/index.php?title=N900-Autoinstaller But failed。
    The guid N900-install here: http://wiki.nitdroid.com/index.php?title=N900-install is outdated, some of the packages can't downloaded.


    I have installed Gingerbread on my N900 with the following steps:

1. Prepare SDcard 

    For this step you need to know the capacity of your SDcard. The Android partition can only be 2GB, so you need to create a FAT partition that is so large there will only be 2GB left. The number must be in MB, example some recommended sizes are 1, 100, 2100, 6100, 14100, 30100. If its 8GB you can choose a number like 6100MB, if its 4GB you can choose a number like 2100MB. If your memory card is 2GB or below, you can choose 1MB as a number. I suggest you use 4GB or bigger.

    Here's an example using 4GB SDcard, use these commands in your N900:

# sudo gainroot
# umount /dev/mmcblk1p1   
# sfdisk -uM /dev/mmcblk1 << EOF
,2100,C
,,L
,,
,,
EOF

2. Install the packages that are needed during the installing

# apt-get install wget bzip2 multiboot multiboot-kernel-maemo

or download these packages and install.
from http://maemo.org/packages/:
wget_1.10.2-2osso3_armel.deb
bzip2_1.0.5-3+0m5_armel.deb
multiboot_0.2.10_armel.deb
multiboot-kernel-maemo_0.3-1_armel.deb


3. Install android filesystem and kernel

# cd /home/user/MyDocs
# wget http://downloads.nitdroid.com/e-yes/gingerbread.tar.bz2
# bzip2 -d gingerbread.tar.bz2
# mkdir -p /and
# mount /dev/mmcblk1p2 /and
# cd /and
# rm -rf *
# tar xvf /home/user/MyDocs/gingerbread.tar

# cd /home/user/MyDocs
# wget http://downloads.nitdroid.com/nitinstaller/Packages/nitdroid-kernel-2.6.28-06_final1_armel.deb
# dpkg -i nitdroid-kernel-2.6.28-06_final1_armel.deb

4. Reboot and enjoy android

# reboot
choose 2 to boot android


5. About this version:
What is working:
- 3D
- GApps
- accelerometer && orientation policies
- lights HAL
- hardware keyboard%)
- sound
- charging, battery status indication
- modem/data, SMS receiving, USSD, calls/signaling
- A2SD
- wi-fi connectivity
- bluetooth

What is NOT working:
- voicecalls (wut do you expect -- mediaserver crashes when ringtone is played?)
- fakegps
- UMS

Saturday, 2 April 2011

SSH to N900

SSH to N900

There's no wireless connection for me to use.
And I want ssh to N900(maemo 5) from my Ubuntu 10.10. 

1. Get N900's root access
    sudo flasher-3.5 -F RX-51_2009SE_20.2010.36-2_PR_COMBINED_MR0_ARM.bin --enable-rd-mode -f -R
    use option '--enable-rd-mode'

2. Download the SSH package form PC
    here to search the package: http://maemo.org/packages/
    openssh-client_5.1p1-6.maemo5_armel.deb
    openssh-common_5.1p1-6.maemo5_armel.deb
    openssh-server_5.1p1-6.maemo5_armel.deb


3. Copy package to N900
    Plug one end of the USB cable on the host and the other end into the N900. The N900 will bring up the mode-selection dialog. Select 'Mass storage mode'.


4. Install SSH server and client
    The packages put in N900 are in this path:
    '/home/user/MyDocs' or 
    '/media/mmc1/'
  
    sudo gainroot
    dpkg -i *.deb

5. Configuration for N900 and PC
    Flow the instruction here: http://wiki.maemo.org/N900_USB_networking

Then can ssh to N900, and more easy to use it. : )

Wednesday, 30 March 2011

又是JAVA

    写在前面的话:本来想一直用英文写这个博客的,但是现在能力有限,还是用中文好了。

    最近迷上了kindle 3,居然发现这个东西的系统还是开源的, 在亚马逊的官网用GPL(GNU General Public License)发布了些源码。下载后,看了一眼,好乱,一堆的压缩包。在网上找了下,没有发现有整理好的版本,看来我自己定做个性化kindle 3系统的愿望暂时不容易实现啊。
    不弄系统了,自己移植个浏览器到kindle 3上也好。到处搜索看看K3的APP是如何开发的。发现kindle 3 是用的linux内核,上层应用程序却是JAVA( Running natively in Java, active content has access to our Whispernet mobile network and Kindle’s large e-ink display.)。这点让我想到了android, 看看android的构架:

为啥这些嵌入式设备上层都用JAVA来实现应用呢? JAVA真的这么好? 可惜我不会JAVA,难道我真的要学JAVA了?
    我看kindle 3源码包里面有个:gtk+-2.16.5.tar.bz2 ,这个说明了什么?kindle 3的应用程序应该能用GTK+写才对,那官方为什么说是JAVA呢?难道这个官方发布的代码是很久以前的版本?

Thursday, 24 March 2011

ContestAppletProd.jnlp error and solve

ContestAppletProd.jnlp error and solve

There are two versions of java in my PC, and the defult one is java-1.5.0-sun.
I want to use java-6-sun because I am using the JAVA application //ContestAppletProd.jnlp//
from the TopCoder.

That's a really interesting web:
http://www.topcoder.com

Choose java 6, but there's error messages.
$update-java-alternatives -l

java-1.5.0-sun 53 /usr/lib/jvm/java-1.5.0-sun
java-6-sun 63 /usr/lib/jvm/java-6-sun

$sudo update-java-alternatives -s java-6-sun

update-alternatives: error: no alternatives for firefox-javaplugin.so.
update-alternatives: error: no alternatives for iceape-javaplugin.so.
update-alternatives: error: no alternatives for iceweasel-javaplugin.so.
update-alternatives: error: no alternatives for midbrowser-javaplugin.so.
update-alternatives: error: no alternatives for mozilla-firefox-javaplugin.so.
update-alternatives: error: no alternatives for mozilla-javaplugin.so.
update-alternatives: error: no alternatives for mozilla-snapshot-javaplugin.so.
update-alternatives: error: no alternatives for xulrunner-1.9-javaplugin.so.
update-alternatives: error: no alternatives for xulrunner-javaplugin.so.
update-alternatives: error: no alternatives for mozilla-javaplugin.so.
update-alternatives: error: no alternatives for xulrunner-1.9-javaplugin.so

Then install the plugins.
$sudo apt-get install sun-java6-plugin
$sudo update-java-alternatives -s java-6-sun

There's also some plugins I can't find.

But I found:

The defult app to open //ContestAppletProd.jnlp// is //Sun Java 5.0 Web Start//.
When I use it there comes out the error message:

com.topcoder.client.ui.UIManagerConfigurationException: The XML configuration for this UI is invalid at line 3 column 85.
at com.topcoder.client.ui.impl.XMLUIManager.create(Unknown Source)
at com.topcoder.client.ui.impl.XMLUIManager.create(Unknown Source)
at com.topcoder.client.contestApplet.ContestApplet.(Unknown Source)
at com.topcoder.client.contestApplet.runner.generic.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at com.sun.javaws.Launcher.executeApplication(Launcher.java:1200)
at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1147)
at com.sun.javaws.Launcher.continueLaunch(Launcher.java:990)
at com.sun.javaws.Launcher.handleApplicationDesc(Launcher.java:519)
at com.sun.javaws.Launcher.handleLaunchFile(Launcher.java:219)
at com.sun.javaws.Launcher.run(Launcher.java:166)
at java.lang.Thread.run(Thread.java:595)
Caused by: com.topcoder.client.ui.UIManagerConfigurationException: The Swing defaults XML configuration is invalid at line 2 column 84.
at com.topcoder.client.ui.impl.XMLUIManager$ConfigurationContentHandler.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:220)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:322)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1693)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
... 15 more
Caused by: com.topcoder.client.ui.UIManagerConfigurationException: The Swing defaults XML configuration is invalid at line 2 column 84.
at com.topcoder.client.ui.impl.xml.swing.XMLSwingDefaults.set(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
... 25 more
Caused by: org.xml.sax.SAXParseException: Unknown element 'scheme'.
at com.topcoder.client.ui.impl.xml.swing.XMLSwingDefaults$SwingDefaultsHandler.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:330)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:779)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1794)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
... 30 more



And I must use the 6.0. After the java 6 installed, then can use the application //Sun Java 6 Web Start//
to open //ContestAppletProd.jnlp//.
all ok.


I can use the app and enjoy the c++ coding.
: )

Sunday, 30 January 2011

Analyse Xingmux Plugin

xingmux adds a Xing header to MP3 files. This contains information about the duration and size
of the file and a seek table and is very useful for getting an almost correct duration and better
seeking on VBR MP3 files.

This element will remove any existing Xing, LAME or VBRI headers from the beginning of the file.

Pad templates and the element details are registered with the plugin during the gst_xing_mux_base_init()

GStreamer uses a type system to ensure that the data passed between elements is in a recognized format

pad templates are registered during the gst_xing_mux_base_init () function. Pads are created from these
templates in the gst_xing_mux_init () function using gst_pad_new_from_template (). The
template can be retrieved from the element class using gst_element_class_get_pad_template()

method 1 and 2 are doing the same, but what's the difference?


1.
GstElementClass *klass = GST_ELEMENT_CLASS (xingmux_class);
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,"sink"), "sink");
gst_pad_new_from_template (gst_element_class_get_pad_template (klass,"src"), "src");

2.
gst_pad_new_from_static_template (&gst_xing_mux_sink_template, "sink");
gst_pad_new_from_static_template (&gst_xing_mux_src_template, "src");

xingmux has a sinkpad and a srcpad, it supports mpeg version 1 audio, layer 1 to 3,
any channel at any samplerate


85 static GstStaticPadTemplate gst_xing_mux_sink_template =                                                                  
86 GST_STATIC_PAD_TEMPLATE ("sink",                                                                                          
87     GST_PAD_SINK,                                                                                                         
88     GST_PAD_ALWAYS,                                                                                                       
89     GST_STATIC_CAPS ("audio/mpeg, "                                                                                       
90         "mpegversion = (int) 1, " "layer = (int) [ 1, 3 ]")); 

initialise the class only once during the gst_xing_mux_class_init()
(specifying what signals, arguments and virtual functions the class has and setting up global state)

The primary and most important way of controlling how an element behaves, is through GObject
properties. GObject properties are defined in the _class_init () function.

gst_xing_mux_init()


  • initialize the new element
  • instantiate pads and add them to element
  • set pad calback functions
  • initialize instance structure

    gst_pad_set_setcaps_function()is called during caps negotiation,
    This is the process where the linked pads decide on the streamtype that will transfer

    Caps negotiation is the process where elements configure themselves and each other for streaming a
    particular media format over their pads.

    between them, here using
    gst_pad_set_setcaps_function (xing->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_setcaps));

    If at all possible, your element should derive from one of the new base classes (Pre-made base classes).
    If you use a base class, you will rarely have to handle state changes yourself. All you have to do is
    override the base class’s start() and stop() virtual functions (might be called differently depending on the
    base class) and the base class will take care of everything for you.

    Do not g_assert for unhandled state changes; this is taken care of by the GstElement base class.

Test Pipeline:gst-launch-0.10 filesrc location=test.mp3 ! xingmux ! filesink location=test2.mp3

additional: function plugin_init() register the element when the plugin is loaded, is in the source file plugin.c under the same folder gst-plugins-ugly/gst/mpegaudioparse

meego play rmvb avi mp4 medio file

My notebook is Asus EeePC 1001px, with meego v1.1
If you can not play the Big_Buck_Bunny.ogv.

Check whether your notebook's hardware graphic acceleration is enabled:
glxinfo | grep "renderer string"
My EeePC output is: "/OpenGL renderer string: Mesa DRI Intel(R) IGD GEM 20100330 DEVELOPMENT x86/MMX/SSE2/ ".
If your output is: "/OpenGL renderer string: Software Rasterizer/", that means acceleration is not fully enabled, your graphics driver might not be capable. Maybe this is the reason that why your notebook can't play video.

For mp3,mp4,avi,rmvb and so on in meego, there's no non-free codecs gstreamer packages form Meego Official site. You can try this command to see the gstreamer related packages.
zypper se gst
In my notebook, there is only gst-plugins-bad-free, but no gst-plugins-bad. We downloaded the gstremer source from Gstreamer Official Website, built and installed to Our EeePC. Then I played non-free types quite smoothly.

Gstreamer Time & Sync

GstClock


Frist some introduce words:

absolute_time: the current time get from GstClock (monotonically increasing time)

running_time:the total time spent in the PLAYING state

base_time:defined as the absolute_time minus the running_time at the time when the pipeline is set to PLAYING

stream_time:the position in the stream(between 0 and the total duration)

GStreamer can use different clocks:


  • system time (with g_get_current_time() and with microsecond accuracy)
  • soundcards and other devices time(better, use get_clock in some elements to get a clock)
  • a network source based on packets received + timestamps in those packets (a typical example is an RTP source)

time is always expessed in nanoseconds, so I think there must have a conversion between different time types.

pipeline state and running_time:

  • NULL/READY, the running_time is undefined
  • PAUSED, the running_time remains at the time when it was last PAUSED
  • PLAYING, the running_time is the delta between the absolute_time and the base time
  • after a flushing seek, the running_time is set to 0(redistribute a new base_time to implement)

    running_time = absolute_time - base_time(In the PLAYING state)

GstBuffer

The GstBuffer timestamps and the preceeding NEW_SEGMENT event define a transformation of the buffer timestamps to running_time

B: GstBuffer

  • B.timestamp = buffer timestamp (GST_BUFFER_TIMESTAMP)

NS: NEWSEGMENT event preceeding the buffers

  • NS.start: start field in the NEWSEGMENT event
  • NS.stop: stop field in the NEWSEGMENT event
  • NS.rate: rate field of NEWSEGMENT event
  • NS.abs_rate: absolute value of rate field of NEWSEGMENT event(By default a pipeline will play from position 0 to
    the total duration of the media at a rate of 1.0)
  • NS.time: time field in the NEWSEGMENT event
  • NS.accum: total accumulated time of all previous NEWSEGMENT events. This field is kept in the GstSegment structure


    if (NS.rate > 0.0)
        B.running_time = (B.timestamp - NS.start) / NS.abs_rate + NS.accum
    else
        B.running_time = (NS.stop - B.timestamp) / NS.abs_rate + NS.accum
    

  • And we also got:

    stream_time = (B.timestamp - NS.start) * NS.abs_applied_rate + NS.time

  • This formula is typically used in sinks to report the current position in
    an accurate and efficient way:

    stream_time = (absolute_time - base_time - NS.accum) * NS.abs_rate * NS.abs_applied_rate + NS.time

Synchronisation

There are two ways to get the running_time:

  • using the clock and the element's base_time with:

    C.running_time = absolute_time - base_time

  • using the buffer timestamp and the preceeding NEWSEGMENT event as (assuming positive playback rate):

    B.running_time = (B.timestamp - NS.start) / NS.abs_rate + NS.accum

  • For synchronisation the following must hold:

    B.running_time = C.running_time

  • expaning:

    B.running_time = absolute_time - base_time

  • or:

    absolute_time = B.running_time + base_time

  • The absolute_time when a buffer with B.running_time should be played is noted with B.sync_time. Thus:

    B.sync_time = B.running_time + base_time

Friday, 21 January 2011

ctags的指定语言类型

今天用ctags看函数的时候,居然跳转到了html文件里面。
然后man了一下,发现:

By  default,  ctags automatically selects the language of a source file, ignoring those files whose language cannot be determined
默认情况ctags会自动设置源码文件的类型

ctags --list-languages
用这个命令看下支持的语言:
Ant
Asm
Asp
Awk
Basic
BETA
C
C++
C#
Cobol
DosBatch
Eiffel
Erlang
Flex
Fortran
HTML
Java
JavaScript
Lisp
Lua
Make
MatLab
OCaml
Pascal
Perl
PHP
Python
REXX
Ruby
Scheme
Sh
SLang
SML
SQL
Tcl
Tex
Vera
Verilog
VHDL
Vim
YACC

这么多语言,看来ctags把C和html都当成源码了

[The  reason  that  .h  extensions  are  mapped  to C++ files rather than C files is because it is common to use .h extensions in C++, and no harm
 results in treating them as C++ files.]
从上面信息发现.h文件属于C++的

所以用下面这命名重新生成tags文件
ctags -R --langmap=C:.c.h --languages=C *

问题搞定,man才是王道

Sunday, 9 January 2011

gstreamer dependencies for plugin mad

configure:24899: *** checking feature: mad mp3 decoder ***
configure:24903: *** for plug-ins: mad ***
configure:24946: checking for ID3TAG
configure:24954: $PKG_CONFIG --exists --print-errors "$which"
Package id3tag was not found in the pkg-config search path.
Perhaps you should add the directory containing `id3tag.pc'
to the PKG_CONFIG_PATH environment variable
No package 'id3tag' found
configure:24957: $? = 1
configure:24972: $PKG_CONFIG --exists --print-errors "$which"
Package id3tag was not found in the pkg-config search path.
Perhaps you should add the directory containing `id3tag.pc'
to the PKG_CONFIG_PATH environment variable
No package 'id3tag' found
configure:24975: $? = 1
No package 'id3tag' found
configure:25003: result: no
configure:25010: No package 'id3tag' found
configure:25036: checking id3tag.h usability
configure:25036: gcc -std=gnu99 -c -g -O2 conftest.c >&5
conftest.c:83: fatal error: id3tag.h: No such file or directory
compilation terminated.

sudo apt-get install libid3tag0-dev

configure:24899: *** checking feature: mad mp3 decoder ***
configure:24903: *** for plug-ins: mad ***
configure:24946: checking for ID3TAG
configure:24954: $PKG_CONFIG --exists --print-errors "$which"
configure:24957: $? = 0
configure:24972: $PKG_CONFIG --exists --print-errors "$which"
configure:24975: $? = 0
configure:25027: result: yes
configure:25096: checking for MAD
configure:25104: $PKG_CONFIG --exists --print-errors "$which"
Package mad was not found in the pkg-config search path.
Perhaps you should add the directory containing `mad.pc'
to the PKG_CONFIG_PATH environment variable
No package 'mad' found
configure:25107: $? = 1
configure:25122: $PKG_CONFIG --exists --print-errors "$which"
Package mad was not found in the pkg-config search path.
Perhaps you should add the directory containing `mad.pc'
to the PKG_CONFIG_PATH environment variable
No package 'mad' found
configure:25125: $? = 1
No package 'mad' found
configure:25153: result: no
configure:25160: No package 'mad' found
configure:25187: checking mad.h usability
configure:25187: gcc -std=gnu99 -c -g -O2 conftest.c >&5
conftest.c:83: fatal error: mad.h: No such file or directory
compilation terminated.

sudo apt-get install libmad0-dev


So do this two commands, you can build plugin mad:
sudo apt-get install libid3tag0-dev
sudo apt-get install libmad0-dev

Wednesday, 5 January 2011

Time in Linux programming

Kernel measures the passage of the time in three different ways:

  1. Wall time ---> measuring absolute time
  2. Process time
  3. Monotonic time ---> calculating relative time

    Unix systems represent absolute time as the number of elapsed seconds since the epoch, which is defined as 00:00:00 UTC on the morning of 1 January 1970.
    SO, even absolute time is, at a low level, relative time.

    The following table shows some useful functions for uing time:
Name second Microsecond Nanosecond
Getting the current time of day time() gettimeofday() clock_gettime()
Setting the current time of day stime() settimeofday() clock_settime()
Sleeping sleep() usleep() nanosleep()

Now Microsoft, ipod nano are in my mind, are these names from here? So interesting.

With a 32-bit long type, time_t will let us have the Y2K mess all over again --- in 2038!

and "Come 22:14:07 on Monday, 18 January 2038, most systems and software will be 64-bit." said Robert Love. Will these happen, let's go and see.

POSIX Clocks have four of the linux standard time source:

  • CLOCK_MONOTONIC
  • CLOCK_PROCESS_CPUTIME_ID
  • CLOCK_REALTIME
  • CLOCK_THREAD_CPUTIME_ID

Tuning the system clock

example by a Makefile

make looks at the file modification timestamps of the source file versus the object file. If the source file is newer than the object file, make rebuilds the source file into an updated object file.If the source file is not newer than the object, however, no action is taken

Tuesday, 4 January 2011

pulseaudio module-detect analyse

source code path:
src/modules/module-detect.c

1. run this function: "int pa__init(pa_module*m)"
"pa_bool_t just_one = FALSE;" allow more than 1 devices

function pa_modargs_new
in "pulsecore/modargs.c".
"modargs.c" analyse the input args, get the args' value such as: "u32, bool, s32..." and store in pa_hashmap list.

for ALSA,OSS,SOLARIS, each has different device node, so the have different codes.
and for WIN32, it does nothing except load module "module-waveout"

There only analyse ALSA.

#ifdef HAVE_ALSA--> use for alsa
2. "detect_alsa" function:

read info from this file "/proc/asound/devices", to get the device info.
("/dev/sndstat", "/proc/sndstat", "/proc/asound/oss/sndstat" these 3 for OSS)
in my PC, the file is:

------------>
2: : timer
3: : sequencer
4: [ 0- 1]: digital audio playback
5: [ 0- 0]: digital audio playback
6: [ 0- 0]: digital audio capture
7: [ 0- 2]: hardware dependent
8: [ 0] : control
<------------

The file above tells that my PC have one control channel, two PCM playback devices (DAC's), a PCM capture device (ADC's), a hardware dependent device, a MIDI sequencer, and a timer.

This function "sscanf(line, " %*i: [%u- %u]: ", &device, &subdevice)" is so insteresting.

3. Use funtion: "pa_module_load()" to load: "module-alsa-sink", "module-alsa-source" the two modules.

The end: unload the "module-detect" itself.

Monday, 3 January 2011

Gstreamer basic Knowledge 2nd

This is my second time to read GStreamer Application Development Manual

Record something important


  • Element:

    Element is an object that can send and/or receive data, also is the most important class of objects in GStreamer
TypeDetailsNumber of pads
Source elementsdo not accept data, only generate dataa source pad
Filters and filter-like elementsoperate the dataat least one input and one output pads
Sink elementsaccept data and do not produce anythinga sink pad
  • Create an element(two methods)
    1. gst_element_factory_make
    2. gst_element_factory_find + gst_element_factory_create

    • gst_init has to be called frist
    • When you don’t need the element anymore, you need to unref it using gst_object_unref ()

      The following example isthe simplest way to create an element using gst_element_factory_make
      #include <gst/gst.h>
      int main (int argc, char *argv[])
      {
      GstElement *element;
      /* init GStreamer */
      gst_init (&argc, &argv);
      /* create element */
      element = gst_element_factory_make ("fakesrc", "source");
      if (!element) {
      g_print ("Failed to create element of type ’fakesrc’\n");
      return -1;
      }
      gst_object_unref (GST_OBJECT (element));
      return 0;
      }

  • Pad:

    Pad is element’s input or output

    A pad can have any of three availabilities:always, sometimes and on request

  • Bin & Pipeline:

    A bin is a container elements

    A pipeline is a special subtype of a bin that allows scheduling of the containing elements

  • Bus:

    A bus is a simple system that takes care of forwarding messages from the pipeline threads to an application in its own thread context

    Every pipeline contains a bus by default

  • Use a bus(two methods)
    1. Run a main loop and attach some kind of watch to the bus using gst_bus_add_watch () or gst_bus_add_signal_watch ()
    2. Get the messages on the bus using gst_bus_peek () and/or gst_bus_poll ()

      Message types:
NameDetails
Error, warning and information notificationsthose are used by elements if a message should be shown to the user about the state of the pipeline
End-of-stream notificationemitted when the stream has ended
Tagsemitted when metadata was found in the stream
State-changesemitted after a successful state change
Bufferingemitted during caching of network-streams
Element messagesthese are special messages that are unique to certain elements and usually represent additional features
Application-specific messagesany information on those can be extracted by getting the message |structure (see above) and reading its fields
  • Buffers & Events:

    The data flowing through a pipeline consists of a combination of buffers and events
    • Buffers contain the actual media data
    • Events contain control information, such as seeking information and end-of-stream notifiers

  • A buffer consists:
NumberNameDescription
1PoniterA pointer to a piece of memory
2SizeThe size of the memory
3TimestampA timestamp for the buffer
4refcountA refcount that indicates how many elements are using this buffer, This refcount will be used to destroy the buffer when no element has a reference to it
5FlagsBuffer flags

Get more information here