iPhone/iPad开发扎记 2012/02/21

来源:互联网 发布:mac mini 蓝牙 天线 编辑:程序博客网 时间:2024/06/04 18:34


1. playing *.pcm in iOS 

* EXC_BAD_ACCESS 

http://www.cocoachina.com/macdev/objc/2011/0219/2661.html


Q:设置NSZombieEnabled后,仍然没有crash的线索。


* thought: 

可能是因为audio queue buffer没有初始化造成的。

see the following article: http://www.cnblogs.com/lovecode/archive/2011/11/14/2249021.html

reasons for EXC_BAD_ACCESS: 

1、访问受保护或者不存在的内存空间,导致返回了一个错误的指针;

2、访问未进行内存分配或初始化的内存空间;

3、在对象被释放后仍然采用原来的指针进行访问;

4、采用了[object release]释放对象,但其实对象并未采用 alloc/copy/retain 等形式进行内存分配;(这是我此次错误的原因)

5、其他不合法的内存访问方式

I guess my issue is 1st or 2nd ones. 


* handle EXC_BAD_ACCESS

# added the following statement: 

// prime the queue with some data before starting

for (int i =0; i <kNumberBuffers; ++i) {

AudioQueueAllocateBuffer(mQueue,MAX_BYTES_BUFFER, &mBuffers[i]); // added by frank.zou on 2012/02/21 Q: why no this before ?

AQBufferCallback (this, mQueue, mBuffers[i]);

   ^ Why not AQBufferPrime(...) ? 2012/03/12 

}


still the error EXC_BAD_ACCESS, but it is about memcpy(...) in readAudioDataPackets() now. 

// copy all data to audioData buffer 

memcpy(audioData, buffer, (size_t)numBytes);


* found out that numBytes is a pointer, changes as follows: 

memcpy(audioData, buffer, (size_t)*numBytes);

                                   ^ done !


note: still some noise need to be taken care of. 


Q: Why SpeakHere samples does not init Audio Queue buffer ?


2. study view related stuff for iOS 

Camera Programming Topics for iOS 


* something related 

Image Picker Controller 

AV Foundation framework 

Assets Library 




原创粉丝点击