From 6090a26f174a0380450884496a5463171600d25a Mon Sep 17 00:00:00 2001 From: dvs1 Date: Thu, 31 Oct 2024 16:03:33 +1000 Subject: Filter out non audio devices and Loopback type things. --- aataaj.lua | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'aataaj.lua') diff --git a/aataaj.lua b/aataaj.lua index 99cf9ff..5f043a7 100755 --- a/aataaj.lua +++ b/aataaj.lua @@ -147,29 +147,33 @@ print('Scanning for audio devices.') local cards = __'ls -d1 /proc/asound/card[0-9]*':noErr():Do() for i,l in ipairs(cards.lines) do local f, e = io.open(l .. '/id', 'r') + local g, h = io.open(l .. '/codec#0', 'r') -- Test to see if it's a real audio device. I think this is a real test. lol + local a, b = io.open(l .. '/stream0', 'r') -- Test to see if it's a real audio device. I think this is a real test. lol if nil == f then print('Could not open ' .. l .. '/id - ' .. e) else - local n = f:read('*a'):sub(1, -2) - Cards[n] = {path = l, name = n, devs = {}, captureDevs = {}, playbackDevs = {}, card=i} - cnt = cnt + 1 - if 'Loopback' ~= Cards[n]['name'] then - Cards[n]['capture'] = __('ls -d1 ' .. l .. '/pcm[0-9]*c*'):noErr():Do() - for j,c in ipairs(Cards[n]['capture'].lines) do - local m = c:match('.*pcm(%d+).*') - Cards[n]['captureDevs'][j] = m - Cards[n]['devs'][m] = m - print('\tFound capture device: ' .. Cards[n]['name'] .. '\tDEVICE: ' .. Cards[n]['captureDevs'][j] .. ' ' .. m) - io.flush() - end - Cards[n]['playback'] = __('ls -d1 ' .. l .. '/pcm[0-9]*p*'):noErr():Do() - for j,p in ipairs(Cards[n]['playback'].lines) do - local m = p:match('.*pcm(%d+).*') - Cards[n]['playbackDevs'][j] = m - Cards[n]['devs'][m] = m - print('\tFound playback device ' .. Cards[n].card - 1 .. ' : ' .. Cards[n]['name'] .. '\tDEVICE: ' .. Cards[n]['playbackDevs'][j] .. ' ' .. m) - io.flush() - if 'JACK' ~= arg[1] then - print('\t\tALSA_CARD=' .. Cards[n].card - 1 .. ' ' .. speaker .. ' "Found playback device ' .. Cards[n].card - 1 .. ' : ' .. Cards[n]['name'] .. ' DEVICE: ' .. Cards[n]['playbackDevs'][j] .. ' ' .. m .. '"') - io.flush() + if (nil ~= g) or (nil ~= a) then + local n = f:read('*a'):sub(1, -2) + Cards[n] = {path = l, name = n, devs = {}, captureDevs = {}, playbackDevs = {}, card=i} + cnt = cnt + 1 + if 'Loopback' ~= Cards[n]['name'] then + Cards[n]['capture'] = __('ls -d1 ' .. l .. '/pcm[0-9]*c*'):noErr():Do() + for j,c in ipairs(Cards[n]['capture'].lines) do + local m = c:match('.*pcm(%d+).*') + Cards[n]['captureDevs'][j] = m + Cards[n]['devs'][m] = m + print('\tFound capture device: ' .. Cards[n]['name'] .. '\tDEVICE: ' .. Cards[n]['captureDevs'][j] .. ' ' .. m) +-- io.flush() + end + Cards[n]['playback'] = __('ls -d1 ' .. l .. '/pcm[0-9]*p*'):noErr():Do() + for j,p in ipairs(Cards[n]['playback'].lines) do + local m = p:match('.*pcm(%d+).*') + Cards[n]['playbackDevs'][j] = m + Cards[n]['devs'][m] = m + print('\tFound playback device ' .. Cards[n].card - 1 .. ' : ' .. Cards[n]['name'] .. '\tDEVICE: ' .. Cards[n]['playbackDevs'][j] .. ' ' .. m) +-- io.flush() + if 'JACK' ~= arg[1] then +-- print('\t\tALSA_CARD=' .. Cards[n].card - 1 .. ' ' .. speaker .. ' "Found playback device ' .. Cards[n].card - 1 .. ' : ' .. Cards[n]['name'] .. ' DEVICE: ' .. Cards[n]['playbackDevs'][j] .. ' ' .. m .. '"') +-- io.flush() + end end end end -- cgit v1.1