My DAC is internally clocked at 48khz, I need to feed it from a stream that is also 48khz but is clocked from a different source.
The two sources will drift over time and any buffering in between will inevitably overflow or underflow.
Unfortunately, there is no rate control mechanism available for the source.
How can this best be handled?
Would it be acceptable to duplicate or toss the occasional sample to compensate? I'm estimating 1 sample every ~70k samples for 30ppm difference.
This may sould like a stupid question, but hear me out: Does the output rate really matter?
Consider this scenario - you have an audio input device. You are sampling an analog waveform input at 48Khz. That waveform could be generated by anything at any rate- from the continuous pressure level measurement of a microphone to an 8Khz voice codec, or lower. The fact that you happen to know that this particular output is also at 48Khz has no bearing on what you are doing.
If there were perfect transmission between the output device and your input, when you compare the original digital waveform to what you read, you will occassionally see that you have duplicated a sample (if your clock is faster) or missed one (if you are slower). But this will happen automatically, without any compensation by you needed. This will easily be as accurate as any attempt by you to figure out when to "duplicate or toss the occasional sample".
In practice, you probably won't get an exact duplicate anyway, between filtering effects and noise in both the DAC and ADC. Unless you are talking about some encoded digital audio format - in which case, ignore everything I've said.
EDIT - Ok, so it is digital audio - S/PDIF?
The signal should carry enough information to implement a phase lock. Ideally in hardware - the rising edges of the signal define the clock rate - you may be able to use PLL hardware to lock your A/D clock to the input. Or oversample for a while and count the rising edges to determine the rate. Or at the software level, measure the rate of framing errors in the 1st four time slots, and adjust your clock to compensate.