Skip to content

New class for return values of interface methods PART4 #3170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/devices/audioFromFileDevice/AudioFromFileDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ AudioFromFileDevice::~AudioFromFileDevice()
{
}

bool AudioFromFileDevice::setHWGain(double gain)
ReturnValue AudioFromFileDevice::setHWGain(double gain)
{
yCInfo(AUDIOFROMFILE) << "Not yet implemented";
return false;
return ReturnValue::return_code::return_value_error_not_implemented_by_device;
}

bool AudioFromFileDevice::open(yarp::os::Searchable &config)
Expand Down Expand Up @@ -100,9 +100,9 @@ bool AudioFromFileDevice::close()
return true;
}

bool AudioFromFileDevice::stopRecording()
ReturnValue AudioFromFileDevice::stopRecording()
{
bool b = AudioRecorderDeviceBase::stopRecording();
ReturnValue b = AudioRecorderDeviceBase::stopRecording();
if (b && m_reset_on_stop)
{
m_bpnt=0;
Expand Down
4 changes: 2 additions & 2 deletions src/devices/audioFromFileDevice/AudioFromFileDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class AudioFromFileDevice :
void run() override;

public:
bool setHWGain(double gain) override;
bool stopRecording () override;
yarp::dev::ReturnValue setHWGain(double gain) override;
yarp::dev::ReturnValue stopRecording () override;

private:
yarp::sig::Sound m_audioFile;
Expand Down
20 changes: 10 additions & 10 deletions src/devices/audioToFileDevice/AudioToFileDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ bool AudioToFileDevice::close()
return true;
}

bool AudioToFileDevice::startPlayback()
ReturnValue AudioToFileDevice::startPlayback()
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
yCDebug(AUDIOTOFILE) << "start";
Expand All @@ -136,10 +136,10 @@ bool AudioToFileDevice::startPlayback()
{
m_sounds.clear();
}
return true;
return ReturnValue_ok;
}

bool AudioToFileDevice::stopPlayback()
ReturnValue AudioToFileDevice::stopPlayback()
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
yCDebug(AUDIOTOFILE) << "stop";
Expand All @@ -148,34 +148,34 @@ bool AudioToFileDevice::stopPlayback()
{
save_to_file();
}
return true;
return ReturnValue_ok;
}

bool AudioToFileDevice::renderSound(const yarp::sig::Sound& sound)
ReturnValue AudioToFileDevice::renderSound(const yarp::sig::Sound& sound)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (m_save_mode_enum == save_break_file)
{
m_sounds.push_back(sound);
save_to_file();
return true;
return ReturnValue_ok;
}
if (m_playback_enabled)
{
m_sounds.push_back(sound);
}
return true;
return ReturnValue_ok;
}

bool AudioToFileDevice::setHWGain(double gain)
ReturnValue AudioToFileDevice::setHWGain(double gain)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (gain > 0)
{
m_hw_gain = gain;
return true;
return ReturnValue_ok;
}
return false;
return ReturnValue::return_code::return_value_error_method_failed;
}

bool AudioToFileDevice::configureDeviceAndStart()
Expand Down
8 changes: 4 additions & 4 deletions src/devices/audioToFileDevice/AudioToFileDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class AudioToFileDevice :
bool close() override;

public:
virtual bool renderSound(const yarp::sig::Sound& sound) override;
virtual bool startPlayback() override;
virtual bool stopPlayback()override;
virtual bool setHWGain(double gain) override;
virtual yarp::dev::ReturnValue renderSound(const yarp::sig::Sound& sound) override;
virtual yarp::dev::ReturnValue startPlayback() override;
virtual yarp::dev::ReturnValue stopPlayback()override;
virtual yarp::dev::ReturnValue setHWGain(double gain) override;
virtual bool configureDeviceAndStart() override;
virtual bool interruptDeviceAndClose() override;
virtual void waitUntilPlaybackStreamIsComplete() override;
Expand Down
6 changes: 3 additions & 3 deletions src/devices/fake/fakeMicrophone/FakeMicrophone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ bool FakeMicrophone::close()
return true;
}

bool FakeMicrophone::setHWGain(double gain)
ReturnValue FakeMicrophone::setHWGain(double gain)
{
std::lock_guard<std::mutex> lock(m_mutex);
if (gain > 0)
{
m_hw_gain = gain;
return true;
return ReturnValue_ok;
}
return false;
return ReturnValue::return_code::return_value_error_method_failed;
}

bool FakeMicrophone::threadInit()
Expand Down
2 changes: 1 addition & 1 deletion src/devices/fake/fakeMicrophone/FakeMicrophone.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class FakeMicrophone :
virtual ~FakeMicrophone() override;

public:
bool setHWGain(double gain) override;
yarp::dev::ReturnValue setHWGain(double gain) override;

public: // DeviceDriver
bool open(yarp::os::Searchable &config) override;
Expand Down
6 changes: 3 additions & 3 deletions src/devices/fake/fakeSpeaker/FakeSpeaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ void FakeSpeaker::run()
}
}

bool FakeSpeaker::setHWGain(double gain)
ReturnValue FakeSpeaker::setHWGain(double gain)
{
std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (gain > 0)
{
m_hw_gain = gain;
return true;
return ReturnValue_ok;
}
return false;
return ReturnValue::return_code::return_value_error_method_failed;
}

bool FakeSpeaker::configureDeviceAndStart()
Expand Down
2 changes: 1 addition & 1 deletion src/devices/fake/fakeSpeaker/FakeSpeaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class FakeSpeaker :
bool close() override;

//interface
virtual bool setHWGain(double gain) override;
virtual yarp::dev::ReturnValue setHWGain(double gain) override;
virtual bool configureDeviceAndStart() override;
virtual bool interruptDeviceAndClose() override;

Expand Down
38 changes: 22 additions & 16 deletions src/devices/messages/IAudioGrabberMsgs/IAudioGrabberMsgs.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@

//-------------------------------------------------

struct return_isRecording {
1: bool ret = false;
2: bool isRecording = false;
}

struct yarp_sig_AudioBufferSize {
} (
yarp.name = "yarp::sig::AudioBufferSize"
Expand All @@ -22,32 +17,43 @@ struct yarp_sig_Sound {
yarp.includefile = "yarp/sig/Sound.h"
)

struct yReturnValue {
} (
yarp.name = "yarp::dev::ReturnValue"
yarp.includefile = "yarp/dev/ReturnValue.h"
)

struct return_isRecording {
1: yReturnValue ret;
2: bool isRecording = false;
}

struct return_getSound {
1: bool ret = false;
1: yReturnValue ret;
2: yarp_sig_Sound sound;
}

struct return_getRecordingAudioBufferCurrentSize {
1: bool ret = false;
1: yReturnValue ret;
2: yarp_sig_AudioBufferSize bufsize;
}

struct return_getRecordingAudioBufferMaxSize {
1: bool ret = false;
1: yReturnValue ret;
2: yarp_sig_AudioBufferSize bufsize;
}

typedef i32 ( yarp.type = "size_t" ) size_t

service IAudioGrabberMsgs
{
bool setHWGain_RPC (1:double gain);
bool setSWGain_RPC (1:double gain);
bool resetRecordingAudioBuffer_RPC ();
bool startRecording_RPC ();
bool stopRecording_RPC ();
return_isRecording isRecording_RPC ();
return_getSound getSound_RPC (1: size_t min_number_of_samples, 2: size_t max_number_of_samples, 3: double max_samples_timeout_s);
return_getRecordingAudioBufferMaxSize getRecordingAudioBufferMaxSize_RPC ();
yReturnValue setHWGain_RPC (1:double gain);
yReturnValue setSWGain_RPC (1:double gain);
yReturnValue resetRecordingAudioBuffer_RPC ();
yReturnValue startRecording_RPC ();
yReturnValue stopRecording_RPC ();
return_isRecording isRecording_RPC ();
return_getSound getSound_RPC (1: size_t min_number_of_samples, 2: size_t max_number_of_samples, 3: double max_samples_timeout_s);
return_getRecordingAudioBufferMaxSize getRecordingAudioBufferMaxSize_RPC ();
return_getRecordingAudioBufferCurrentSize getRecordingAudioBufferCurrentSize_RPC ();
}
Loading
Loading