简体   繁体   中英

Learning Core Audio Chapter 8 Example not running

I am just getting up to speed on core audio, and am going through all the examples in "Learning Core Audio" by Adamson and Avila.

The first example that doesn't work (using the sample code and projects from the web site) is in Chapter 8. It simply doesn't do anything.

Some times, but not every time I run the program, I also get an error on the last line

AUGraphClose(player.graph);

CH08_AUGraphInput(9781,0x7fff78ee8960) malloc: * error for object 0x104003600: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug

I am just checking to see if anybody has had this problem as I dive into figuring out what could be going wrong.

Ok, I managed to debug this, through fortuitous use of breakpoints.

It appears that the mTimestamp field of the timestamp is not getting written properly on the first output callback. On the first call, it is always showing up as 0. After the first call, it is of a similar magnitude to the value from the input timestamp, which is much greater than 0. As a result, the inToOutSampleTimeOffset calculated from the first sample is not a meaningful value, and it is messing up the ring buffer.

To fix this, I added

if (inTimeStamp->mSampleTime > 0.0) {

At line 97, and blocked off the execution of the rest of the function. It now works, although it does make a dreadful pop to start.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM