GStreamer alsasrc 插件中的 I2S 匯流排聲道設定

我的一位同事在測試 GStreamer 的 alsasrc 與 osssrc 插件時發現,alsasrc 消耗了相當驚人的 CPU 資源(在我們使用的晶片上約占 16%)。他詢問我,為何晶片供應商提供的測試工具卻能維持極高的效率(約僅占 1~2%)。這巨大的效能差距引起了我的好奇,我決定深入研究原因。 經過數小時的調查,我發現當參數設定為「非阻塞模式 (non-blocking mode)」時,該插件可能會在 While 迴圈中導致忙碌等待 (busy wait)。我對程式碼進行了簡單修改並重新執行,結果 CPU 使用率降低到 12%。雖然略有改進,但我依然感到有些沮喪。 於是,我開始嘗試不同的參數組合,因為我同事發現了 alsasrc 與測試工具間的三個差異點: alsasrc 設定為「非阻塞模式」,而測試工具為「阻塞模式 (block mode)」。 alsasrc 的聲道設定為 1,而測試工具設定為 2。 測試工具限制了緩衝區大小 (buffer size),而 alsasrc 沒有這項限制。 針對第一點:我原以為非阻塞模式應該更有效率,但關鍵在於必須改善其忙碌等待的機制。 針對第二點:這非常奇特,因為當我在 alsasrc 插件將聲道數設定為 2 時,CPU 使用率竟然大幅降低。這讓我開始懷疑這是否與 I2S 匯流排的特性有關。我在網路上搜尋,並未發現任何資料指明「當音訊匯流排為 I2S 時,必須在 GStreamer 的 alsasrc 插件中將聲道參數設為 2」。稍後我會進一步確認此現象。 針對第三點:我認為限制緩衝區大小以優化效能是合理的做法。

February 8, 2013 · 1 分鐘 · 55 字 · ChenFu Kuo

[工作點滴] RabbitMQ setup and test

RabbitMQ setup and test Server side: My desktop PC is windows 7 and we download the rabbitmq server from http://www.rabbitmq.com/. The installation guide is here http://www.rabbitmq.com/install-windows.html. I use extra ethernet card and set the ip address to be 192.168.1.19 and make sure the firewall would not block the port 5672. Client side: we put the send and listen on same device. I use the package from https://github.com/alanxz/rabbitmq-c. We can follow the guide in the link to cross build and install on the embedded device we use. ...

February 7, 2013 · 1 分鐘 · 86 字 · ChenFu Kuo

[工作點滴] The realtime of transport stream on Miracast

When I google the internet with realtime and transport stream, I could not find the information I want. The word ‘realtime’ must construct on the relative thinking. For example, there is camera and screen and the camera’s video can be showed on the screen with quite small latency. We assume the latency is under 150ms or 300ms whatever and we can call this is realtime or not when we can have comparisons. The structure of the transport stream or what we call MPEG-TS is not that simple. What I say is compare with raw encoded media direct push to intermedia. Maybe the transport stream is design for broadcasting usage, so the media stream can be selected and video can be smooth played are much more important than realtime. Because people would not feel any latency happened when they just watch TV. If we want to convert raw encoded media to transport stream. First, we have to packetize the raw encoded media to packetized elementary stream(PES). Second, we handle the PES by the muxing, splitting to small slice AV data…etc to program stream or what we call transport stream. Finally, we send the transport stream to internet or satellite for people to receive and watch it on display. These steps create lots of latency and make us feel it’s not realtime enough. Let’s go back to the definition of the Miracast. It is to convert the raw encoded media stream to transport stream and then encapsulate the stream to RTP. Finally go through the wifi directly to display. I’m not sure how many latency will be created? Maybe someone can tell me.

February 6, 2013 · 2 分鐘 · 271 字 · ChenFu Kuo

[工作點滴] Airplay, DLNA and Miracast

Today, there is a supplier come to our company to introduce their solution with DLNA and Miracast support. I survey the internet and found three kinds of protocols are discussed on the market. The DLNA has been talked for a long time and Apple is DLNA member originally. But Apple left DLNA and create the proprietary Airplay protocol. The Miracast is created by Wifi Alliance. It seems that Android alliance choose the Miracast to fight with Apple? ...

February 5, 2013 · 1 分鐘 · 78 字 · ChenFu Kuo

[工作點滴] STL notes

國外工程師用boost c++ library來進行相關專案的開發, 進而看到一些相關的STL語法, 所以還是得抽空K一下相關資料, 至少要把code看懂. From wiki: http://en.wikipedia.org/wiki/Standard_Template_Library The Standard Template Library (STL) is a C++ software library that influenced many parts of the C++ Standard Library. It provides four components called algorithms, containers, functional, and iterators. The STL provides a ready-made set of common classes for C++, such as containers and associative arrays, that can be used with any built-in type and with any user-defined type that supports some elementary operations (such as copying and assignment). STL algorithms are independent of containers, which significantly reduces the complexity of the library. ...

February 5, 2013 · 1 分鐘 · 171 字 · ChenFu Kuo

[工作點滴] Linux工具小記錄

打patch的command diff -Naur [from-file] [to-file] > [YourFileName.patch] -N In directory comparison, if a file is found in only one directory, treat it as present but empty in the other directory. -a Treat all files as text and compare them line-by-line, even if they do not seem to be text. -u Use the unified output format. -r When comparing directories, recursively compare any subdirectories found. SVN版本控制下要移除所有目錄底下.svn $ rm -rf find . -type d -name .svn ...

February 4, 2013 · 1 分鐘 · 86 字 · ChenFu Kuo

[工作點滴] message pack rpc install on openwrt

Message pack with RPC extension required 3 packages. msgpack msgpack-rpc mpio The msgpack and mpio are required by msgpack-rpc. The following are openwrt makefiles that I use to build the packages. msgpack library include $(TOPDIR)/rules.mk PKG_NAME:=msgpack PKG_VERSION:=0.5.7 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://msgpack.org/releases/cpp/ PKG_MD5SUM:=705106a9378c792fe22d285dba5c142c PKG_INSTALL:=1 include $(INCLUDE_DIR)/package.mk define Package/msgpack SECTION:=libs CATEGORY:=Libraries TITLE:=Message Pack library URL:=http://msgpack.org endef define Package/msgpack/description MessagePack is an efficient binary serialization format. It lets you exchange data among multiple languages like JSON but it’s faster and smaller. endef ...

February 4, 2013 · 2 分鐘 · 257 字 · ChenFu Kuo

[工作點滴] msgpack-idl howto

msgpack-idl howto Step1 get the msgpack-idl $ git clone git://github.com/msgpack/msgpack-idl.git Step2 install the ruby tool that required $ sudo apt-get install ruby1.9.1 Step3 go to msgpack-idl folder. $ sudo gem install msgpack-idl $ sudo msgpack-idl –install java Step4 create a sample file ‘sample’ with content as follow. message Node { ``1``: string address ``2``: map<string,string> properties ``3``: optional string? description } message StorageNode < Node { ``4``: long capacity ``5``: optional int weight = 1 } Step 5 generate the java code by following command ...

February 4, 2013 · 1 分鐘 · 147 字 · ChenFu Kuo

[工作點滴] git clone error "error: Problem with the SSL CA cert (path? access rights?)"

Our company’s git server do not support the ssl verify but support user name password verify. The default git enable the SSL verify when access https. I would encounter the error message like: error: Problem with the SSL CA cert (path? access rights?) while accessing https://tw.ubnt.com/git/example.git/info/refs fatal: HTTP request failed So we have to config the git by command: git config –global http.sslVerify false Then git clone again $ git clone https://tw.ubnt.com/git/example.git Cloning into ’test’… Username for ‘https://tw.ubnt.com’: name Password for ‘https://[email protected]’: password remote: Counting objects: 1054, done. remote: Compressing objects: 100% (674/674), done. remote: Total 1054 (delta 390), reused 747 (delta 290) Receiving objects: 100% (1054/1054), 14.45 MiB | 377 KiB/s, done. Resolving deltas: 100% (390/390), done. ...

January 31, 2013 · 1 分鐘 · 119 字 · ChenFu Kuo

[工作點滴] protocol buffer and message pack initial

When I have engineer discussion with the abroad engineer, I found he use the 3rd party library name message pack for binary serialization for internet application. More detailed information of message pack is here. http://msgpack.org/ I do not sure what’s the total different between these two library and I could not get a detailed comparison from them. So I will spend some time to study it.

January 31, 2013 · 1 分鐘 · 66 字 · ChenFu Kuo