Bug 928547: Change AudioStream cubeb-dependent logic to handle success cases first, so we can add #ifdef that ends in failure case. r=padenot

This commit is contained in:
Daniel Holbert 2013-10-23 17:44:13 +02:00
parent 388b302e9e
commit a4e08580e0

View File

@ -433,15 +433,16 @@ AudioStream* AudioStream::AllocateStream()
int AudioStream::MaxNumberOfChannels()
{
uint32_t maxNumberOfChannels, rv;
#if defined(MOZ_CUBEB)
uint32_t maxNumberOfChannels;
rv = cubeb_get_max_channel_count(GetCubebContext(), &maxNumberOfChannels);
if (rv != CUBEB_OK) {
return 0;
if (cubeb_get_max_channel_count(GetCubebContext(),
&maxNumberOfChannels) == CUBEB_OK) {
return static_cast<int>(maxNumberOfChannels);
}
#endif
return static_cast<int>(maxNumberOfChannels);
return 0;
}
int AudioStream::PreferredSampleRate()
@ -453,9 +454,13 @@ int AudioStream::PreferredSampleRate()
// backend used.
const int fallbackSampleRate = 44100;
if (mPreferredSampleRate == 0) {
if (cubeb_get_preferred_sample_rate(GetCubebContext(), &mPreferredSampleRate) != CUBEB_OK) {
mPreferredSampleRate = fallbackSampleRate;
#if defined(MOZ_CUBEB)
if (cubeb_get_preferred_sample_rate(GetCubebContext(),
&mPreferredSampleRate) == CUBEB_OK) {
return mPreferredSampleRate;
}
#endif
mPreferredSampleRate = fallbackSampleRate;
}
return mPreferredSampleRate;