Thursday, November 29, 2007

xbench on my macbook - 105.18

I run xbench on my macbook and got the score 105.18.

Seven steps to write a functioning Makefile

In my opinion, writing a Makefile is not simple, it sometimes can be more complicated if you want to your code compiled with different compilers, different running environments or targets, and different builds to support diffent features. A Makefile can accept shell or sed scripts, it makes the building process more advance. Today, I just want to cover the basic part of Makefile, or the parts I am using for a Makefile.

First define directory variables, you specifies this to tell `make' where is your project?

PROJECT_ROOT_DIR = /devel/src/foo

Second, specify the common compiler settings, most of my time is build for embedded target, so here is the code:

export ARCH :=arm
export CROSS_COMPILE := arm-linux-

# Include make variables (CC, etc...)

3rd, specifies the source code compileing rules, how you compile c++ or c code. The rules will make the later life easier

%.o : %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<

%.o : %.c
$(CC) $(CFLAGS) -c -o $@ $<

Fourth, is more specific compiling setting, you define CFLAGS, CXXFLAGS, or LDFLAGS, so you specify what header directory to include, you specify what library to link, you also specify "-g" for debug, and how you want the compiler post warning message etc.

CFLAGS += -I$(INCLS) -D_FOO_=1 -g

Fiveth, now you can provide the basic feature you want in the Makefile. Here is the sample:

compile: libfoo foo_bin

You want the user use "make compile" for build foo.

Sixth, specifiy all source code you build in seperate directories.

SRCS_FOO = $(SRCS_FOO_DIR)/util_arm.s \
$(SRCS_FOO_DIR)/foo_info.c \
$(SRCS_FOO_DIR)/foo_main.c $(FOO_SRC_DIR)/foo_help.c
OBJS_FOO = $(patsubst %.s,%.o, $(patsubst %.c,%.o, $(SRCS_FOO)))

OBJS_GST = $(SRCS_GST:.c=.o)

Seventh, now weave them together.

libfoo : $(OBJS_FOO) $(OBJS_GST)
$(CC) $(CFLAGS) -shared -o $ $^

For now, the Makefile is done, to add "clean" feature, is quite simple based the content from here.

Wednesday, November 28, 2007


After the close of trading on Tuesday, Marvell Technology's (nasdaq: MRVL - news - people ) reported a third-quarter loss of $6.4 million, or 1 cent per share, compared to a profit of $6 million, or 1 cent per share in the similar period a year ago.

Investors took notice, pushing Marvell's stock down 7.3%, or $1.22, to $15.43, in Wednesday morning trading.

I quote this from here.

What happens to Marvell today, I am not sure, it seems Marvell is sold to another big company, Intel? But any way the cut-off the work force is started, some on-going projects are dead.

Wednesday, November 21, 2007


I am using LaunchBar on my Mac, it is $20 for a single user, but it is worth for the cost, I see spotlight from Leopard can do the same kind of job as LaunchBar does, but I still choose LB on my everyday basis use because LaunchBar is more fast -- Actually I only use Mac at night after work.

Here is a video shows the basic usage of LaunchBar.

Here is my experience, basically I am using LB to launch applications, I can launch application from Finder Application directory, or click an application to run from the Dock but I don't want to a long list of applications in the dock, I want the dock to be simple. so I feel use LB is the best choice for me. The second thing with LB is browse the internet, I found LB remembers well bookmarks of Safari or Firefox, so if I wanna quick goes to the website I have to save the site to bookmarks of my Firefox as an example, otherwise LB will have no way to remember. But I am using delicous a lot, the hard thing for LB is it is not supported to the share society bookmarks, still did not try delicious2Safari (correct me if the name is not correct). There is some other beautiful functions by LB explained on the video, but I did not have a chance to use it.

At last, I think the experience will grows with using LB.

Tuesday, November 13, 2007

script - create package

Today I write a shell script that is used to create project package, so I can backup easily. There are two features I want the script supports, one is have a date stamp automatically generated, second in the source code directory I want to filter only c source code, for instance just have c and h file.

Here is the script:

export PROJECT_NAME=foo
export PROJECT_PATH=/devel/project
export DATESTAMP=`date +%d%b%Y`

tar czf $PROJECT_NAME-$DATESTAMP.tar.gz ./Makefile.arm-linux ./plugin/*.[ch] ./application/*.c

echo "DONE!"

Tuesday, November 6, 2007


I found this site several days ago, then try to download gstreamer from there, but guess what happened, it just contains the core of gstreamer, but without the build of the plugins, it is just a crap, I try to loggin to its forum and can not get into it. I found plugins from, but the plugins did not work with the crap streamer from the site, so I remove the crap and install slacky's gstreamer and it it works.

Today I found the following quote from this site, I recommend any slack user will never go to this site until its construction is ready !!!

** Because of the many false package requests (over 300 were incorrect), I had to clean the requests db table.PLEASE, report ONLY the packages that really have newer versions! If a package doesn't runs for you, check the dependent libraries, and download them. If it still doesn't work, use the forum to tell me what you get and why I should rebuild it. Recently I don't have much time for this site :( **

Monday, November 5, 2007

ALSA and Gstreamer on Linux

First, check alsa in the kernel or not.

/root/wiki/web # cat /proc/asound/cards
0 [AudioPCI ]: ENS1371 - Ensoniq AudioPCI
Ensoniq AudioPCI ENS1371 at 0x1400, irq 18

Second, use amixer to understand your audio device.

~/.gstreamer-0.10 # amixer info
Card default 'AudioPCI'/'Ensoniq AudioPCI ENS1371 at 0x1400, irq 18'
Mixer name : 'Cirrus Logic CS4297A rev 3'
Components : 'AC97a:43525913'
Controls : 24
Simple ctrls : 13

And the controls.

~/.gstreamer-0.10 # amixer controls
numid=1,iface=MIXER,name='Master Playback Switch'
numid=2,iface=MIXER,name='Master Playback Volume'
numid=16,iface=MIXER,name='PCM Playback Switch'
numid=17,iface=MIXER,name='PCM Playback Volume'
numid=8,iface=MIXER,name='Line Playback Switch'
numid=9,iface=MIXER,name='Line Playback Volume'
numid=10,iface=MIXER,name='CD Playback Switch'
numid=11,iface=MIXER,name='CD Playback Volume'
numid=7,iface=MIXER,name='Mic Boost (+20dB)'
numid=5,iface=MIXER,name='Mic Playback Switch'
numid=6,iface=MIXER,name='Mic Playback Volume'
numid=3,iface=MIXER,name='Phone Playback Switch'
numid=4,iface=MIXER,name='Phone Playback Volume'
numid=12,iface=MIXER,name='Video Playback Switch'
numid=13,iface=MIXER,name='Video Playback Volume'
numid=14,iface=MIXER,name='Aux Playback Switch'
numid=15,iface=MIXER,name='Aux Playback Volume'
numid=18,iface=MIXER,name='Capture Source'
numid=19,iface=MIXER,name='Capture Switch'
numid=20,iface=MIXER,name='Capture Volume'
numid=21,iface=MIXER,name='IEC958 Playback Con Mask'
numid=22,iface=MIXER,name='IEC958 Playback Pro Mask'
numid=23,iface=MIXER,name='IEC958 Playback Default'
numid=24,iface=MIXER,name='IEC958 Playback Switch'

Then find out how to change the volume with amixer.

~/.gstreamer-0.10 # amixer cset iface=MIXER,name='Master Playback Volume' 45
numid=2,iface=MIXER,name='Master Playback Volume'
; type=INTEGER,access=rw---,values=2,min=0,max=63,step=0
: values=45,45
~/.gstreamer-0.10 # amixer cget iface=MIXER,name='Master Playback Volume'
numid=2,iface=MIXER,name='Master Playback Volume'
; type=INTEGER,access=rw---,values=2,min=0,max=63,step=0
: values=45,45

Then use aplay to test a stereo wav samples.

~/.gstreamer-0.10 # aplay ~/Desktop/nelly_raw_225.wav

Till now we can say alsa is ok if aplay works. Now let's play with gstreamer.
I am using gstreamer-0.10 it is the current release.

gst-launch-0.10 -v fakesrc num-buffers=8 ! fakesink
gst-launch-0.10 -v audiotestsrc ! audioconvert ! audioresample ! osssink

One import thing is use "gst-inspect | grep -i wavparse" if I want to know wavparse is ready with my gstreamer. Also directly check the xml in "~/.gstreamer-0.10" is acceptable.

Then use gstreamer to play the same wave file.

gst-launch-0.10 filesrc location=~/Desktop/nelly_raw_225.wav !
wavparse ! audioconvert ! audioresample ! osssink

Hopefully gstreamer works.