|
|
|
@@ -140,7 +140,8 @@ type IngestAES67DiscoveryConfig struct { |
|
|
|
|
|
|
|
func Default() Config { |
|
|
|
return Config{ |
|
|
|
Audio: AudioConfig{Gain: 1.0, ToneLeftHz: 1000, ToneRightHz: 1600, ToneAmplitude: 0.4}, |
|
|
|
// BUG-C fix: tones off by default (was 0.4 — caused unintended audio output). |
|
|
|
Audio: AudioConfig{Gain: 1.0, ToneLeftHz: 1000, ToneRightHz: 1600, ToneAmplitude: 0}, |
|
|
|
RDS: RDSConfig{Enabled: true, PI: "1234", PS: "FMRTX", RadioText: "fm-rds-tx", PTY: 0}, |
|
|
|
FM: FMConfig{ |
|
|
|
FrequencyMHz: 100.0, |
|
|
|
@@ -256,8 +257,9 @@ func (c Config) Validate() error { |
|
|
|
if c.Audio.Gain < 0 || c.Audio.Gain > 4 { |
|
|
|
return fmt.Errorf("audio.gain out of range") |
|
|
|
} |
|
|
|
if c.Audio.ToneLeftHz <= 0 || c.Audio.ToneRightHz <= 0 { |
|
|
|
return fmt.Errorf("audio tone frequencies must be positive") |
|
|
|
// BUG-B fix: only enforce positive freq when amplitude is non-zero. |
|
|
|
if c.Audio.ToneAmplitude > 0 && (c.Audio.ToneLeftHz <= 0 || c.Audio.ToneRightHz <= 0) { |
|
|
|
return fmt.Errorf("audio tone frequencies must be positive when toneAmplitude > 0") |
|
|
|
} |
|
|
|
if c.Audio.ToneAmplitude < 0 || c.Audio.ToneAmplitude > 1 { |
|
|
|
return fmt.Errorf("audio.toneAmplitude out of range") |
|
|
|
@@ -411,11 +413,15 @@ func (c Config) Validate() error { |
|
|
|
if c.Ingest.Icecast.RadioText.MaxLen < 0 || c.Ingest.Icecast.RadioText.MaxLen > 64 { |
|
|
|
return fmt.Errorf("ingest.icecast.radioText.maxLen out of range (0-64)") |
|
|
|
} |
|
|
|
// Fail-loud PI validation |
|
|
|
if c.RDS.Enabled { |
|
|
|
// BUG-D fix: validate PI whenever non-empty, not only when RDS is enabled. |
|
|
|
// An invalid PI stored in config causes a silent failure when RDS is later |
|
|
|
// enabled via live-patch. |
|
|
|
if strings.TrimSpace(c.RDS.PI) != "" { |
|
|
|
if _, err := ParsePI(c.RDS.PI); err != nil { |
|
|
|
return fmt.Errorf("rds config: %w", err) |
|
|
|
} |
|
|
|
} else if c.RDS.Enabled { |
|
|
|
return fmt.Errorf("rds.pi is required when rds.enabled is true") |
|
|
|
} |
|
|
|
if c.RDS.PTY < 0 || c.RDS.PTY > 31 { |
|
|
|
return fmt.Errorf("rds.pty out of range (0-31)") |
|
|
|
|