Skip to content

Commit

Permalink
Fix crash on mac when no audio device exists.
Browse files Browse the repository at this point in the history
Test for NULL pointer before trying to read its content
  • Loading branch information
jyavenard committed Feb 29, 2012
1 parent 7e6f5fa commit dfd909f
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions mythtv/libs/libmyth/audio/audiooutputca.cpp
Expand Up @@ -200,17 +200,28 @@ AudioOutputSettings* AudioOutputCA::GetOutputSettings(bool digital)
// Seek hardware sample rate available
int rate;
int *rates = d->RatesList(d->mDeviceID);
int *p_rates = rates;

while (*p_rates > 0 && (rate = settings->GetNextRate()))
if (rates == NULL)
{
if (*p_rates == rate)
// Error retrieving rates, assume 48kHz
settings->AddSupportedRate(48000);
}
else
{
while ((rate = settings->GetNextRate()))
{
settings->AddSupportedRate(*p_rates);
p_rates++;
int *p_rates = rates;
while (*p_rates > 0)
{
if (*p_rates == rate)
{
settings->AddSupportedRate(*p_rates);
}
p_rates++;
}
}
free(rates);
}
free(rates);

// Supported format: 16 bits audio or float
settings->AddSupportedFormat(FORMAT_S16);
Expand Down

0 comments on commit dfd909f

Please sign in to comment.