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(); this->InitDevice();
int err = snd_pcm_set_params( if (this->pcmHandle) {
this->pcmHandle, int err = snd_pcm_set_params(
PCM_FORMAT, this->pcmHandle,
PCM_ACCESS_TYPE, PCM_FORMAT,
this->channels, PCM_ACCESS_TYPE,
this->rate, this->channels,
1, /* allow resampling */ this->rate,
500000); /* 0.5s latency */ 1, /* allow resampling */
500000); /* 0.5s latency */
if (err > 0) { if (err > 0) {
std::cerr << "AlsaOut: set format error: " << snd_strerror(err) << std::endl; std::cerr << "AlsaOut: set format error: " << snd_strerror(err) << std::endl;
} }
else { else {
this->SetVolume(this->volume); this->SetVolume(this->volume);
}
} }
std::cerr << "AlsaOut: device format initialized from buffer\n"; std::cerr << "AlsaOut: device format initialized from buffer\n";