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
13
14#include <catch2/catch_amalgamated.hpp>
15#include <harness.h>
16
17using namespace yarp::dev;
18using namespace yarp::os;
19
20TEST_CASE("dev::audioFromFileDevice", "[yarp::dev]")
21{
22 YARP_REQUIRE_PLUGIN("audioFromFileDevice", "device");
23
24 Network::setLocalMode(true);
25
26 SECTION("Checking audioFromFileDevice device")
27 {
28 PolyDriver dd;
30
32 {
34 res.setDefaultContext("tests/audioFromFileDevice");
35 std::string filepath = res.findFileByName("440.wav");
36#if 0
37 std::string cpp_path = __FILE__;
38 std::size_t pos = cpp_path.find("audioFromFileDevice_test.cpp");
39 if (pos != std::string::npos)
40 {
41 cpp_path.erase(pos, 28);
42 }
43#endif
45 p_cfg.put("device", "audioFromFileDevice");
46 Property& p_cfg_audio_base = p_cfg.addGroup("AUDIO_BASE");
47 p_cfg_audio_base.put("channels", 1);
48 p_cfg.put("file_name", filepath);
49 REQUIRE(dd.open(p_cfg));
51 }
52
53 dd.view(igrb);
54 CHECK(igrb->startRecording());
55 CHECK(igrb->stopRecording());
56
57 //"Close all polydrivers and check"
58 {
59 CHECK(dd.close());
60 }
61 }
62
63 Network::setLocalMode(false);
64}
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:32
Helper class for finding config files and other external resources.
bool setDefaultContext(const std::string &contextName)
Sets the context for the current ResourceFinder object.
std::string findFileByName(const std::string &name)
Find the full path to a file.
void exec_params_test(yarp::dev::PolyDriver *pdrv)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.