WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: TCE 10.0 32bit, flit.tcz, Lenovo b4030  (Read 6335 times)

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11632
Re: TCE 10.0 32bit, flit.tcz, Lenovo b4030
« Reply #15 on: March 04, 2019, 09:33:51 AM »
Hi chattrhand
Here's the problem:
no sound found
Playback open error: -2 No such file or directory
For whatever reason, the sound system isn't ready.

Quote
# /home/tc/.X.d/autostart
sleep 1
[ $(which flit) ] && flit > ~/flit.txt &
sleep 1
speaker-test -c2 -t wav -l1 &
Try increasing the first sleep command to see if it's timing related.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: TCE 10.0 32bit, flit.tcz, Lenovo b4030
« Reply #16 on: March 05, 2019, 01:07:23 AM »
no sound found
Playback open error: -2 No such file or directory

Is it possible that you have more than one sound device, for example hdmi and analogue, and the default could change on reboot?

For me, if hdmi comes up as default, flit will not find any sound device. If analogue comes up as default, things work fine.

One other thing I have noticed is that if the sound volume is adjusted via flit, it is not saved and reverts to the default volume on reboot.

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11632
Re: TCE 10.0 32bit, flit.tcz, Lenovo b4030
« Reply #17 on: March 05, 2019, 09:09:11 AM »
Hi Juanito
... One other thing I have noticed is that if the sound volume is adjusted via flit, it is not saved and reverts to the default volume on reboot.
Wouldn't adding  alsactl store  to  shutdown.sh  fix that?

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11632
Re: TCE 10.0 32bit, flit.tcz, Lenovo b4030
« Reply #18 on: March 05, 2019, 10:54:24 PM »
Hi Juanito
... One other thing I have noticed is that if the sound volume is adjusted via flit, it is not saved and reverts to the default volume on reboot.
I worked out the code for saving and restoring the volume if you are interested. There is one caveat however. I think there's a
truncation error in the volume calculations. Place the mouse cursor over flits speaker symbol and wait for the tool tip to pop up
with the current volume level. Using the mouses scroll wheel, alternate one click up, one click down, one click up, etc. You'll
see the volume level takes larger steps going down than going up. The error gets smaller as the volume level drops. It appears
to be caused by converting 0 to 100 volume levels to the mixers 0 to 31 scale and back again. Set versus read back values
look like this:
Code: [Select]
Set   Read
100    100
 90     87
 80     77
 70     67
 60     58
 50     48
 40     38
 30     29
 20     19
 10      9
  0      0

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: TCE 10.0 32bit, flit.tcz, Lenovo b4030
« Reply #19 on: March 07, 2019, 01:01:18 AM »
Using the mouses scroll wheel, alternate one click up, one click down, one click up, etc.

I didn't realise you could do that - this thing is smarter than it looks  :)

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: TCE 10.0 32bit, flit.tcz, Lenovo b4030
« Reply #20 on: March 07, 2019, 05:58:13 AM »
flit updated to latest version in tinycore git

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11632
Re: TCE 10.0 32bit, flit.tcz, Lenovo b4030
« Reply #21 on: March 08, 2019, 01:52:36 AM »
Hi Juanito
If you're interested in trying it, I've attached a patch to update flit. Changes are:
1. Sound volume is now saved when you click on  Save configuration.
2. ALSA Audio level calculations rewritten to round instead of truncate.
3. Lowered the volume stepsize to better fit ALSAs 5 bit (0-31) volume level range.

Here are the changes if anyone wants to scroll through them:
Code: [Select]
--- flit.cpp.old 2019-03-05 11:52:44.186716596 +0000
+++ flit.cpp 2019-03-08 01:27:08.107952046 +0000
@@ -1,5 +1,13 @@
 // flit.cpp -- Flit is a "tray" with clock, sound, and battery applets
 
+// Version 1.3.2 Added: saved_volume variable
+// Updated: get_config and save_config to allow saving and restoring
+// volume level between sessions.
+// Rewrote: ALSA and newvol Audio level calculations to round instead of truncate.
+// Old versions are commented out with //RR, new versions in following line.
+// Updated: Lowered volume stepsize to 3% from 5% in do_sound_adj to fit better in
+// ALSAs 5 bit (0-31) volume level range.
+
 // Version 1.3.1 - M. Losh - Fix to make file to preserve root perms in /usr when installed   
 
 // Version 1.3.0 - M. Losh - Released with changes to default values of custom colors
@@ -114,7 +122,7 @@
 #define MIN(a, b)   (((a) < (b)) ? (a):(b))
 #endif
 
-#define APP_VER "1.3.1" // Last update 2011-07-23
+#define APP_VER "1.3.2" // Last update 2019-03-08
 #define PROG    "flit"
 #define METER_W     28
 #define SOUND_W     28
@@ -135,6 +143,9 @@
 const char *argp_program_version = PROGNAME_VERSION;
 const char *argp_program_bug_address = "<mlockmoore@gmail.com>; <jbysewski@googlemail.com>";
 
+// Volume level saved in config file.
+int saved_volume = -1;
+
 // This structure is used by main to communicate with parse_opt
 struct arguments
 {
@@ -803,7 +814,8 @@
                             rvol = v;
                         }
                         if (lvol >= 0 && rvol >= 0 && (mix_max > mix_min)) {
-                            pct = (int)(((float)(rvol + lvol)) * 100.0 / (2.0 * (float)(mix_max - mix_min)));
+//RR                            pct = (int)(((float)(rvol + lvol)) * 100.0 / (2.0 * (float)(mix_max - mix_min)));
+ pct = (int)(roundf(((rvol + lvol) * (100.0 / ((float)(mix_max - mix_min) * 2.0)))));
 #ifdef DIAG
                             printf("Sound level is %d %%\n", pct);
 #endif
@@ -826,7 +838,11 @@
             oss_mixer_value vr;
             int newvol;
             int intended;
-            newvol = (int)((float)(vol * mix_max) / 100.0) - mix_min;
+//RR            newvol = (int)((float)(vol * mix_max) / 100.0) - mix_min;
+            newvol = (int)(roundf((vol * ((float)(mix_max - mix_min) / 100.0))));
+#ifdef DIAG
+            printf("vol=%d newvol=%d mix_max=%d mix_min=%d\n", vol, newvol, mix_max, mix_min);
+#endif
             if (sound_type == SOUND_TYPE_OSS && mixer_fd && mix_ctrl) {
                 info.dev = 0;
                 info.ctrl = mix_ctrl;               
@@ -908,7 +924,8 @@
                         }
                     }
                     if (lvol >= 0 && rvol >= 0 && (mix_max > mix_min)) {
-                        actual_pct = (rvol + lvol) * 100.0 / (2.0 * (mix_max - mix_min));
+//RR                        actual_pct = (rvol + lvol) * 100.0 / (2.0 * (mix_max - mix_min));
+ actual_pct = (int)(roundf(((rvol + lvol) * (100.0 / ((float)(mix_max - mix_min) * 2.0)))));
 #ifdef DIAG
                         printf("Sound level after change is actually %d %%\n", actual_pct);
 #endif
@@ -1255,12 +1272,12 @@
             vol = sound_p->value();
             if (direction < 0) {
                 prev_sound_vol = vol;
-                vol -= 5;
+                vol -= 3;
                 if (vol < 0) vol = 0;
             }
             else if (direction > 0) {
                 prev_sound_vol = vol;
-                vol += 5;
+                vol += 3;
                 if (vol > 100) vol = 100;
             }
             else {
@@ -1427,6 +1444,14 @@
 #endif
                         
                     }
+                    else if (1 == sscanf(confline, "sound_volume_level = %d\n", &n)) {
+#ifdef DIAG     
+                        printf("volume is %d\n", n);
+#endif
+                        if((n >= 0) && (n <= 100))
+ saved_volume = n;
+                    }
+
                     else if (1 == sscanf(confline, "show24hr = %d\n", &n)) {
 #ifdef DIAG     
                         printf("show24hr is %d\n", n);
@@ -1684,6 +1709,9 @@
                 fprintf(cfgf, "# OSS/ALSA sound control name to use, autosel means 'try to pick for me'\n");
                 fprintf(cfgf, "sound_control_name = %s\n", sound_control_name);
                 fprintf(cfgf, "\n");
+                fprintf(cfgf, "# OSS/ALSA sound volume level (0 to 100)\n");
+                fprintf(cfgf, "sound_volume_level = %d\n", sound_p->value());
+                fprintf(cfgf, "\n");
                 fprintf(cfgf, "# Automatically pop up right-click menu when Ctrl key is first pressed (1 = do, 0 = don't)\n");
                 fprintf(cfgf, "menu_hotkey_activation = %d\n", menu_hotkey_activation);
                 fprintf(cfgf, "\n");
@@ -1858,6 +1886,13 @@
         make_window_dock();   
     }
 
+ if(saved_volume >= 0)
+ {
+ MainWnd.set_sound_level(saved_volume);
+#ifdef DIAG
+ printf("saved_volume=%d\n", saved_volume);
+#endif
+ }
     //XSetInputFocus(fl_display, PointerRoot, RevertToPointerRoot, CurrentTime);
     while(Running) {
         Fl::wait(5.0);

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: TCE 10.0 32bit, flit.tcz, Lenovo b4030
« Reply #22 on: March 08, 2019, 03:58:44 AM »
Thanks - flit updated in the repos and tinycore git