2 * This file is part of the libjaylink project.
4 * Copyright (C) 2014-2016 Marc Schink <jaylink-dev@marcschink.de>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "libjaylink.h"
26 #include "libjaylink-internal.h"
34 static void clear_discovery_list(struct jaylink_context
*ctx
)
38 struct jaylink_device
*dev
;
40 item
= ctx
->discovered_devs
;
43 dev
= (struct jaylink_device
*)item
->data
;
44 jaylink_unref_device(dev
);
51 ctx
->discovered_devs
= NULL
;
57 * @param[in,out] ctx libjaylink context.
58 * @param[in] ifaces Host interfaces to scan for devices. Use bitwise OR to
59 * specify multiple interfaces, or 0 to use all available
60 * interfaces. See #jaylink_host_interface for a description
63 * @retval JAYLINK_OK Success.
64 * @retval JAYLINK_ERR_ARG Invalid arguments.
65 * @retval JAYLINK_ERR_IO Input/output error.
66 * @retval JAYLINK_ERR Other error conditions.
68 * @see jaylink_get_devices()
72 JAYLINK_API
int jaylink_discovery_scan(struct jaylink_context
*ctx
,
78 return JAYLINK_ERR_ARG
;
81 ifaces
= JAYLINK_HIF_USB
| JAYLINK_HIF_TCP
;
83 clear_discovery_list(ctx
);
86 if (ifaces
& JAYLINK_HIF_USB
) {
87 ret
= discovery_usb_scan(ctx
);
89 if (ret
!= JAYLINK_OK
) {
90 log_err(ctx
, "USB device discovery failed.");
96 if (ifaces
& JAYLINK_HIF_TCP
) {
97 ret
= discovery_tcp_scan(ctx
);
99 if (ret
!= JAYLINK_OK
) {
100 log_err(ctx
, "TCP/IP device discovery failed.");