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 Mar 13, 2012
1 parent 63128e2 commit 0367088
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions mythtv/libs/libmyth/audiooutputca.cpp
Expand Up @@ -201,17 +201,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 Expand Up @@ -1715,4 +1726,4 @@ QMap<QString, QString> *AudioOutputCA::GetDevices(const char *type)
}
}
return devs;
}
}

0 comments on commit 0367088

Please sign in to comment.