YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
audioFromFileDevice_test.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
7#include <yarp/os/Network.h>
11
12#include <catch2/catch_amalgamated.hpp>
13#include <harness.h>
14
15using namespace yarp::dev;
16using namespace yarp::os;
17
18TEST_CASE("dev::audioFromFileDevice", "[yarp::dev]")
19{
20 YARP_REQUIRE_PLUGIN("audioFromFileDevice", "device");
21
22 Network::setLocalMode(true);
23
24 SECTION("Checking audioFromFileDevice device")
25 {
26 PolyDriver dd;
28
30 {
32 res.setDefaultContext("tests/audioFromFileDevice");
33 std::string filepath = res.findFileByName("440.wav");
34#if 0
35 std::string cpp_path = __FILE__;
36 std::size_t pos = cpp_path.find("audioFromFileDevice_test.cpp");
37 if (pos != std::string::npos)
38 {
39 cpp_path.erase(pos, 28);
40 }
41#endif
43 p_cfg.put("device", "audioFromFileDevice");
44 Property& p_cfg_audio_base = p_cfg.addGroup("AUDIO_BASE");
45 p_cfg_audio_base.put("channels", 1);
46 p_cfg.put("file_name", filepath);
47 REQUIRE(dd.open(p_cfg));
48 }
49
50 dd.view(igrb);
51 CHECK(igrb->startRecording());
52 CHECK(igrb->stopRecording());
53
54 //"Close all polydrivers and check"
55 {
56 CHECK(dd.close());
57 }
58 }
59
60 Network::setLocalMode(false);
61}
TEST_CASE("dev::audioFromFileDevice", "[yarp::dev]")
bool view(T *&x)
Get an interface to the device driver.
Read a YARP-format sound block from a device.
A container for a device driver.
Definition PolyDriver.h:23
bool close() override
Close the DeviceDriver.
bool open(const std::string &txt)
Construct and configure a device by its common name.
A mini-server for performing network communication in the background.
A class for storing options and configuration information.
Definition Property.h:33
Helper class for finding config files and other external resources.
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.