Wed Dec 14, 2016 2:26 am
Hi Eric,
Glad to hear that you were able to resolve the issue.
I can confirm that calling IDeckLinkOutput::ScheduleAudioSamples [1] and passing NULL for the sampleFramesWritten parameter will result in a blocking write, i.e. the call will wait until all of the provided audio samples have been scheduled.
Providing a valid pointer to sampleFramesWritten will result in a non-blocking write, and the actual number of audio samples written will be returned in this out parameter. A note has been made to ensure that this point is more clearly described in the SDK manual.
The blocking that your application experienced occured because:
1. The DeckLink API allows a maximum of one second of audio to be prerolled (i.e. 48000 samples)
2. During preroll the audio streams are not running, so the audio buffer is not being drained
3. When sampleFramesWritten is NULL, the API blocks waiting to schedule all of the provided audio samples.
Please note that the SignalGenerator sample relies on this blocking audio scheduling behaviour in combination with timestamped audio (bmdAudioOutputStreamTimestamped passed to EnableAudioOutput [2]) in order to schedule audio for the 'pip' and 'dropout' signals.
In your application it may be appropriate to either use IDeckLinkOutput::GetBufferedAudioSampleFrameCount [3] in order to determine the number of buffered audio samples and then schedule enough to maintain the audio waterlevel at an application defined level, or to schedule enough audio for the prerolled video frames, e.g. using IDeckLinkOutput::GetBufferedVideoFrameCount [4].
Regarding the number of frames prerolled, please note that the minumum number of frames provided for preroll depends on the device architecture; pre-4k devices require a minimum of three frames provided for preroll, while 4k architecture devices (incl. the DeckLink Duo 2) require a minimum of two frames.
Hope that helps,
-nick
[1] 2.5.3.19 IDeckLinkOutput::ScheduleAudioSamples method
[2] 2.5.3.14 IDeckLinkOutput::EnableAudioOutput method
[3] 2.5.3.20 IDeckLinkOutput::GetBufferedAudioSampleFrameCount method
[4] 2.5.3.13 IDeckLinkOutput::GetBufferedVideoFrameCount method