add return error code

This commit is contained in:
Lei Kang
2025-09-05 16:15:34 -07:00
parent 8cd08c4280
commit dd145ac720
2 changed files with 8 additions and 5 deletions
+4 -4
View File
@@ -86,15 +86,15 @@ func NewDecoder(p prop.Media) (Decoder, error) {
}, nil
}
func (d *Decoder) Decode(data []byte) {
func (d *Decoder) Decode(data []byte) error {
if len(data) == 0 {
return
return fmt.Errorf("empty data")
}
status := C.decodeFrame(d.codec, (*C.uint8_t)(&data[0]), C.uint(len(data)))
if status != C.VPX_CODEC_OK {
fmt.Println("Decode failed", status)
panic("Decode failed")
return fmt.Errorf("Decode failed: %v", status)
}
return nil
}
func (d *Decoder) GetFrame() *VpxImage {