mirror of https://github.com/axmolengine/axmol.git
This commit is contained in:
parent
01e67f6203
commit
6d27868918
|
@ -83,7 +83,7 @@ static CallerThreadUtils __callerThreadUtils;
|
|||
|
||||
static int fdGetter(const std::string& url, off_t* start, off_t* length)
|
||||
{
|
||||
int fd = 0;
|
||||
int fd = -1;
|
||||
if (cocos2d::FileUtilsAndroid::getObbFile() != nullptr)
|
||||
{
|
||||
fd = getObbAssetFileDescriptorJNI(url.c_str(), start, length);
|
||||
|
|
|
@ -344,7 +344,7 @@ AudioPlayerProvider::AudioFileInfo AudioPlayerProvider::getFileInfo(
|
|||
AudioFileInfo info;
|
||||
long fileSize = 0;
|
||||
off_t start = 0, length = 0;
|
||||
int assetFd = 0;
|
||||
int assetFd = -1;
|
||||
|
||||
if (audioFilePath[0] != '/')
|
||||
{
|
||||
|
@ -471,7 +471,7 @@ UrlAudioPlayer *AudioPlayerProvider::createUrlAudioPlayer(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
SLuint32 locatorType = info.assetFd > 0 ? SL_DATALOCATOR_ANDROIDFD : SL_DATALOCATOR_URI;
|
||||
SLuint32 locatorType = info.assetFd->getFd() > 0 ? SL_DATALOCATOR_ANDROIDFD : SL_DATALOCATOR_URI;
|
||||
auto urlPlayer = new (std::nothrow) UrlAudioPlayer(_engineItf, _outputMixObject, _callerThreadUtils);
|
||||
bool ret = urlPlayer->prepare(info.url, locatorType, info.assetFd, info.start, info.length);
|
||||
if (!ret)
|
||||
|
|
|
@ -276,7 +276,18 @@ bool UrlAudioPlayer::prepare(const std::string &url, SLuint32 locatorType, std::
|
|||
_url = url;
|
||||
_assetFd = assetFd;
|
||||
|
||||
ALOGV("UrlAudioPlayer::prepare: %s, %d, %d, %d, %d", _url.c_str(), (int)locatorType, assetFd->getFd(), start,
|
||||
const char* locatorTypeStr= "UNKNOWN";
|
||||
if (locatorType == SL_DATALOCATOR_ANDROIDFD)
|
||||
locatorTypeStr = "SL_DATALOCATOR_ANDROIDFD";
|
||||
else if (locatorType == SL_DATALOCATOR_URI)
|
||||
locatorTypeStr = "SL_DATALOCATOR_URI";
|
||||
else
|
||||
{
|
||||
ALOGE("Oops, invalid locatorType: %d", (int)locatorType);
|
||||
return false;
|
||||
}
|
||||
|
||||
ALOGV("UrlAudioPlayer::prepare: %s, %s, %d, %d, %d", _url.c_str(), locatorTypeStr, _assetFd->getFd(), start,
|
||||
length);
|
||||
SLDataSource audioSrc;
|
||||
|
||||
|
@ -303,11 +314,6 @@ bool UrlAudioPlayer::prepare(const std::string &url, SLuint32 locatorType, std::
|
|||
audioSrc.pLocator = &locUri;
|
||||
ALOGV("locUri: locatorType: %d", (int)locUri.locatorType);
|
||||
}
|
||||
else
|
||||
{
|
||||
ALOGE("Oops, invalid locatorType: %d", (int)locatorType);
|
||||
return false;
|
||||
}
|
||||
|
||||
// configure audio sink
|
||||
SLDataLocator_OutputMix locOutmix = {SL_DATALOCATOR_OUTPUTMIX, _outputMixObj};
|
||||
|
|
Loading…
Reference in New Issue