I've visited friends, knocked on their door, told to come in, and they were masturbating. We I didn't join in, they eventually stopped. I didn't think any less of them. I probably wanted to join in but didn't, I don't why I didn't.
Do what you are comfortable doing. If he's your friend, it won't matter to him. He might join in, or might not.