顯示具有 技術-蘋果相關 標籤的文章。 顯示所有文章
顯示具有 技術-蘋果相關 標籤的文章。 顯示所有文章

2018年2月18日 星期日

MAC OS 避免 USB NTFS 唯讀的方法

步驟記錄如下:

1. $ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            499.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3 
/dev/disk1 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *15.6 GB    disk1
   1:               Windows_NTFS KINGSTON                15.6 GB    disk1s1
此時可以得知 USB 碟的標籤是 KINGSTON

2. $ sudo vi /etc/fstab
LABEL=KINGSTON none ntfs rw,auto,nobrowse
注意:因為設定為 nobrowse,所以以後插入此 USB碟的時候,在 finder 內不會顯示此 USB 碟。
3. 移除 USB, 重新插入一次

4. $ sudo ln -s /Volumes ~/Desktop/Volumes


參考資料:


2016年3月9日 星期三

iOS - Enable AirPlay for your APP

之前寫了一個簡單的音樂APP,可以在同時使用 AudioUnit 同時進行錄音與播放。使用手機測試錄音與播放是沒問題的,但是當我想要將程式改為在手機端錄音,透過 AirPlay 在電視上播放時卻發生問題,問題現象是手機上不會出現 AirPlay 選項。

以下記錄使用 Audio Unit 各種實驗與其結果:

1. 先了解 Audio 運作時可以設定的各種模式
摘錄 Apple 定義的 AudioSession Category/Mode 設定值 
Table B-1  Audio session category behavior
Category identifiers
Silenced by the Ring/Silent switch and by screen locking see note
Interrupts non-mixable apps audio
Allows audio input (recording) and output (playback)
AVAudioSessionCategoryAmbient
Yes
No
Output only
AVAudioSessionCategoryAudioProcessing
Yes
No input and no output
AVAudioSessionCategoryMultiRoute
No
Yes
Input and output
AVAudioSessionCategoryPlayAndRecord
No
Yes by default; no by using override switch
Input and output
AVAudioSessionCategoryPlayback
No
Yes by default; no by using override switch
Output only
AVAudioSessionCategoryRecord
No (recording continues with the screen locked)
Yes
Input only
AVAudioSessionCategorySoloAmbient
Yes
Yes
Output only
Table B-2  Modes and associated categories
Mode identifiers
Compatible categories
AVAudioSessionModeDefault
All
AVAudioSessionModeVoiceChat
AVAudioSessionCategoryPlayAndRecord
AVAudioSessionModeGameChat
AVAudioSessionCategoryPlayAndRecord
AVAudioSessionModeVideoRecording
AVAudioSessionCategoryPlayAndRecord
AVAudioSessionCategoryRecord
AVAudioSessionModeMoviePlayback
AVAudioSessionCategoryPlayback
AVAudioSessionModeMeasurement
AVAudioSessionCategoryPlayAndRecord
AVAudioSessionCategoryRecord
AVAudioSessionCategoryPlayback
AVAudioSessionModeVideoChat
AVAudioSessionCategoryPlayAndRecord
因為此 APP 同時有 Audio In/Audio Out,所以能夠選擇的設定如下
  • AVAudioSessionCategoryMultiRoute
  • AVAudioSessionCategoryPlayAndRecord
  • AVAudioSessionModeDefault
  • AVAudioSessionModeVoiceChat
  • AVAudioSessionModeGameChat
  • AVAudioSessionModeVideoRecording
  • AVAudioSessionModeMeasurement
  • AVAudioSessionModeVideoChat

2. 測試不同 Audio Session Mode 與 Audio Unit 同時啟用時所造成的影響
以下僅為個人實驗結果,當 APP 啟動後,若設定為下列 Category/Mode 不會出現 Airplay選項。
  • AVAudioSessionCategoryMultiRoute
  • AVAudioSessionCategoryPlayAndRecord
  • AVAudioSessionModeGameChat
  • AVAudioSessionModeVideoRecording
  • AVAudioSessionModeVoiceChat

圖例如下:


當 APP 啟動後,若設定為下列 Category/Mode 可以出現 Airplay選項。
  • AVAudioSessionModeDefault
  • AVAudioSessionModeMeasurement
  • AVAudioSessionModeVideoChat

此時已經可以正常播放音樂,圖例如下:
 
但是一旦當APP開始進行錄音時,卻會變成只有 "iPhone" 與 "iPhone擴音"可選
圖例如下:


設定方式舉例如下: 
[[sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker|AVAudioSessionCategoryOptionMixWithOthers error:&setCategoryErr];
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionModeDefault error:&setCategoryErr]; 
經過上述實驗,我會懷疑是否使用Audio Unit 進行錄音時,便無法使用Airplay。


3. 設定 APP Capabilities,設定 Background Modes 支援 Audio and Airplay,如下圖:
此作法也是沒用。


結論:本來想作好此功能之後,可以把家裡電視跟舊iPhone結合成卡拉OK,沒想到一直試不出來,只好作罷。如果有好心人試出這個功能,麻煩請教教我啊,謝謝。

參考資料
  1. Audio Session Categories and Modes
  2. Jawbone/AudioSessionManager 
  3. AudioSessionProgrammingGuide
  4. EnrichYourAppforAirPlay


2015年12月24日 星期四

重新安裝 Mac OS

這個星期要把舊 Mac 搬回家給爸爸用了,將處理舊 Mac 的過程作一記錄

2014年9月12日 星期五

內存越界檢查 -- 使用 XCode 與 Instrument

最近用 C語言 改寫 webrtc 內的 pseudoTCP,在記憶體配置與釋放遇到一個問題,將本次的解法記錄如下。

問題現象:

pseudoTCP(1403,0x7fff7cc17310) malloc: *** error for object 0x100103c10:
incorrect checksum for freed object - object was probably modified after being freed.

問題可能原因:

一般記憶體出錯的可能原因如下
  • you are freeing an object twice,
  • you are freeing a pointer that was never allocated
  • you are writing through an invalid pointer which previously pointed to an object which was already freed

2014年9月2日 星期二

iOS -- 使用音頻資料產生波形圖(Waveform)

對於 iOS 上的 Audio 應用,本人已經學會了使用 AudioUnit 進行播放,錄音以及混音,也了解如何使用 AudioConverter 或是 FFmpeg 進行音頻格式的轉換,接著要練習的便是利用 Audio 畫出 Waveform。本篇將針對 Waveform 作一介紹。

2014年5月19日 星期一

iOS -- 使用 Crash Report 進行除錯

當 APP 發佈之後,若使用者發現此APP會當掉,該如何回報給開發商,而開發 APP的人又該如何處理這些問題呢?以下針對上述問題的解決方式作一整理。

1. APP Crash Report
當 APP 發生問題導致Crash,iOS 會將各個 APP 的 Crash Report 統一儲存,路徑為 /private/var/mobile/Library/Logs/CrashReporter/

2014年4月14日 星期一

iOS - Audio Unit 簡介

本篇乃針對 Audio Unit Hosting Guide for iOS,摘錄個人閱讀後的心得整理。

基本概念

Audio Unit 在 iOS Audio Frame Work 屬於底層的應用,其階層關係可參考下圖。

2014年3月11日 星期二

iOS -- 錄音功能實作

近日針對 iOS 設備的錄音功能做一研究,整理如下:

一、聲音來源

錄音時,其聲音來源可能有以下兩處,
  • 麥克風
  • 正在播放的音頻資料(可能來自本地端的檔案,或是遠端的音頻資料)
可以分別選擇不同來源進行錄音,也可以將兩種聲音進行 mix

2014年2月10日 星期一

如何取得 iPhone 內建音效檔案

iPhone 手機內建了許多音效,當我們開發App時,要如何直接使用這些音效檔案呢?以下簡介使用與取得這些音效檔案的方法。

2014年1月19日 星期日

iOS -- 背景撥放音樂

iOS -- 背景撥放音樂

背景控制播放音樂的基本原理如下:
1. 將 app 設定為 FirstResponder 
2. 實作 UIResponder class 定義的 remoteControlReceivedWithEvent: 方法
   接收對應的 event 並進行處理,以下列舉幾個 event 當作例子 
UIEventSubtypeRemoteControlPlay
UIEventSubtypeRemoteControlPause
UIEventSubtypeRemoteControlStop
UIEventSubtypeRemoteControlTogglePlayPause
IEventSubtypeRemoteControlNextTrack
UIEventSubtypeRemoteControlPreviousTrack 
3. 透過 MPNowPlayingInfoCenter defaultCenter 設定鎖屏時顯示的資訊
   例如:[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo ];

網路上已經有很多程式範例了,茲將實作時參考到的程式碼紀錄如後

設定背景撥放音樂,並接收鎖屏時的 Play/Stop 按鍵以進行客製化的行為
修改鎖屏時所顯示的歌曲訊息文字與圖片

2014年1月17日 星期五

iOS -- 播放聲音的 API

在 iOS 設備上有許多播放聲音的方法,那麼應該選擇什麼樣的方式呢?
以下根據個人的經驗,分析不同情景下適用的處理方式。

iOS 可以使用數種方法播放聲音,根據用法的難易度,由簡單到困難列舉如下:
  • System Sound Service
  • AVAudioPlayer
  • AVPlayer
  • Audio Queue Service
  • OpenAL
  • Audio Unit
下圖為 Audio Framework,可由此得知不同方法之間的階層關係

2014年1月6日 星期一

Apple TV3 播放大陸影音網站

Apple TV 可以直接播放大陸影音網站所提供的影片,這功能真的很方便,而且速度也挺順的,以下將自己設定 Apple TV3的過程作一記錄。

2014年1月5日 星期日

iOS -- 如何處理撥放的聲音(音量大小、聲音路徑、特效)

當 iOS 設備可以正確的播放聲音之後,後續便可能需要對此聲音作些處理,例如:變更音量大小,設定音量從喇叭或是耳機輸出,或者對於此聲音做些特效。

2014年1月3日 星期五

iOS -- 程式中指定透過WIFI 或 3G 進行連線

在手機中使用3G上網往往需要較昂貴的費用,因此app開發者應該要讓使用者可以自由選擇透過3G或是WIFI上網。

要指定建立連線的網路介面,只要使用 bind 函數,指定對應的網路介面即可。在 iOS 中選擇 WIFI 或是 3G 也是同樣的道理,以iPhone為例,其網路介面名稱定義如下

  • WIFI 為 en0
  • 3G 為 pdp_ip0

2013年12月3日 星期二

AirPlay 測試心得

最近使用 PPS 播放影音時,無法與 Apple TV 進行 airplay,印象中之前是可以的,趁著今晚有空,針對 AirPlay 的互通性進行以下測試。

AirPlay 原理


基本概念


AirPlay 是一個用來與 Apple TV溝通的協定,可用 iOS 設備或 itunes將資料交給 Apple TV進行播放,其實作使用 Multicast DNS, HTTP, RTSP, RTP or NTP 等協定,並加上些許的修改。

2013年9月3日 星期二

iOS -- Packet Tracing

當我們在 iOS Device 撰寫網路相關的 APP 時,時常需要分析網路上所傳送/接收的封包,由於 iOS 本身並沒有直接支援擷取封包的功能,因此需要使用其他方法來擷取網路封包。以下參考 developer.apple.com,整理封包擷取的方法。

2013年8月4日 星期日

[xcode] 清除 recent memu

打開 xcode,裡面常常出現許多已經沒有使用的 Project,下面的操作可以將 Project list 整個清空。
  1. Launch Xcode
  2. Select File->Open Recent->Clear Menu
  3. Right-click the Xcode icon and select "Show All Windows". You should now see only your current document in the recents list at the bottom
  4. Quit Xcode. The recents list should now only be populated with your single current project.

2013年2月28日 星期四

Apple Device Spec (iPhone, iPad)

整理 iOS Device 相關能力,以利開發 app 時能夠正確的套用到各種機型。

Resolution and Memory