An error occurred during uninstalling FTOEQU, causing the system to crash

Discussion about writing software for VS1005 and the VSOS Operating System. Also posts about VS1005-related hardware design and device drivers should be posted here.
Post Reply
shehold
User
Posts: 19
Joined: Tue 2023-01-31 8:51

An error occurred during uninstalling FTOEQU, causing the system to crash

Post by shehold »

play AUXPLAY.DL3
after I load FTOEQU(DRIVER +FTOEQU), I run 8 EQ, this time it works normally, when I stop FTOEQU(DRIVER -FTOEQU), there is a crash, the system prompts the following, what is the reason?

Code: Select all

Installed system devices:
S:  896K SPI Flash c213, handled by FAT.
Load drivers, config 0...
Driver: UARTIN... 
Driver: S:SHELL.AP3... 
VSOS SHELL
S:>DRIVER +AUXI2SM S
S:>DRIVER +AUXPLAY
S:>DRIVER +FTOEQU
 ----S:>SETEQU 1--8
 //In good working order 
 
S:>DRIVER -FTOEQU
E'Call to dropped lib! encnt=0, last vector 0xf'
ZeroPtrCall from 7883(0x1ecb)
//System's dead. There's no sound. We need to reboot
 
User avatar
Henrik
VLSI Staff
Posts: 1295
Joined: Tue 2010-06-22 14:10

Re: An error occurred during uninstalling FTOEQU, causing the system to crash

Post by Henrik »

Hello!

I can confirm your symptoms. I also have an explanation and a solution.

First let me explain what goes wrong. This is a subtle thing, not very obvious at all.

THE ISSUE

In VSOS we have two standard audio file handles: stdaudioin and stdaudioout. In your configuration they
are by default not defined, i.e. they are NULL pointers:
NULL -> (NOTHING) -> NULL

When you load auxi2sm.dl3, you populate both stdaudioin and stdaudioout. So, now you have two file handles, but nothing yet in between:
stdaudioin(auxi2sm) -> (NOTHING) -> stdaudiout(auxi2sm)

Now you load AUXPLAY. AuxPlay reads data from stdaudioin and writes it to stdaudioout. So now we have the following audio chain:
stdaudioin(auxi2sm) -> AUXPLAY -> stdaudiout(auxi2sm)

Now you load FtOEqu. FtOEqu connects to the original driver that is there in stdaudioout, replaces it with itself, and then starts running all data sent to stdaudioout through itself:
stdaudioin(auxi2sm) -> AUXPLAY -> stdaudiout(ftoequ) -> (auxi2sm)

Now, when you unload FtOEqu from memory, if reverses its operation by removing itself from the audio path, and restoring stdaudioout to point to the original driver, then FtOEqu is removed from memory. So the audio path will again look like this:
stdaudioin(auxi2sm) -> AUXPLAY -> stdaudiout(auxi2sm)

However, and here comes the problem: when FtOEqu removes itself from the audio path and memory, a call by AUXPLAY to FtOEqu may still be going on. So we are essentially calling a library that has been removed from memory, and you end up with exactly the kind of crash you have seen.

SOLUTION #1

This is kind of an easy way out: don't remove FtOEqu from memory.
If this is not an option, there is the following alternative:

SOLUTION #2

Always remove AUXPLAY from memory before FtOEqu. That way AUXPLAY cannot call FtOEqu while FtOEqu is being removed from the audio path. For instance, like this:

Code: Select all

S:>driver -AUXPLAY
S:>driver -FTOEQU
The first command will restore the audio path to:
stdaudioin(auxi2sm) -> (NOTHING) -> stdaudiout(ftoequ) -> (auxi2sm)
... and the second one to ...
stdaudioin(auxi2sm) -> (NOTHING) -> stdaudiout(auxi2sm)

So this way the drivers unload peacefully. Then you can, if needed, reload one or both of the drivers.

Hope this helps!

Kind regards,
- Henrik
Good signatures never die. They just fade away.
shehold
User
Posts: 19
Joined: Tue 2023-01-31 8:51

Re: An error occurred during uninstalling FTOEQU, causing the system to crash

Post by shehold »

But this is not the result I want, because I am playing, deciding whether to load FTOEQU, if AUXPLAY is turned off and restarted, the sound will be cut out, which gives the customer a very bad experience. So I want to load FTOEQU at any time, and be able to stop it immediately when it's not needed without affecting the work being played
User avatar
Henrik
VLSI Staff
Posts: 1295
Joined: Tue 2010-06-22 14:10

Re: An error occurred during uninstalling FTOEQU, causing the system to crash

Post by Henrik »

Hello!
shehold wrote: Tue 2023-07-18 18:59 But this is not the result I want, because I am playing, deciding whether to load FTOEQU, if AUXPLAY is turned off and restarted, the sound will be cut out, which gives the customer a very bad experience. So I want to load FTOEQU at any time, and be able to stop it immediately when it's not needed without affecting the work being played
Ok, that's understandable.
Is it ok then to have FtOEqu loaded at all times, but in such a way that all filters are turned off when you don't want it to actively do anything? If all filters are turned off, FtOEqu acts as a pass-through "filter" and doesn't affect the samples at all.

Kind regards,
- Henrik
Good signatures never die. They just fade away.
User avatar
Henrik
VLSI Staff
Posts: 1295
Joined: Tue 2010-06-22 14:10

Re: An error occurred during uninstalling FTOEQU, causing the system to crash

Post by Henrik »

Just to add to the previous message, you can either turn all filters off by calling:

Code: Select all

SetEqu 1 0
SetEqu 2 0
[...]
SetEqu 16 0
... or from C code something like ...

Code: Select all

#include <aucommon.h>
#include <vsos.h>

int i;

for (i=0; i<16; i++) {
  struct FilterEqualizer fltEqu = {0};
  ioctl(fp, IOCTL_AUDIO_SET_EQU_FILTER, (void *)(&fltEqu));
}
Kind regards,
- Henrik
Good signatures never die. They just fade away.
Post Reply