Skip to content

Commit

Permalink
added extra checks in SoundFilters
Browse files Browse the repository at this point in the history
  • Loading branch information
randaz81 committed Jul 22, 2021
1 parent 0208a4a commit ae93106
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmake/YarpFindDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ print_dependency(Libv4l2)
print_dependency(Libv4lconvert)
print_dependency(Fuse)
print_dependency(ZLIB)
print_dependency(SOXR)

################################################################################
# Print information for user
Expand Down
21 changes: 21 additions & 0 deletions src/libYARP_sig/src/yarp/sig/SoundFilters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ namespace

bool yarp::sig::soundfilters::resample(yarp::sig::Sound& snd, size_t frequency)
{
if (frequency == 0)
{
yCError(SOUNDFILTERS) << "invalid frequency value = 0";
return false;
}
if (snd.getChannels() != 1)
{
yCError(SOUNDFILTERS) << "only 1 channel is currently supported";
return false;
}
if (snd.getSamples() == 0)
{
yCError(SOUNDFILTERS) << "empty sound received?!";
return false;
}
if (snd.getFrequency() == frequency)
{
yCWarning(SOUNDFILTERS) << "no resampling needed";
return true;
}

#if !defined (YARP_HAS_SOXR)

yCError(SOUNDFILTERS) << "libsoxr not available";
Expand Down

0 comments on commit ae93106

Please sign in to comment.