output/openal: auto-fallback to mono if channel count is unsupported

.. instead of failing playback completely.
This commit is contained in:
Max Kellermann 2011-10-08 14:39:40 +02:00
parent 72a1ca3b99
commit 5ed0eb51d1
2 changed files with 11 additions and 9 deletions

2
NEWS
View File

@ -10,6 +10,8 @@ ver 0.16.5 (2010/??/??)
- ffmpeg: higher precision timestamps - ffmpeg: higher precision timestamps
- ffmpeg: don't require key frame for seeking - ffmpeg: don't require key frame for seeking
- fix CUE track seeking - fix CUE track seeking
* output:
- openal: auto-fallback to mono if channel count is unsupported
* player: * player:
- make seeking to CUE track more reliable - make seeking to CUE track more reliable
- the "seek" command works when MPD is stopped - the "seek" command works when MPD is stopped

View File

@ -64,26 +64,26 @@ openal_audio_format(struct audio_format *audio_format)
return AL_FORMAT_STEREO16; return AL_FORMAT_STEREO16;
if (audio_format->channels == 1) if (audio_format->channels == 1)
return AL_FORMAT_MONO16; return AL_FORMAT_MONO16;
break;
/* fall back to mono */
audio_format->channels = 1;
return openal_audio_format(audio_format);
case SAMPLE_FORMAT_S8: case SAMPLE_FORMAT_S8:
if (audio_format->channels == 2) if (audio_format->channels == 2)
return AL_FORMAT_STEREO8; return AL_FORMAT_STEREO8;
if (audio_format->channels == 1) if (audio_format->channels == 1)
return AL_FORMAT_MONO8; return AL_FORMAT_MONO8;
break;
/* fall back to mono */
audio_format->channels = 1;
return openal_audio_format(audio_format);
default: default:
/* fall back to 16 bit */ /* fall back to 16 bit */
audio_format->format = SAMPLE_FORMAT_S16; audio_format->format = SAMPLE_FORMAT_S16;
if (audio_format->channels == 2) return openal_audio_format(audio_format);
return AL_FORMAT_STEREO16;
if (audio_format->channels == 1)
return AL_FORMAT_MONO16;
break;
} }
return 0;
} }
static bool static bool