Skip to content

Commit

Permalink
fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrolcl committed Nov 17, 2024
1 parent 7510b7a commit 3fd8a9b
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions test/SonivoxTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

//#define LOG_NDEBUG 0
#define LOG_TAG "SonivoxTest"
#include <utils/Log.h>

Expand Down Expand Up @@ -52,7 +51,6 @@ class SonivoxTest : public ::testing::TestWithParam<tuple</*fileName*/ string,
public:
SonivoxTest()
: mFd(-1)
, mInputFp(nullptr)
, mEASDataHandle(nullptr)
, mEASStreamHandle(nullptr)
, mPCMBuffer(nullptr)
Expand All @@ -62,8 +60,6 @@ class SonivoxTest : public ::testing::TestWithParam<tuple</*fileName*/ string,

~SonivoxTest()
{
if (mInputFp)
fclose(mInputFp);
if (mFd >= 0)
close(mFd);
if (mPCMBuffer) {
Expand All @@ -81,6 +77,7 @@ class SonivoxTest : public ::testing::TestWithParam<tuple</*fileName*/ string,
virtual void SetUp() override
{
EAS_RESULT result;
struct stat buf;
tuple<string, uint32_t, string> params = GetParam();
mInputMediaFile = gEnv->getRes() + get<0>(params);
mAudioplayTimeMs = get<1>(params);
Expand All @@ -95,24 +92,35 @@ class SonivoxTest : public ::testing::TestWithParam<tuple</*fileName*/ string,

if (mSoundFont.length() > 0) {
string soundfontpath = gEnv->getTmp() + mSoundFont;
memset(&mDLSFile, 0, sizeof(EAS_FILE));
mFd = open(soundfontpath.c_str(), O_RDONLY | OPEN_FLAG);
ASSERT_GE(mFd, 0) << "Failed to get the file descriptor for file: " << soundfontpath;

int8_t err = stat(soundfontpath.c_str(), &buf);
ASSERT_EQ(err, 0) << "Failed to get information for file: " << soundfontpath;

mBase = 0;
mLength = buf.st_size;
memset(&mDLSFile, 0, sizeof(mDLSFile));

mDLSFile.handle = fopen(soundfontpath.c_str(), "rb");
#ifdef NEW_HOST_WRAPPER
mDLSFile.handle = fdopen(mFd, "rb");
ASSERT_NE(mDLSFile.handle, nullptr)
<< "Failed to open " << soundfontpath << " error: " << strerror(errno);
#ifndef NEW_HOST_WRAPPER
mDLSFile.readAt = Read;
mDLSFile.size = Size;
#else
mDLSFile.handle = this;
mDLSFile.readAt = ::readAt;
mDLSFile.size = ::getSize;
#endif
result = EAS_LoadDLSCollection(mEASDataHandle, nullptr, &mDLSFile);
ASSERT_EQ(result, EAS_SUCCESS) << "Failed to load DLS file: " << soundfontpath;
fclose((FILE *) mDLSFile.handle);
#ifdef NEW_HOST_WRAPPER
close(mFd);
#endif
}

mFd = open(mInputMediaFile.c_str(), O_RDONLY | OPEN_FLAG);
ASSERT_GE(mFd, 0) << "Failed to get the file descriptor for file: " << mInputMediaFile;

struct stat buf;
int8_t err = stat(mInputMediaFile.c_str(), &buf);
ASSERT_EQ(err, 0) << "Failed to get information for file: " << mInputMediaFile;

Expand Down Expand Up @@ -199,7 +207,6 @@ class SonivoxTest : public ::testing::TestWithParam<tuple</*fileName*/ string,
int64_t mLength;
int mFd;

FILE *mInputFp;
EAS_DATA_HANDLE mEASDataHandle;
EAS_HANDLE mEASStreamHandle;
EAS_FILE mEasFile;
Expand Down

0 comments on commit 3fd8a9b

Please sign in to comment.