ref: here
根據Financial Times網站所 提,Google旗下YouTube視訊網站目前正與好萊塢(Hollywood)電影協商,將於2010年底推展全球按次計費電影點播服務。若所言屬實 的話,那麼很可能創造新的形態。畢竟目前我們絕大多數人觀看新的電影,是以上電影院或是買 / 租 DVD片的方式(當然也有人是以「下載」的形態啦)。此外,也形成了在數位影視內容的發行市場上與蘋果硬碰硬情形,後續發展,值得繼續觀察。
在知道這樣的消息後,除了想到可能創造一個新的看電影形態外,也想到iVideo這個網站服務(說起來,YouTube這樣的方式,才更適合稱得上 iVideo吧)。目前當然沒有更進一步的消息,但若台灣也能有YouTube這樣的電影計次收費服務,iVideo可能會很辛苦吧。
2010年8月30日 星期一
2010年8月24日 星期二
C語言的label
對於C的label 以前都只知道是與goto一起搭配使用, 使用方法如下
{
int a = 1;
int i = 0;
for (i=1; i<10; i++)
{
if ((a % 5) == 0 )
goto exit1;
++a;
}
goto exit2;
exit1:
printf("a = %d\n", a);
return a;
exit2:
printf("a = %d\n", a);
return a;
}
Label就是在程式中的某一段你想要goto到的點插入 "lable:", 然後就可以利用goto label; 來直接跳到那個地方. 不過後來發現還有另外一種宣告label的方式, 可以用來記錄label 的address, 然後可以在任何地方都直接跳到你要的點(需要同一個有效空間)
例子如下
int main(void)
{
__label__ something; // something_1
int foo;
foo=0;
char *ptr1 = &&something; // *ptr 記錄了 something_1的位址, 此時goto *ptr1 == goto something;
printf("%X\n", *ptr1);
goto something;
{
__label__ something; // something_2
char *ptr2 = &&something;
printf("%X\n", *ptr2);
goto something;
something: // something_2
foo++;
}
something: // something_1
return foo;
}
上面例子可以發現, label可以命名相同名字但必須在不同的scope裡面, 如果在內部scope想跳到外部scope的label則可以利用__label__的宣告來事先記錄下該label的address, 如 *ptr1
end.
{
int a = 1;
int i = 0;
for (i=1; i<10; i++)
{
if ((a % 5) == 0 )
goto exit1;
++a;
}
goto exit2;
exit1:
printf("a = %d\n", a);
return a;
exit2:
printf("a = %d\n", a);
return a;
}
Label就是在程式中的某一段你想要goto到的點插入 "lable:", 然後就可以利用goto label; 來直接跳到那個地方. 不過後來發現還有另外一種宣告label的方式, 可以用來記錄label 的address, 然後可以在任何地方都直接跳到你要的點(需要同一個有效空間)
例子如下
int main(void)
{
__label__ something; // something_1
int foo;
foo=0;
char *ptr1 = &&something; // *ptr 記錄了 something_1的位址, 此時goto *ptr1 == goto something;
printf("%X\n", *ptr1);
goto something;
{
__label__ something; // something_2
char *ptr2 = &&something;
printf("%X\n", *ptr2);
goto something;
something: // something_2
foo++;
}
something: // something_1
return foo;
}
上面例子可以發現, label可以命名相同名字但必須在不同的scope裡面, 如果在內部scope想跳到外部scope的label則可以利用__label__的宣告來事先記錄下該label的address, 如 *ptr1
end.
Build openssl for ARM
雖然網路上可以搜尋到很多人提供的方法跟經驗分享,在此我還是紀錄一下我自己的使用經驗
步驟:
1. ./Configure linux-generic32 no-shared --prefix=/path/to/your/prefer/openssl/path
2. 修改Makefile as below
modify CC = /path/to/your/gcc/for/arm
AR = /path/to/your/ar/for/arm
RANLIB = /path/to/your/ranlib/for/arm
3. make
4. (Optional) make install
ps. 如果想要build成static版本, 可以修改Makefile裡面的CFLAGS,加入 -static
After step 3, the openssl executable file will be generated in apps/ folder
之後就可以把openssl copy到 target machine上去執行
步驟:
1. ./Configure linux-generic32 no-shared --prefix=/path/to/your/prefer/openssl/path
2. 修改Makefile as below
modify CC = /path/to/your/gcc/for/arm
AR = /path/to/your/ar/for/arm
RANLIB = /path/to/your/ranlib/for/arm
3. make
4. (Optional) make install
ps. 如果想要build成static版本, 可以修改Makefile裡面的CFLAGS,加入 -static
After step 3, the openssl executable file will be generated in apps/ folder
之後就可以把openssl copy到 target machine上去執行
2010年6月10日 星期四
轉 -如何去寫Android init.rc
參考來源:http://embeddeder.spaces.live.com/blog/cns!8006E36532087D51!160.entry
=
如 何去寫Android init.rc (Android init language)
Android初始化語言由四大類聲明組 成:行為類(Actions),命令類(Commands),服務類(Services),選項類(Options).
* 初始化語言以行為單位,由以空格間隔的語言符號組成。C風格的反斜槓轉義符可以用來插入空白到語言符號。雙引號也可以用來防止文本被空格分成多個語言符 號。當飯斜槓在行末時,作為折行符。
* 以#開始(前面允許有空格)的行為註釋行。
* Actions和Services隱含聲明一個新的段落。所有該段落下Commands或Options的聲明屬於該段落。第一段落前的Commands 或Options被忽略。
* Actions和Services擁有獨一無二的命名。在它們之後聲明相同命名的類將被當作錯誤並忽略。
Actions
-------
Actions 是一系列命令的命名。Actions擁有一個觸發器(trigger)用來決定action何時執行。當一個action在符合觸發條件被執行時,如果它 還沒被加入到待執行隊列中的話,則加入到隊列最後。
隊列中的action依次執行,action中 的命令也依次執行。Init在執行命令的中間處理其他活動(設備創建/銷毀,property設置,進程重啟)。
Actions 表現形式為:
on
Services
--------
Services 是由init啟動,在它們退出時重啟(可選)。Service表現形式為:
service [ ]*
...
Options
-------
Options 是Services的修飾,它們影響init何時、如何運行service.
critical
這是一個設備關鍵服務(device-critical service) .如果它在4分鐘內退出超過4次,設備將重啟並進入恢復模式。
disabled
這個服務的級別將不會自動啟動,它必須被依照服務名指定啟動才可以啟動。
setenv
設置已啟動的進程的環境變量的值
socket [ [ ] ]
創建一個名為/dev/socket/的unix domin socket,並傳送它的fd到已啟動的進程。必須 為"dgram"或"stream".用戶和組默認為0.
user
在執行服務前改變用戶名。當前默認為root.如果你的進程需要linux能力,你不能使用這個命令。你必須在還是root時請求能力,並下降到你需要的 uid.
group [ ]*
在執行服務前改變組。在第一個組後的組將設為進程附加組(通過setgroups()).當前默認為root.
oneshot
在服務退出後不重啟。
class
為service指定一個類別名。同樣類名的所有的服務可以一起啟動或停止。如果沒有指定類別的服務默認為"default"類。
onrestart
當服務重啟時執行一個命令。
Triggers
--------
Triggers(觸發器)是一個字串,可以用來匹配某種類型的事件並執行一個action。
boot
這是當init開始後執行的第一個觸發器(當/init.conf被加載)
當property 被設為指定的值時觸發。
device-added-
device-removed-
當設備節點被添加或移除時觸發。
service-exited-
當指定的服務存在時觸發
Commands
--------
exec [ ]*
Fork並執行一個程序().這將被block直到程序執行完畢。最好避免執行例如內建命令以外的程序,它可能會導致init被阻 塞不動。
export
設定全局環境變量的值, 當這個命令執行後所有的進程都可以取得。
ifup
使網絡接口連 線。
import
解析一個init配置文件,擴展當前配置文件。
hostname
設置主機名
chmod
改變文件訪問權限
chown
改變文件所屬和組
class_start
當指定類別的服務沒有運行,啟動該類別所有的服務。
class_stop
當指定類別的服務正在運行,停止該類別所有的服務。
domainname
設置域名。
insmod
加載該路徑的模塊
mkdir [mode] [owner] [group]
在創 建一個目錄,可選選項:mod,owner,group.如果沒有指定,目錄以755權限,owner為root,group為root創建.
mount [ ]*
嘗試mount 到目錄. 可以用mtd@name格式以命名指定一個mtd塊設備。包 含"ro","rw","remount","noatime".
setkey
暫時沒有
setprop
設置系統property 的值.
setrlimit
設置resource的rlimit.
start
啟動一個沒有運行的服務。
stop
停止一個正在運行的服務。
symlink
創建一個的 符號鏈接到
sysclktz
設置系統時區(GMT為0)
trigger
觸發一個事件。用於調用其他action。
write [ ]*
打開的文件並寫入一個或多個字串。
Properties
----------
Init 會更新一些系統property以提供查看它正在幹嘛。
init.action
當前正在執行的action,如果沒有則為""
init.command
被執行的命令,如果沒有則為""
init.svc.
命名為的服務的狀態("stopped", "running", "restarting")
init.rc 示例:
-----------------
# not complete -- just providing some examples of usage
#
on boot
export PATH /sbin:/system/sbin:/system/bin
export LD_LIBRARY_PATH /system/lib
mkdir /dev
mkdir /proc
mkdir /sys
mount tmpfs tmpfs /dev
mkdir /dev/pts
mkdir /dev/socket
mount devpts devpts /dev/pts
mount proc proc /proc
mount sysfs sysfs /sys
write /proc/cpu/alignment 4
ifup lo
hostname localhost
domainname localhost
mount yaffs2 mtd@system /system
mount yaffs2 mtd@userdata /data
import /system/etc/init.conf
class_start default
service adbd /sbin/adbd
user adb
group adb
service usbd /system/bin/usbd -r
user usbd
group usbd
socket usbd 666
service zygote /system/bin/app_process -Xzygote /system/bin --zygote
socket zygote 666
service runtime /system/bin/runtime
user system
group system
on device-added-/dev/compass
start akmd
on device-removed-/dev/compass
stop akmd
service akmd /sbin/akmd
disabled
user akmd
group akmd
調試
---------------
默 認情況下,init執行的程序輸出的信息和錯誤到/dev/null.為了debug,你可以通過Android程序logwrapper執行你的程序。 這將重定向輸出/錯誤輸出到Android logging系統(通過logcat訪問)。
例如
service akmd /system/bin/logwrapper /sbin/akmd
2010年5月28日 星期五
(轉載)Ubuntu 10.04 換成 sun-java-jdk 的步驟
ref: http://blog.cheyingwu.tw/index.php/2010/05/02/ubuntu-10-04-switch-to-sun-jdk/
話說沒讀 release notes 中地雷的人還蠻多的,我也是其中之一
在 ubuntu 10.04 預設是 openjdk 要換成 sun-java-jdk 也不是很難
首先先要加入 repository
話說沒讀 release notes 中地雷的人還蠻多的,我也是其中之一
在 ubuntu 10.04 預設是 openjdk 要換成 sun-java-jdk 也不是很難
首先先要加入 repository
=========================================
順道一題,由於想要在ubuntu上安裝android的開發套件
所以需要安裝eclipse and ADT
之前第一次安裝的ubuntu是32位元版,沒碰到什麽問題
後來第二次安裝ubuntu時選擇安裝64位元版本, 結果在安裝ADT確遇到問題了(這邊有提供解法 http://developer.android.com/sdk/installing.html#troubleshooting)
為了省去麻煩, 建議還是安裝32位元版的ubuntu就好
不然後續可能要多作一些額外處理才能正常使用android開發環境
補充:要安裝Android開發套件,安裝完eclipse之後還要確定有安裝Eclipse Java development tools (JDT), 之後才能安裝ADT
話說沒讀 release notes 中地雷的人還蠻多的,我也是其中之一
在 ubuntu 10.04 預設是 openjdk 要換成 sun-java-jdk 也不是很難
首先先要加入 repository
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"然後安裝 sun-jdk
sudo apt-get update然後手動切換成 sun-jdk
sudo apt-get install sun-java6-jdk sun-java6-plugin
sudo update-java-alternatives -s java-6-sun這樣就可以換成 sun-jdk 了
話說沒讀 release notes 中地雷的人還蠻多的,我也是其中之一
在 ubuntu 10.04 預設是 openjdk 要換成 sun-java-jdk 也不是很難
首先先要加入 repository
sudo add-apt-repository 『deb http://archive.canonical.com/ lucid partner』然後安裝 sun-jdk
sudo apt-get update然後手動切換成 sun-jdk
sudo apt-get install sun-java6-jdk sun-java6-plugin
sudo update-java-alternatives -s java-6-sun這樣就可以換成 sun-jdk 了
=========================================
順道一題,由於想要在ubuntu上安裝android的開發套件
所以需要安裝eclipse and ADT
之前第一次安裝的ubuntu是32位元版,沒碰到什麽問題
後來第二次安裝ubuntu時選擇安裝64位元版本, 結果在安裝ADT確遇到問題了(這邊有提供解法 http://developer.android.com/sdk/installing.html#troubleshooting)
為了省去麻煩, 建議還是安裝32位元版的ubuntu就好
不然後續可能要多作一些額外處理才能正常使用android開發環境
補充:要安裝Android開發套件,安裝完eclipse之後還要確定有安裝Eclipse Java development tools (JDT), 之後才能安裝ADT
2010年5月27日 星期四
Thinkpad Trackpoint Scrolling in ubuntu 10.04
轉錄 (http://psung.blogspot.com/2010/04/thinkpad-trackpoint-scrolling-in-ubuntu.html)
Thinkpad TrackPoint Scrolling in Ubuntu Lucid/10.04
Another Ubuntu release, another set of X.org shakeups.
Some things in X changed in Lucid (xorg 1:7.5+5 and higher), breaking existing Thinkpad TrackPoint scrolling configurations that modify files in /etc/hal/fdi/policy (like those you may have seen in this previous post). You can use gpointing-device-settings to apply the same policy, but I found that even that stops working after a suspend/resume cycle.
Samson Yeung pointed out to me the following fix which can be applied on Ubuntu Lucid/10.04:
Create a new file /usr/lib/X11/xorg.conf.d/20-thinkpad.conf with the following contents:
This configuration seems to be general enough that it works for both Thinkpad laptops with TrackPoints and the Thinkpad TrackPoint keyboard.
Source: instructions derived from these instructions by Samson Yeung. Thanks, Samson!
Some things in X changed in Lucid (xorg 1:7.5+5 and higher), breaking existing Thinkpad TrackPoint scrolling configurations that modify files in /etc/hal/fdi/policy (like those you may have seen in this previous post). You can use gpointing-device-settings to apply the same policy, but I found that even that stops working after a suspend/resume cycle.
Samson Yeung pointed out to me the following fix which can be applied on Ubuntu Lucid/10.04:
Create a new file /usr/lib/X11/xorg.conf.d/20-thinkpad.conf with the following contents:
Section "InputClass"
Identifier "Trackpoint Wheel Emulation"
MatchProduct "TrackPoint"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
Option "EmulateWheel" "true"
Option "EmulateWheelButton" "2"
Option "Emulate3Buttons" "false"
Option "XAxisMapping" "6 7"
Option "YAxisMapping" "4 5"
EndSectionThen restart X.This configuration seems to be general enough that it works for both Thinkpad laptops with TrackPoints and the Thinkpad TrackPoint keyboard.
Source: instructions derived from these instructions by Samson Yeung. Thanks, Samson!
2010年5月26日 星期三
mplayer video out driver (轉載)
在很多應用中的圖形輸出數據是存放在一些指定的內存區域的,比如說我現在實現的基於 minigui圖形中間件的mplayer播放器的,在播放前需要告訴mplayer當前播放窗口所在的內存地址和當前的屏幕像素深度,bpp,窗口大小等 等一系列的信息,這就有必要給mplayer寫個自己的video_out driver了。和大 多數驅動一樣,mplayer也提供了一個驅動函數結構體,其結構體定義如下(在libvo/video_out.h文件中定義):
typedef struct vo_functions_s{
vo_info_t *info;
/*
* Preinitializes driver (real INITIALIZATION)
* arg - currently it's vo_subdevice
* returns: zero on successful initialization, non-zero on error.
*/
int (*preinit)(const char *arg);
/*
* Initialize (means CONFIGURE) the display driver.
* params:
* width,height: image source size
* d_width,d_height: size of the requested window size, just a hint
* fullscreen: flag, 0=windowd 1=fullscreen, just a hint
* title: window title, if available
* format: fourcc of pixel format
* returns : zero on successful initialization, non-zero on error.
*/
int (*config)(uint32_t width, uint32_t height, uint32_t d_width,
uint32_t d_height, uint32_t fullscreen, char *title,
uint32_t format);
/*
* Control interface
*/
int (*control)(uint32_t request, void *data, ...);
/*
* Display a new RGB/BGR frame of the video to the screen.
* params:
* src[0] - pointer to the image
*/
int (*draw_frame)(uint8_t *src[]);
/*
* Draw a planar YUV slice to the buffer:
* params:
* src[3] = source image planes (Y,U,V)
* stride[3] = source image planes line widths (in bytes)
* w,h = width*height of area to be copied (in Y pixels)
* x,y = position at the destination image (in Y pixels)
*/
int (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
/*
* Draws OSD to the screen buffer
*/
void (*draw_osd)(void);
/*
* Blit/Flip buffer to the screen. Must be called after each frame!
*/
void (*flip_page)(void);
/*
* This func is called after every frames to handle keyboard and
* other events. It's called in PAUSE mode too!
*/
void (*check_events)(void);
/*
* Closes driver. Should restore the original state of the system.
*/
void (*uninit)(void);
} vo_functions_t;
1:初始化驅動(preinit 函數、config函數和uninit 函數):當驅動初始化時將調用preinit ,退出時則調用uninit函數(注意:播放器在每播放一個媒體文件時都會初始化一次video驅動的)。在preinit函數和config函數里可以做我們一些初始化工作,比如指定存放音頻的內存地址,當前設備支持的像素,窗口大小,和 bpp(每像素點需要用多少bit存儲))等工作。而uninit 函數則可以做些收尾工作了....
2:告訴mplayer設備支持的圖形顯示格式在mplayer調用完preinit 函數後, 它就要開始輸出數據啦。它在輸出前 會去查詢下驅動支持的像素格式等一些大小,這時候它將調用驅動的control函數,並且傳遞VOCTRL_QUERY_FORMAT參數, 這時候我們就應該把preinit函數中設置的參數告訴mplayer,然後mplayer就按設備支持的 格式輸出數據,
3:獲取 mplayer圖形數據:獲取mplayer數據有很多種方法,這些方法可以根據設備來選擇,這裡我們只使用最簡單的方法VOCTRL_DRAW_IMAGE。同樣還是在control函數中,當mplayer輸出數據將會調用control函數並傳遞VOCTRL_DRAW_IMAGE參 數和mp_image_t指針,我們可以通過mp_image_t指針來獲取圖像數據的大小,存放的位置等必要信息,然後將這些存放在顯示內存中顯示出來...int dx = mpi->wint dy = mpi->huint8_t *buf = mpi->planes[0]int stride = mpi->stride[0]
4:其它:config 函數:mplayer將調用config函數來通知驅 動,mplayer顯示圖形的原始大小,和播放的最佳大小,和影片標題等信息,這些信息只是給驅動提供參考值的.還有其它draw_frame,draw_slice,draw_osd,flip_page等接口可以按需使用,充分利用 mplayer提供的接口可以打造一個性能較優的video_out驅動的。
5:結尾現在只是使用了簡單的mplayer驅動的方法,其實還有很多點可以去優化的,比如說讓mplayer直接將數據寫到顯示內存中,而 不再先放入mp_image_t結構體中,充分利用其它的幾個接口來提高驅動的性能。
typedef struct vo_functions_s{
vo_info_t *info;
/*
* Preinitializes driver (real INITIALIZATION)
* arg - currently it's vo_subdevice
* returns: zero on successful initialization, non-zero on error.
*/
int (*preinit)(const char *arg);
/*
* Initialize (means CONFIGURE) the display driver.
* params:
* width,height: image source size
* d_width,d_height: size of the requested window size, just a hint
* fullscreen: flag, 0=windowd 1=fullscreen, just a hint
* title: window title, if available
* format: fourcc of pixel format
* returns : zero on successful initialization, non-zero on error.
*/
int (*config)(uint32_t width, uint32_t height, uint32_t d_width,
uint32_t d_height, uint32_t fullscreen, char *title,
uint32_t format);
/*
* Control interface
*/
int (*control)(uint32_t request, void *data, ...);
/*
* Display a new RGB/BGR frame of the video to the screen.
* params:
* src[0] - pointer to the image
*/
int (*draw_frame)(uint8_t *src[]);
/*
* Draw a planar YUV slice to the buffer:
* params:
* src[3] = source image planes (Y,U,V)
* stride[3] = source image planes line widths (in bytes)
* w,h = width*height of area to be copied (in Y pixels)
* x,y = position at the destination image (in Y pixels)
*/
int (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
/*
* Draws OSD to the screen buffer
*/
void (*draw_osd)(void);
/*
* Blit/Flip buffer to the screen. Must be called after each frame!
*/
void (*flip_page)(void);
/*
* This func is called after every frames to handle keyboard and
* other events. It's called in PAUSE mode too!
*/
void (*check_events)(void);
/*
* Closes driver. Should restore the original state of the system.
*/
void (*uninit)(void);
} vo_functions_t;
1:初始化驅動(preinit 函數、config函數和uninit 函數):當驅動初始化時將調用preinit ,退出時則調用uninit函數(注意:播放器在每播放一個媒體文件時都會初始化一次video驅動的)。在preinit函數和config函數里可以做我們一些初始化工作,比如指定存放音頻的內存地址,當前設備支持的像素,窗口大小,和 bpp(每像素點需要用多少bit存儲))等工作。而uninit 函數則可以做些收尾工作了....
2:告訴mplayer設備支持的圖形顯示格式在mplayer調用完preinit 函數後, 它就要開始輸出數據啦。它在輸出前 會去查詢下驅動支持的像素格式等一些大小,這時候它將調用驅動的control函數,並且傳遞VOCTRL_QUERY_FORMAT參數, 這時候我們就應該把preinit函數中設置的參數告訴mplayer,然後mplayer就按設備支持的 格式輸出數據,
3:獲取 mplayer圖形數據:獲取mplayer數據有很多種方法,這些方法可以根據設備來選擇,這裡我們只使用最簡單的方法VOCTRL_DRAW_IMAGE。同樣還是在control函數中,當mplayer輸出數據將會調用control函數並傳遞VOCTRL_DRAW_IMAGE參 數和mp_image_t指針,我們可以通過mp_image_t指針來獲取圖像數據的大小,存放的位置等必要信息,然後將這些存放在顯示內存中顯示出來...int dx = mpi->wint dy = mpi->huint8_t *buf = mpi->planes[0]int stride = mpi->stride[0]
4:其它:config 函數:mplayer將調用config函數來通知驅 動,mplayer顯示圖形的原始大小,和播放的最佳大小,和影片標題等信息,這些信息只是給驅動提供參考值的.還有其它draw_frame,draw_slice,draw_osd,flip_page等接口可以按需使用,充分利用 mplayer提供的接口可以打造一個性能較優的video_out驅動的。
5:結尾現在只是使用了簡單的mplayer驅動的方法,其實還有很多點可以去優化的,比如說讓mplayer直接將數據寫到顯示內存中,而 不再先放入mp_image_t結構體中,充分利用其它的幾個接口來提高驅動的性能。
訂閱:
文章 (Atom)