diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2012-07-31 13:10:44 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2014-03-10 19:53:57 +0100 |
commit | bc72e1332cfc81e166c83c90ad63b4b648f19867 (patch) | |
tree | 91285072d74f8addcd5a72e6960f37e61a7e95b4 /src/main.c | |
parent | 45033a900fb0d004b9790f7b9d57045ea7510cd3 (diff) |
Split media_device creation and opening
Make the media_device refcounted to manage its life time.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -329,15 +329,20 @@ int main(int argc, char **argv) if (parse_cmdline(argc, argv)) return EXIT_FAILURE; - /* Open the media device and enumerate entities, pads and links. */ + media = media_device_new(media_opts.devname); + if (media == NULL) { + printf("Failed to create media device\n"); + goto out; + } + if (media_opts.verbose) - media = media_open_debug( - media_opts.devname, + media_debug_set_handler(media, (void (*)(void *, ...))fprintf, stdout); - else - media = media_open(media_opts.devname); - if (media == NULL) { - printf("Failed to open %s\n", media_opts.devname); + + /* Enumerate entities, pads and links. */ + ret = media_device_enumerate(media); + if (ret < 0) { + printf("Failed to enumerate %s (%d)\n", media_opts.devname, ret); goto out; } @@ -446,7 +451,7 @@ int main(int argc, char **argv) out: if (media) - media_close(media); + media_device_unref(media); return ret ? EXIT_FAILURE : EXIT_SUCCESS; } |