mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-01-28 08:09:40 +01:00
Cleanup alsadevicefinder
Signed-off-by: Jonas Kvinge <jonas@jkvinge.net>
This commit is contained in:
parent
e5774ffcdc
commit
f9c2801db1
@ -42,10 +42,10 @@ QList<DeviceFinder::Device> AlsaDeviceFinder::ListDevices() {
|
|||||||
|
|
||||||
QList<Device> ret;
|
QList<Device> ret;
|
||||||
|
|
||||||
//register int err;
|
int result = -1;
|
||||||
int card = -1;
|
int card = -1;
|
||||||
int dev = -1;
|
int dev = -1;
|
||||||
int result = -1;
|
|
||||||
snd_ctl_card_info_t *cardinfo;
|
snd_ctl_card_info_t *cardinfo;
|
||||||
snd_pcm_info_t *pcminfo;
|
snd_pcm_info_t *pcminfo;
|
||||||
snd_ctl_t *handle;
|
snd_ctl_t *handle;
|
||||||
@ -53,8 +53,6 @@ QList<DeviceFinder::Device> AlsaDeviceFinder::ListDevices() {
|
|||||||
snd_ctl_card_info_alloca(&cardinfo);
|
snd_ctl_card_info_alloca(&cardinfo);
|
||||||
snd_pcm_info_alloca(&pcminfo);
|
snd_pcm_info_alloca(&pcminfo);
|
||||||
|
|
||||||
card = -1;
|
|
||||||
|
|
||||||
snd_pcm_stream_name(SND_PCM_STREAM_PLAYBACK);
|
snd_pcm_stream_name(SND_PCM_STREAM_PLAYBACK);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -68,6 +66,7 @@ QList<DeviceFinder::Device> AlsaDeviceFinder::ListDevices() {
|
|||||||
|
|
||||||
char name[32];
|
char name[32];
|
||||||
sprintf(name, "hw:%d", card);
|
sprintf(name, "hw:%d", card);
|
||||||
|
|
||||||
result = snd_ctl_open(&handle, name, 0);
|
result = snd_ctl_open(&handle, name, 0);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
qLog(Error) << "Unable to open soundcard" << card << ":" << snd_strerror(result);
|
qLog(Error) << "Unable to open soundcard" << card << ":" << snd_strerror(result);
|
||||||
@ -93,14 +92,13 @@ QList<DeviceFinder::Device> AlsaDeviceFinder::ListDevices() {
|
|||||||
snd_pcm_info_set_device(pcminfo, dev);
|
snd_pcm_info_set_device(pcminfo, dev);
|
||||||
snd_pcm_info_set_subdevice(pcminfo, 0);
|
snd_pcm_info_set_subdevice(pcminfo, 0);
|
||||||
snd_pcm_info_set_stream(pcminfo, SND_PCM_STREAM_PLAYBACK);
|
snd_pcm_info_set_stream(pcminfo, SND_PCM_STREAM_PLAYBACK);
|
||||||
|
|
||||||
result = snd_ctl_pcm_info(handle, pcminfo);
|
result = snd_ctl_pcm_info(handle, pcminfo);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
if (result != -ENOENT) qLog(Error) << "Unable to get control digital audio info for card" << card << ":" << snd_strerror(result);
|
if (result != -ENOENT) qLog(Error) << "Unable to get control digital audio info for card" << card << ":" << snd_strerror(result);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
snd_pcm_info_get_name(pcminfo);
|
|
||||||
|
|
||||||
Device device;
|
Device device;
|
||||||
device.description = QString("%1 %2").arg(snd_ctl_card_info_get_name(cardinfo)).arg(snd_pcm_info_get_name(pcminfo));
|
device.description = QString("%1 %2").arg(snd_ctl_card_info_get_name(cardinfo)).arg(snd_pcm_info_get_name(pcminfo));
|
||||||
device.value = QString("hw:%1,%2").arg(card).arg(dev);
|
device.value = QString("hw:%1,%2").arg(card).arg(dev);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user