Air conditioner is working great and then starts blowing warm/outside air- on 2007 Volvo S40

Texas 95 degrees-air conditioner works great-then it starts blowing out recycled air. Smells weird and after awhile it will start blowing cold air---then it will blow warm air again. It did it 3 times yesterday. I was driving for over an hour. It has done this before.

Asked by for the 2007 Volvo S40