@@ -846,14 +846,6 @@ func (s *Server) handleListener(w http.ResponseWriter, r *http.Request) {
846846 w .Header ().Set ("X-Accel-Buffering" , "no" )
847847 }
848848
849- // ICY Metadata negotiation
850- metaint := 0
851- if r .Header .Get ("Icy-MetaData" ) == "1" {
852- metaint = 16000 // Standard interval
853- w .Header ().Set ("icy-metaint" , "16000" )
854- w .Header ().Set ("icy-name" , s .Config .PageTitle )
855- }
856-
857849 flusher , _ := w .(http.Flusher )
858850 id := r .RemoteAddr + "-" + fmt .Sprintf ("%d" , time .Now ().UnixNano ())
859851 logrus .WithFields (logrus.Fields {"mount" : mount , "ip" : r .RemoteAddr , "ua" : r .Header .Get ("User-Agent" )}).Info ("Listener connected" )
@@ -889,6 +881,16 @@ func (s *Server) handleListener(w http.ResponseWriter, r *http.Request) {
889881 return
890882 }
891883
884+ // ICY Metadata negotiation
885+ metaint := 0
886+ // Ogg/Opus handles its own metadata. Injecting ICY metadata into an Ogg
887+ // stream corrupts the framing and causes CRC errors.
888+ if r .Header .Get ("Icy-MetaData" ) == "1" && ! stream .IsOgg () {
889+ metaint = 16000 // Standard interval
890+ w .Header ().Set ("icy-metaint" , "16000" )
891+ w .Header ().Set ("icy-name" , s .Config .PageTitle )
892+ }
893+
892894 if s .Config .MaxListeners > 0 && stream .ListenersCount () >= s .Config .MaxListeners {
893895 http .Error (w , "Server Full" , http .StatusServiceUnavailable )
894896 return
0 commit comments