media: Add nullptr check at FileInputDataSource
When open, check file is already open.
When close, check file is nullptr.
@@ -52,6 +52,11 @@ FileInputDataSource::~FileInputDataSource()
bool FileInputDataSource::open()
{
+ if (mFp) {
+ meddbg("FileInputDataSource::open : file is already open\n");
+ return false;
+ }
+
setAudioType(utils::getAudioTypeFromPath(mDataPath));
switch (getAudioType()) {
@@ -78,9 +83,11 @@ bool FileInputDataSource::open()
void FileInputDataSource::close()
{
+ if (mFp) {
fclose(mFp);
mFp = nullptr;
}
+}
bool FileInputDataSource::isPrepare()
{
