2018年1月6日 星期六
[Word] Mac 版 Microsoft Word 中文直書
- Problem: Mac上的 Microsoft Word, 想排版成中文直書, 但直書只看得到連字也順時針轉 90度的選項
- Solution:
- 關閉 Word
- 設定 Microsoft Language Register到 Traditional Chinese
- 應用程式 -> Microsoft Word 20xx -> Additional Tools -> Microsoft Language Register
- 重開 Word, Layout中看到 Layout中的直書選項即可
- Reference: [教學]如何在Office 2004 for Mac Word 中輸入直式中文
2018年1月5日 星期五
2017年12月28日 星期四
[Android] Autolock
- 在 trace Android media player時, 常看到 function有些有加 _l suffix的, 有的沒有. e.g. prepare, prepare_l
- 主要的差異在於是否有用 Mutex lock住
- 但此時又看到神奇的 code
- /frameworks/av/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp
-
status_t NuPlayerDriver::prepare() { ALOGV("prepare(%p)", this); Mutex::Autolock autoLock(mLock); return prepare_l(); } - /frameworks/av/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp 因此會發出疑問, 這個 autoLock 是做什麼的? 定義卻沒有使用?
- 簡單說, 就是利用 constructor跟 deconstructor 來呼叫 mutex lock 跟 mutex unlock
- 而此處的 prepare_l 有 l結尾的應該就是指 lock後執行的程式碼
[C++] do...while(0)
- 優點:
- block 區塊, 可以在其內宣告變數, 在像 C89需要將變數定義在最上方這方面大有幫助
- 以 do...while(0) 取代 goto, 將 goto 後的東西放 while外面, 裡面用 break來達到 goto的效果
- 程式碼易讀且效能並沒損失
- 避免 marco 沒有加 {}, 又接在 if() 單行執行內容有分號的 case
- e.g.
#define swap(x, y) int temp; temp = x; x = y; y = temp;
if(x > y) swap(x, y);- Reference:宏定义中使用do{}while(0)的好处
2017年12月27日 星期三
[C++] Coding convention - prefix k and What
- trace Android code時, 常會看到如下的 code
enum { kWhatSetDataSource = '=DaS', kWhatPrepare = 'prep', kWhatSetVideoSurface = '=VSu', kWhatSetAudioSink = '=AuS', kWhatMoreDataQueued = 'more', kWhatConfigPlayback = 'cfPB', ...- 這個 k代表什麼意思呢? => konstant, 因為 c的 prefix 已經被 char 用掉了, 用了 Germany的 konstant, 至於全大寫與 Hungarian notation 就不在這戰了
- 至於 What, 則猜測這些 enum 主要是用來在 message中傳遞, 對應 message.what 的 int值, 所以在 handler中常會看到自行定義的 enum 用 kWhat當 prefix
- 節錄 Android doc Message.what
-
what int what User-defined message code so that the recipient can identify what this message is about.
Each Handler has its own name-space for message codes,
so you do not need to worry about yours conflicting with other handlers.
[Android] DISALLOW_EVIL_CONSTRUCTORS
- 簡單的 macro, 用來避免未實作的 copy constructor 跟 assignment constructor 被 compiler實作
- Code
#define DISALLOW_EVIL_CONSTRUCTORS(name) \
name(const name &); \
name &operator=(const name &) /* NOLINT */
- Sample: ABuffer.h
struct ABuffer : public RefBase { explicit ABuffer(size_t capacity); ABuffer(void *data, size_t capacity); ... private: DISALLOW_EVIL_CONSTRUCTORS(ABuffer);- Reference:
[Android] Media Player
- State Diagram
- fixme later: 補 initialized/prepared/stopped 的 state diagram
- stagefright/NuPlayer
- fundamental design
- ALooper/AMessage/AHandler
- Interface
- content source/demuxer/decoder/render (driver)
- Reference:
2017年12月25日 星期一
訂閱:
文章 (Atom)


