package globals

import "sync"

var (
	adau1761lock sync.Mutex
	cureq        = ADAU1761_EQ_UNKNOW
	Seteq        func(eq int) error
)

type ADAU1761_EQ int

const (
	ADAU1761_EQ_UNKNOW ADAU1761_EQ = -1
	ADAU1761_EQ_NORMAL ADAU1761_EQ = 0
	ADAU1761_EQ_TTS    ADAU1761_EQ = 1
	ADAU1761_EQ_BYPASS ADAU1761_EQ = 2
)

func SetEq(eq ADAU1761_EQ) error {
	adau1761lock.Lock()
	defer adau1761lock.Unlock()
	if eq == cureq {
		return nil
	}

	if Seteq != nil {
		cureq = eq
		return Seteq(int(eq))
	}

	return nil
}
