mirror of
https://github.com/alsa-project/alsa-tools.git
synced 2025-10-29 05:40:25 -04:00
Karsten Wiese <annabellesgarden@yahoo.de>:
- Two Segmentation fault spots cleared.
This commit is contained in:
parent
ae6ba4c872
commit
e6764b8a6c
5 changed files with 31 additions and 12 deletions
|
|
@ -38,7 +38,8 @@ void us428_lights::init_us428_lights()
|
|||
|
||||
void Cus428State::InitDevice(void)
|
||||
{
|
||||
SliderChangedTo(eFaderM, ((unsigned char*)(us428ctls_sharedmem->CtlSnapShot + us428ctls_sharedmem->CtlSnapShotLast))[eFaderM]);
|
||||
if (us428ctls_sharedmem->CtlSnapShotLast >= 0)
|
||||
SliderChangedTo(eFaderM, ((unsigned char*)(us428ctls_sharedmem->CtlSnapShot + us428ctls_sharedmem->CtlSnapShotLast))[eFaderM]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -36,26 +36,29 @@ Cus428_ctls::dump(int n)
|
|||
}
|
||||
|
||||
void
|
||||
Cus428_ctls::analyse(Cus428_ctls& Previous, unsigned n)
|
||||
Cus428_ctls::analyse(Cus428_ctls *Previous, unsigned n)
|
||||
{
|
||||
Cus428_ctls *PreviousL = Previous ? Previous : new Cus428_ctls();
|
||||
OneState->Set_us428_ctls(this);
|
||||
for (; n < 9; n++) { //Sliders
|
||||
char Diff = ((unsigned char*)this)[n] - ((unsigned char*)&Previous)[n];
|
||||
char Diff = DiffValAt(PreviousL, n);
|
||||
if (Diff)
|
||||
OneState->SliderChangedTo(n, ((unsigned char*)this)[n]);
|
||||
OneState->SliderChangedTo(n, ValAt(n));
|
||||
}
|
||||
for (; n < 16; n++) { //Knobs
|
||||
unsigned char Diff = ((unsigned char*)this)[n] ^ ((unsigned char*)&Previous)[n];
|
||||
unsigned char Diff = DiffBitAt(PreviousL, n);
|
||||
unsigned o = 0;
|
||||
while (o < 8) {
|
||||
if (Diff & (1 << o))
|
||||
OneState->KnobChangedTo((Cus428State::eKnobs)(8*n + o), ((unsigned char*)this)[n] & (1 << o));
|
||||
OneState->KnobChangedTo((Cus428State::eKnobs)(8*n + o), ValAt(n) & (1 << o));
|
||||
++o;
|
||||
}
|
||||
}
|
||||
for (; n < sizeof(*this); n++) { //wheels
|
||||
char Diff = ((unsigned char*)this)[ n] - ((unsigned char*)&Previous)[n];
|
||||
char Diff = DiffValAt(PreviousL, n);
|
||||
if (Diff)
|
||||
OneState->WheelChangedTo((E_In84)n, Diff);
|
||||
}
|
||||
}
|
||||
if (0 == Previous)
|
||||
delete PreviousL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,11 +25,24 @@
|
|||
|
||||
class Cus428_ctls: public us428_ctls{
|
||||
public:
|
||||
Cus428_ctls() {
|
||||
memset(this, 0, sizeof(*this));
|
||||
}
|
||||
void dump(int n = 0);
|
||||
void analyse(Cus428_ctls& Previous, unsigned n = 0);
|
||||
void analyse(Cus428_ctls *Previous, unsigned n = 0);
|
||||
bool Knob( int K) {
|
||||
return ((char*)this)[K / 8] & (1 << K % 8);
|
||||
}
|
||||
protected:
|
||||
unsigned char ValAt(int i) {
|
||||
return ((unsigned char*)this)[i];
|
||||
}
|
||||
unsigned char DiffValAt(Cus428_ctls *Other, int i) {
|
||||
return ValAt(i) - Other->ValAt(i);
|
||||
}
|
||||
unsigned char DiffBitAt(Cus428_ctls *Other, int i) {
|
||||
return ValAt(i) ^ Other->ValAt(i);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
AC_INIT(us428control.cc)
|
||||
AM_INIT_AUTOMAKE(us428control, 0.4)
|
||||
AM_INIT_AUTOMAKE(us428control, 0.4.1)
|
||||
AC_PROG_CXX
|
||||
AC_PROG_INSTALL
|
||||
AC_HEADER_STDC
|
||||
|
|
|
|||
|
|
@ -121,14 +121,16 @@ int US428Control(const char* DevName)
|
|||
if (verbose > 1)
|
||||
printf("Last is %i\n", Last);
|
||||
while (us428ctls_sharedmem->CtlSnapShotRed != Last) {
|
||||
static Cus428_ctls *Red = 0;
|
||||
int Read = us428ctls_sharedmem->CtlSnapShotRed + 1;
|
||||
if (Read >= N_us428_ctl_BUFS)
|
||||
if (Read >= N_us428_ctl_BUFS || Read < 0)
|
||||
Read = 0;
|
||||
Cus428_ctls* PCtlSnapShot = ((Cus428_ctls*)(us428ctls_sharedmem->CtlSnapShot)) + Read;
|
||||
int DiffAt = us428ctls_sharedmem->CtlSnapShotDiffersAt[Read];
|
||||
if (verbose > 1)
|
||||
PCtlSnapShot->dump(DiffAt);
|
||||
PCtlSnapShot->analyse(((Cus428_ctls*)(us428ctls_sharedmem->CtlSnapShot))[us428ctls_sharedmem->CtlSnapShotRed], DiffAt );
|
||||
PCtlSnapShot->analyse(Red, DiffAt);
|
||||
Red = PCtlSnapShot;
|
||||
us428ctls_sharedmem->CtlSnapShotRed = Read;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue