2
0
Oleksandr Redko 2 жил өмнө
parent
commit
09205a8574
2 өөрчлөгдсөн 2 нэмэгдсэн , 6 устгасан
  1. 2 2
      device/device.go
  2. 0 4
      v4l2/format.go

+ 2 - 2
device/device.go

@@ -89,7 +89,7 @@ func Open(path string, options ...Option) (*Device, error) {
 	}
 
 	// set pix format
-	if !dev.config.pixFormat.IsZero() {
+	if dev.config.pixFormat != (v4l2.PixFormat{}) {
 		if err := dev.SetPixFormat(dev.config.pixFormat); err != nil {
 			return nil, fmt.Errorf("device open: %s: set format: %w", path, err)
 		}
@@ -199,7 +199,7 @@ func (d *Device) GetPixFormat() (v4l2.PixFormat, error) {
 		return v4l2.PixFormat{}, v4l2.ErrorUnsupportedFeature
 	}
 
-	if d.config.pixFormat.IsZero() {
+	if d.config.pixFormat == (v4l2.PixFormat{}) {
 		pixFmt, err := v4l2.GetPixFormat(d.fd)
 		if err != nil {
 			return v4l2.PixFormat{}, fmt.Errorf("device: %w", err)

+ 0 - 4
v4l2/format.go

@@ -278,10 +278,6 @@ func (f PixFormat) String() string {
 	)
 }
 
-func (f PixFormat) IsZero() bool {
-	return f == PixFormat{}
-}
-
 // GetPixFormat retrieves pixel information for the specified driver (via v4l2_format and v4l2_pix_format)
 // See https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/videodev2.h#L2331
 // and https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-g-fmt.html#ioctl-vidioc-g-fmt-vidioc-s-fmt-vidioc-try-fmt