mirror of
				https://github.com/AlexxIT/go2rtc.git
				synced 2025-10-31 03:36:30 +08:00 
			
		
		
		
	Fix empty streams json on stream lock
This commit is contained in:
		| @@ -198,8 +198,12 @@ producers: | |||||||
| //} | //} | ||||||
|  |  | ||||||
| func (s *Stream) MarshalJSON() ([]byte, error) { | func (s *Stream) MarshalJSON() ([]byte, error) { | ||||||
|  | 	if !s.mu.TryLock() { | ||||||
|  | 		log.Warn().Msgf("[streams] json locked") | ||||||
|  | 		return []byte(`null`), nil | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	var v []interface{} | 	var v []interface{} | ||||||
| 	s.mu.Lock() |  | ||||||
| 	for _, prod := range s.producers { | 	for _, prod := range s.producers { | ||||||
| 		if prod.element != nil { | 		if prod.element != nil { | ||||||
| 			v = append(v, prod.element) | 			v = append(v, prod.element) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Alexey Khit
					Alexey Khit