ref: 20614fd8f8ef258b5930d849d4263487daad9014
parent: 4ec0a1a2712acc48ba2f52dfa760aa25bcb07c85
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Sun May 7 21:02:34 EDT 2023
fall back to internal/fixed output if speakers are not available
--- a/jacksense.c
+++ b/jacksense.c
@@ -12,7 +12,7 @@
void
main(int argc, char **argv)
{
- int hp, sp, cmd, ctl, vol, lastvol, newvol;
+ int hp, sp, lp, cmd, ctl, vol, lastvol, newvol;
int debug, hpsafevol, spsafevol;
u32int x, y[4], has, had, c;
char *s, *a[16], tmp[32];
@@ -45,6 +45,7 @@
sysfatal("%r");
sp = -1;
hp = -1;
+ lp = -1;
while((sp < 0 || hp < 0) && (s = Brdline(b, '\n')) != nil){
s[Blinelen(b)-1] = 0;
if(tokenize(s, a, nelem(a)) < 8)
@@ -55,12 +56,20 @@
hp = atoi(a[1]);
if(debug) fprint(2, "hpout pin %d\n", hp);
}
- if(strcmp(a[3], "fix") == 0 && strcmp(a[6], "speaker") == 0){
- sp = atoi(a[1]);
- if(debug) fprint(2, "speaker pin %d\n", sp);
+ if(strcmp(a[3], "fix") == 0){
+ if(strcmp(a[6], "speaker") == 0){
+ sp = atoi(a[1]);
+ if(debug) fprint(2, "speaker pin %d\n", sp);
+ }else if(strcmp(a[4], "int") == 0){
+ /* fallback for built-in speakers/etc */
+ lp = atoi(a[1]);
+ if(debug) fprint(2, "speaker fallback pin %d\n", sp);
+ }
}
}
Bterm(b);
+ if(sp < 0)
+ sp = lp;
if(sp < 0 || hp < 0){
fprint(2, "couldn't detect pins\n");
exits("pins");