diff --git a/src/devices/audioRecorder_nws_yarp/tests/audioRecorder_nws_yarp_test.cpp b/src/devices/audioRecorder_nws_yarp/tests/audioRecorder_nws_yarp_test.cpp index bede74a680..d3db1e21a0 100644 --- a/src/devices/audioRecorder_nws_yarp/tests/audioRecorder_nws_yarp_test.cpp +++ b/src/devices/audioRecorder_nws_yarp/tests/audioRecorder_nws_yarp_test.cpp @@ -21,6 +21,36 @@ using namespace yarp::os; using namespace yarp::dev; using namespace yarp::sig; +void test_fakeMicrophone (size_t channels) +{ + PolyDriver dd_fake; + PolyDriver dd_nws; + Property p_fake; + Property p_nws; + + p_nws.put("device", "audioRecorder_nws_yarp"); + p_nws.put("start", ""); + p_fake.put("device", "fakeMicrophone"); + + char buff_channels[10]; + snprintf (buff_channels, sizeof(buff_channels), "%d", (int)channels); + Property& psub = p_fake.addGroup("AUDIO_BASE"); + psub.put("channels", (int)(channels)); + + REQUIRE(dd_fake.open(p_fake)); + REQUIRE(dd_nws.open(p_nws)); + yarp::os::SystemClock::delaySystem(0.5); + + {yarp::dev::WrapperSingle* ww_nws; dd_nws.view(ww_nws); + REQUIRE(ww_nws); + bool result_att = ww_nws->attach(&dd_fake); + REQUIRE(result_att); } + + yarp::os::SystemClock::delaySystem(1.0); + + CHECK(dd_nws.close()); + CHECK(dd_fake.close()); +} TEST_CASE("dev::AudioRecorder_nws_yarp", "[yarp::dev]") { @@ -45,27 +75,8 @@ TEST_CASE("dev::AudioRecorder_nws_yarp", "[yarp::dev]") SECTION("Test the audioRecorder_nws_yarp device with a fakeMicrophone device") { - PolyDriver dd_fake; - PolyDriver dd_nws; - Property p_fake; - Property p_nws; - - p_nws.put("device", "audioRecorder_nws_yarp"); - p_nws.put("start",""); - p_fake.put("device", "fakeMicrophone"); - REQUIRE(dd_fake.open(p_fake)); - REQUIRE(dd_nws.open(p_nws)); - yarp::os::SystemClock::delaySystem(0.5); - - {yarp::dev::WrapperSingle* ww_nws; dd_nws.view(ww_nws); - REQUIRE(ww_nws); - bool result_att = ww_nws->attach(&dd_fake); - REQUIRE(result_att); } - - yarp::os::SystemClock::delaySystem(1.0); - - CHECK(dd_nws.close()); - CHECK(dd_fake.close()); + test_fakeMicrophone(1); + test_fakeMicrophone(2); } Network::setLocalMode(false); diff --git a/src/devices/fakeMicrophone/fakeMicrophone.cpp b/src/devices/fakeMicrophone/fakeMicrophone.cpp index c5cc58d57f..1b4745e932 100644 --- a/src/devices/fakeMicrophone/fakeMicrophone.cpp +++ b/src/devices/fakeMicrophone/fakeMicrophone.cpp @@ -54,7 +54,9 @@ bool fakeMicrophone::open(yarp::os::Searchable &config) return false; } - bool b = configureRecorderAudioDevice(config.findGroup("AUDIO_BASE"), "fakeMicrophone"); + std::string debug_cfg_string = config.toString(); + yarp::os::Bottle& bb = config.findGroup("AUDIO_BASE"); + bool b = configureRecorderAudioDevice(bb, "fakeMicrophone"); if (!b) { return false; } //sets the thread period diff --git a/src/libYARP_dev/src/yarp/dev/AudioRecorderDeviceBase.cpp b/src/libYARP_dev/src/yarp/dev/AudioRecorderDeviceBase.cpp index 6bd2f44e05..047626df99 100644 --- a/src/libYARP_dev/src/yarp/dev/AudioRecorderDeviceBase.cpp +++ b/src/libYARP_dev/src/yarp/dev/AudioRecorderDeviceBase.cpp @@ -214,6 +214,8 @@ AudioRecorderDeviceBase::~AudioRecorderDeviceBase() bool AudioRecorderDeviceBase::configureRecorderAudioDevice(yarp::os::Searchable& config, std::string device_name) { + std::string debug_cfg_string = config.toString(); + m_audiorecorder_cfg.frequency = config.check("rate", Value(0), "audio sample rate (0=automatic)").asInt32(); m_audiorecorder_cfg.numSamples = config.check("samples", Value(0), "number of samples per network packet (0=automatic). For chunks of 1 second of recording set samples=rate. Channels number is handled internally.").asInt32(); m_audiorecorder_cfg.numChannels = config.check("channels", Value(0), "number of audio channels (0=automatic, max is 2)").asInt32();