Hmm... You could detect the output type (built-in speakers, headphones, bluetooth) and change the audio quality accordingly.