A few days ago my digital output stopped working altogether. I had no problem switching from built in output to digital, i just had no audio at all via digital. I ended up fixing it by using the cotton bud fix given in this page (above).
I removed the cotton from one side of the cotton bud, leaving just the plastic bit remaining, and very gently put it into the headphone jack, then twisted it around slowly. I also blew into the headphone jack which might have dislodged a tiny bit of dust.
I'm assuming that the optical red light in my macbook jack port, had been partially blocked by dust.
Thankfully its now working fine now, no problem with audio either digital or built-in.
Thanks for the useful advice!