MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / ff_fbdev_get_device_list

Function ff_fbdev_get_device_list

libavdevice/fbdev_common.c:74–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74int ff_fbdev_get_device_list(AVDeviceInfoList *device_list)
75{
76 struct fb_var_screeninfo varinfo;
77 struct fb_fix_screeninfo fixinfo;
78 char device_file[12];
79 AVDeviceInfo *device = NULL;
80 int i, fd, ret = 0;
81 const char *default_device = ff_fbdev_default_device();
82
83 if (!device_list)
84 return AVERROR(EINVAL);
85
86 for (i = 0; i <= 31; i++) {
87 snprintf(device_file, sizeof(device_file), "/dev/fb%d", i);
88
89 if ((fd = avpriv_open(device_file, O_RDWR)) < 0) {
90 int err = AVERROR(errno);
91 if (err != AVERROR(ENOENT))
92 av_log(NULL, AV_LOG_ERROR, "Could not open framebuffer device '%s': %s\n",
93 device_file, av_err2str(err));
94 continue;
95 }
96 if (ioctl(fd, FBIOGET_VSCREENINFO, &varinfo) == -1)
97 goto fail_device;
98 if (ioctl(fd, FBIOGET_FSCREENINFO, &fixinfo) == -1)
99 goto fail_device;
100
101 device = av_mallocz(sizeof(AVDeviceInfo));
102 if (!device) {
103 ret = AVERROR(ENOMEM);
104 goto fail_device;
105 }
106 device->device_name = av_strdup(device_file);
107 device->device_description = av_strdup(fixinfo.id);
108 if (!device->device_name || !device->device_description) {
109 ret = AVERROR(ENOMEM);
110 goto fail_device;
111 }
112
113 if ((ret = av_dynarray_add_nofree(&device_list->devices,
114 &device_list->nb_devices, device)) < 0)
115 goto fail_device;
116
117 if (default_device && !strcmp(device->device_name, default_device)) {
118 device_list->default_device = device_list->nb_devices - 1;
119 default_device = NULL;
120 }
121 close(fd);
122 continue;
123
124 fail_device:
125 if (device) {
126 av_freep(&device->device_name);
127 av_freep(&device->device_description);
128 av_freep(&device);
129 }
130 if (fd >= 0)
131 close(fd);

Callers 2

fbdev_get_device_listFunction · 0.85
fbdev_get_device_listFunction · 0.85

Calls 8

ff_fbdev_default_deviceFunction · 0.85
avpriv_openFunction · 0.85
av_logFunction · 0.85
av_strdupFunction · 0.85
av_dynarray_add_nofreeFunction · 0.85
closeFunction · 0.85
av_freepFunction · 0.85
av_malloczFunction · 0.50

Tested by

no test coverage detected