danielpaulus / quicktime_video_hack

Record iOS device audio and video
MIT License
537 stars 113 forks source link

Why check class and subclass each settings, but just the first one is effective? #64

Closed yuruxuan closed 4 years ago

yuruxuan commented 4 years ago

https://github.com/danielpaulus/quicktime_video_hack/blob/bfcee09d51933cc99006a85a093c425aa868efae/screencapture/discovery.go#L212

Is something wrong there?

yuruxuan commented 4 years ago
        for _, alt := range iface.AltSettings {
            isVendorClass := alt.Class == gousb.ClassVendorSpec
            isCorrectSubClass := alt.SubClass == subClass
            log.Debugf("found: %t", isCorrectSubClass && isVendorClass)

        }
        isVendorClass := iface.AltSettings[0].Class == gousb.ClassVendorSpec
        isCorrectSubClass := iface.AltSettings[0].SubClass == subClass
danielpaulus commented 4 years ago

Thanks, good catch! You're absolutely right. I forgot to remove the old code that always used setting 0. I think it is actually not a big deal whether you just use the first setting or iterate them all as it seems there is usually only one setting present. Lopping through all of them just seems a little safer to me. I will add a fix soon. Thanks again for bringing this to my attention :-)