Fix invalid handle issue in AlsaOut

This commit is contained in:
casey langen 2020-04-09 16:54:03 -07:00
parent adb3048a21
commit c95cb68ae4

View File

@ -499,20 +499,22 @@ void AlsaOut::SetFormat(IBuffer *buffer) {
this->InitDevice();
int err = snd_pcm_set_params(
this->pcmHandle,
PCM_FORMAT,
PCM_ACCESS_TYPE,
this->channels,
this->rate,
1, /* allow resampling */
500000); /* 0.5s latency */
if (this->pcmHandle) {
int err = snd_pcm_set_params(
this->pcmHandle,
PCM_FORMAT,
PCM_ACCESS_TYPE,
this->channels,
this->rate,
1, /* allow resampling */
500000); /* 0.5s latency */
if (err > 0) {
std::cerr << "AlsaOut: set format error: " << snd_strerror(err) << std::endl;
}
else {
this->SetVolume(this->volume);
if (err > 0) {
std::cerr << "AlsaOut: set format error: " << snd_strerror(err) << std::endl;
}
else {
this->SetVolume(this->volume);
}
}
std::cerr << "AlsaOut: device format initialized from buffer\n";