diff options
-rwxr-xr-x | aataaj.lua | 39 |
1 files changed, 34 insertions, 5 deletions
@@ -226,7 +226,7 @@ local cards = __'ls -d1 /proc/asound/card[0-9]*':noErr():Do() | |||
226 | for i,l in ipairs(cards.lines) do | 226 | for i,l in ipairs(cards.lines) do |
227 | local f, e = io.open(l .. '/id', "r") | 227 | local f, e = io.open(l .. '/id', "r") |
228 | if nil == f then print("Could not open " .. l .. '/id') else | 228 | if nil == f then print("Could not open " .. l .. '/id') else |
229 | Cards[l] = {path = l, name = f:read("*a"):sub(1, -2), devs = {}, captureDevs = {}, playbackDevs = {}} | 229 | Cards[l] = {path = l, name = f:read("*a"):sub(1, -2), devs = {}, captureDevs = {}, playbackDevs = {}, card=i} |
230 | if "Loopback" ~= Cards[l]['name'] then | 230 | if "Loopback" ~= Cards[l]['name'] then |
231 | Cards[l]['capture'] = __('ls -d1 ' .. l .. '/pcm[0-9]*c*'):noErr():Do() | 231 | Cards[l]['capture'] = __('ls -d1 ' .. l .. '/pcm[0-9]*c*'):noErr():Do() |
232 | for j,c in ipairs(Cards[l]['capture'].lines) do | 232 | for j,c in ipairs(Cards[l]['capture'].lines) do |
@@ -234,22 +234,51 @@ for i,l in ipairs(cards.lines) do | |||
234 | Cards[l]['captureDevs'][j] = n | 234 | Cards[l]['captureDevs'][j] = n |
235 | Cards[l]['devs'][n] = n | 235 | Cards[l]['devs'][n] = n |
236 | print("\tFound capture device: " .. Cards[l]['name'] .. "\tDEVICE: " .. Cards[l]['captureDevs'][j] .. ' ' .. n) | 236 | print("\tFound capture device: " .. Cards[l]['name'] .. "\tDEVICE: " .. Cards[l]['captureDevs'][j] .. ' ' .. n) |
237 | io.flush() | ||
237 | end | 238 | end |
238 | Cards[l]['playback'] = __('ls -d1 ' .. l .. '/pcm[0-9]*p*'):noErr():Do() | 239 | Cards[l]['playback'] = __('ls -d1 ' .. l .. '/pcm[0-9]*p*'):noErr():Do() |
239 | for j,p in ipairs(Cards[l]['playback'].lines) do | 240 | for j,p in ipairs(Cards[l]['playback'].lines) do |
240 | local n = p:match(".*pcm(%d+).*") | 241 | local n = p:match(".*pcm(%d+).*") |
241 | Cards[l]['playbackDevs'][j] = n | 242 | Cards[l]['playbackDevs'][j] = n |
242 | Cards[l]['devs'][n] = n | 243 | Cards[l]['devs'][n] = n |
243 | print("\tFound playback device " .. i - 1 .. " : " .. Cards[l]['name'] .. "\tDEVICE: " .. Cards[l]['playbackDevs'][j] .. ' ' .. n) | 244 | print("\tFound playback device " .. Cards[l].card - 1 .. " : " .. Cards[l]['name'] .. "\tDEVICE: " .. Cards[l]['playbackDevs'][j] .. ' ' .. n) |
245 | io.flush() | ||
244 | if 'JACK' ~= args[1] then | 246 | if 'JACK' ~= args[1] then |
245 | print('\t\tALSA_CARD=' .. i - 1 .. ' ' .. speaker .. ' "Found playback device ' .. i - 1 .. ' : ' .. Cards[l]['name'] .. ' DEVICE: ' .. Cards[l]['playbackDevs'][j] .. ' ' .. n .. '"') | 247 | print('\t\tALSA_CARD=' .. Cards[l].card - 1 .. ' ' .. speaker .. ' "Found playback device ' .. Cards[l].card - 1 .. ' : ' .. Cards[l]['name'] .. ' DEVICE: ' .. Cards[l]['playbackDevs'][j] .. ' ' .. n .. '"') |
246 | __('ALSA_CARD=' .. i - 1 .. ' ' .. speaker .. ' "Found playback device ' .. i - 1 .. ' : ' .. Cards[l]['name'] .. ' DEVICE: ' .. Cards[l]['playbackDevs'][j] .. ' ' .. n .. '"'):noErr():noOut():Do() | 248 | io.flush() |
247 | __'sleep 1':Do() | ||
248 | end | 249 | end |
249 | end | 250 | end |
250 | end | 251 | end |
251 | end | 252 | end |
252 | end | 253 | end |
254 | print('') | ||
255 | io.flush() | ||
256 | |||
257 | -- TODO - No idea why the fuck #Cards kept telling me 0. | ||
258 | local cnt = 0 | ||
259 | for i,C in pairs(Cards) do | ||
260 | cnt = cnt + 1 | ||
261 | end | ||
262 | |||
263 | print('Your ' .. cnt .. ' audio devices are ') | ||
264 | for i,C in pairs(Cards) do | ||
265 | print('' .. C.card - 1 .. ' : ' .. C.name) | ||
266 | __('ALSA_CARD=' .. C.card - 1 .. ' ' .. speaker .. ' "Your ' .. cnt .. ' audio devices are "'):log():noErr():noOut():fork() | ||
267 | end | ||
268 | -- TODO - should do a proper "wait for speakers to finish" here. Have fork(write a file), think that's what :wait(file) does. | ||
269 | __'sleep 6':Do() | ||
270 | print('') | ||
271 | io.flush() | ||
272 | for i,C in pairs(Cards) do | ||
273 | print('' .. C.card - 1 .. ' : ' .. C.name) | ||
274 | __('echo "' .. C.card - 1 .. ' : ' .. C.name .. '"') | ||
275 | __('ALSA_CARD=' .. C.card - 1 .. ' ' .. speaker .. ' "Device ' .. C.card - 1 .. ' ' .. C.name .. '"'):log():noErr():noOut():Do() | ||
276 | io.flush() | ||
277 | __'sleep 1':Do() | ||
278 | end | ||
279 | print('') | ||
280 | io.flush() | ||
281 | |||
253 | 282 | ||
254 | if 'start' == args[1] then | 283 | if 'start' == args[1] then |
255 | __('mkdir -p ' .. asoundrcPath):Do() | 284 | __('mkdir -p ' .. asoundrcPath):Do() |