發表文章

目前顯示的是 8月, 2013的文章

搞不清楚之ubuntu pulseaudio

圖片
先說了,我搞不清楚ubuntu的pulseaudio。 備忘一:如何暫時關掉pulseaudio? A: 網上有人問了也有人答了,見 how-to-temporarily-disable-pulseaudio 個人偏好第二個答案,就是去/etc/pulse/client.conf設定檔,將autospawn=yes改成no,記得前面;是備註的意思,要把它去掉。這樣當我們下指令: $ pulseaudio --kill 把pulseaudio關掉後,pulseaudio就不會再自己自動重新開啟了。 那如果我們想要打開pulseaudio,就下指令: $ pulseaudio --start 狀況一: 使用MAC機器架VirtualBox,裝ubuntu 10.04,暫時關掉pulseaudio,發現aplay還可以正常運作: $ aplay ~/音樂/01\ 慢火車.wav 正在播放 WAVE '/home/ops/音樂/01 慢火車.wav' : Signed 16 bit Little Endian, 速率 44100 Hz, 立體聲 $ aplay -Dhw:0,0 ~/音樂/01\ 慢火車.wav 正在播放 WAVE '/home/ops/音樂/01 慢火車.wav' : Signed 16 bit Little Endian, 速率 44100 Hz, 立體聲 $ aplay -L null     Discard all samples (playback) or generate zero samples (capture) default:CARD=I82801AAICH     Intel 82801AA-ICH, Intel 82801AA-ICH     Default Audio Device front:CARD=I82801AAICH,DEV=0     Intel 82801AA-ICH, Intel 82801AA-ICH     Front speakers surround40:CARD=I82801AAICH,DEV=0     Intel 82801AA-ICH, Intel 82801AA-ICH     4.0 Surround outpu

D-BUS學習筆記

圖片
我第一個看到的文章是 ali's Blog [1] , 其中提到二支程式server.c client.c,我試著去compile這二支程式, 沒什麼太大的問題就可以成功。因為這是所謂的dbus c api, 也就是low lever api,在ubuntu下只要安裝套件libdbus-1-dev, 就會安裝這個api: $ sudo apt-get install libdbus-1-dev 然後就如該文所提到的,在compile時,必須指定library: $ gcc server.c -o server -l dbus-1 此時再去compile程式,可能會發現找不到dbus.h的問題。其實檔案是存在的,只是gcc不知道去那裡找而已。我們只要加入-I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include 告訴gcc就可以了。 $ gcc -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -o server server.c -l dbus-1 如此,可以compile成功。但每次要打這麼多字,實在記不得,也容易打錯,所以使用Makefile吧! 建一個檔案,其名為Makefile,內容如下: All: server client server: server.c   gcc -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -o server server.c -l dbus-1 client: client.c   gcc -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -o client client.c -l dbus-1 我們把server.c client.c Makefile三個檔案,都放在同一個目錄,叫做dbus-test好了。這樣以後只要: $ cd dbus-test $ make 就會正確的編出server client二支可執行的程式。我們也不用去記這些很長的路徑名稱了。用過Makefile的朋友應該看得出來,其實Makefile可以再簡短一些。改成如下: All: server client

Mac下玩vala

雖然vala大都在Linux下玩,但手上有Mac,就會想看看是不是也可以在Mac下玩玩。初步試了一下,應該可以! 1. 使用MacPort安裝vala(所以請先安裝MacPort) $ sudo port install vala 2. 安裝pkg-config $ sudo port install pkgconfig 3. 可以試著寫vala程式了 請參看 Vala_Tutorial class Demo.HelloWorld : GLib.Object {     public static int main(string[] args) {         stdout.printf("Hello, World\n");         return 0;     } } 將以上程式存成 hello.vala 然後到Terminal, 下指令: $ valac hello.vala /Users/ops/vala/hello.vala.c:55:2: warning: 'g_type_init' is deprecated [-Wdeprecated-declarations]         g_type_init ();         ^ /opt/local/include/glib-2.0/gobject/gtype.h:669:23: note: 'g_type_init' declared here void                  g_type_init                    (void);                       ^ 1 warning generated. 好了,雖然有一個警告,不過,目前來說,還不礙事。 同樣在Terminal下, 下指令,執行編譯出來的程式 hello $ ./hello Hello, World 結果是ok的! ========================== 相對地,在ubuntu 13.04下,試了一下,發現只要安裝valac套件就可以: $ sudo apt-get install valac 想來,應該是

What I learn about howto cross compile c source code for ARM CPU on an x86 ubuntu machine

圖片
1. Install the gnu c compiler for ARM (from: cross-compiling-static-c ) $ sudo apt-get install gcc-arm-linux-gnueabi And what do 'eabi' mean? EABI is the new Application Binary Interface (ABI) specification for the ARM Architecture. (from: geekwentfreak ) In short, we can link binaries which compiled by any compilers who follow the EABI specification. 2. Write a simple hello.c program and cross compile it $ arm-linux-gnueabi-gcc hello.c -o hello 3. So, we get a binary file 'hello', which can execute on ARM platform. But, how can we run and test it? Of course, we can copy it to an ARM machine, like Raspberry Pi, Pandaboard, BeagleBoard, and more. But more convenient way is using emulator, so We can do all the job on one machine. Let's install QEMU: (from: cnx-software ) $ sudo apt-get install qemu-kvm qemu-kvm-extras $ qemu-system-arm -version QEMU emulator version 1.2.0 (Debian 1.2.0-2012.09-0ubuntu1), Copyright (c) 2003-2008 Fabrice Bellard Open web