When an optical CD/DVD drive begins to fail, it usually has trouble with recordable media first. A few simple tests can help verify whether the problem is with the drive or the media:
I have a macbook and recently I cannot put a cd in to record or have recorded. This happened before with toast. And I found I had something set wrong. What am I supposed to set this on so it will quit ejecting my cds?
Usually an optical drive will eject a CD or DVD if it has trouble reading the media. That could mean a bad disc, or that the CD/DVD drive itself is failing. Try another brand of discs; if you have repeated failures wtih multiple brands, and the same discs work OK on a different Mac, you will probably need to replace the drive..