SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
RTLSDRDev.hxx
Go to the documentation of this file.
1#pragma once
2/*
3Copyright (c) 2026 Matthew H. Reilly (kb1vc)
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are
8met:
9
10 Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in
14 the documentation and/or other materials provided with the
15 distribution.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
38
39#include <rtl-sdr.h>
40#include <memory>
41#include <string>
42
43namespace SoDa {
44
45 struct RTLSDRDev {
46 rtlsdr_dev_t * dev;
47 std::string name;
48
49 explicit RTLSDRDev(uint32_t index) : dev(nullptr) {
50 name = std::string(rtlsdr_get_device_name(index));
51 rtlsdr_open(&dev, index);
52 }
53
55 if (dev) { rtlsdr_close(dev); dev = nullptr; }
56 }
57
58 RTLSDRDev(const RTLSDRDev &) = delete;
59 RTLSDRDev & operator=(const RTLSDRDev &) = delete;
60 };
61
62 using RTLSDRDevPtr = std::shared_ptr<RTLSDRDev>;
63
64} // namespace SoDa
std::shared_ptr< RTLSDRDev > RTLSDRDevPtr
Definition RTLSDRDev.hxx:62
std::string name
Definition RTLSDRDev.hxx:47
rtlsdr_dev_t * dev
Definition RTLSDRDev.hxx:46
RTLSDRDev(const RTLSDRDev &)=delete
RTLSDRDev(uint32_t index)
Definition RTLSDRDev.hxx:49
RTLSDRDev & operator=(const RTLSDRDev &)=delete