Hi everybody,
I'm currently working on a music player app for social partner dancing. One of my beta testers reported an issue where his computer slept the display, he pressed a key to awake the display, and the audio stopped. Fortunately, the dance event he was DJing for was very forgiving :)
His console logs report:
3/24/14 3:41:04.142 AM WindowServer[90] device_generate_lock_screen_screenshot: authw 0x0(0), shield 0x7ffdca755f10(2001)
3/24/14 3:41:14.000 AM kernel[0] IOAudioStream[0xffffff8018fbe000]::clipIfNecessary() - Error: attempting to clip to a position more than one buffer ahead of last clip position (20d8,b08)->(20db,2d20).
3/24/14 3:41:14.000 AM kernel[0] IOAudioStream[0xffffff8018fbe000]::clipIfNecessary() - adjusting clipped position to (20db,b08)
3/24/14 3:41:17.646 AM WindowServer[90] CGXDisplayDidWakeNotification [4613089715284]: posting kCGSDisplayDidWake
Sadly, this is all of the logging that I have. The comprehensive logs that my app writes out were deleted by accident.
I can't find anything recent regarding the "clipIfNecessary" messages, but it sounds like, at one point in time, it was regarded as a red herring?
My basic methodology is:
1) Grab an audio file, convert the entire thing to PCM in a very large memory buffer.
2) Use a ScheduledSoundPlayer audio unit with one ScheduledAudioSlice (pointed at the entire buffer) rather than feeding the ScheduledSoundPlayer many slices throughout playback.
3) Connect that to an AUHAL output unit. In this case, the output device was a Behringer UCA222 in Hog Mode, with a 512 frame buffer and 44100Hz nominal sample rate.
4) Grab the current sample time via AudioUnitGetProperty(... kAudioUnitProperty_CurrentPlayTime ...). Stop the graph when that timestamp's mSampleTime / sampleRate is greater than the song's duration.
A few questions:
A) Is #2 above (using a single slice) dangerous or not recommended?
B) Is there situations (especially in relation to kCGSDisplayDidWake) where the AUGraph/ScheduledAudioSlice may stop and I have to respond to an event to tell it to continue? I'm thinking about the CGEventTap APIs, where if you get a timeout error, you have to re-enable the tap. Is there anything like that in the ScheduledAudioSlice land?
C) I wasn't checking the result of AudioUnitGetProperty(kAudioUnitProperty_CurrentPlayTime), nor was I checking the mFlags of the timestamp to make sure the mSampleTime was valid before I used it. The structure for the time stamp was initialized to {0} prior to calling AudioUnitGetProperty(); however, is it possible that mSampleTime was filled with a garbage value? If a high enough Float64, this would have caused the current song to stop and advance to the next song (which is what the DJ saw).
Any advice is appreciated :) Thank you for your time!
Ricci Adams