Android — Как получить файлы с SD-карты в C ++?

Я пытаюсь получить файлы с SD-карты в C ++
Я знаю, как получить аудиоданные от AAssetManager.
Вот как я получаю его из AAssetManager (в соответствии с примером кода «Гобой — Ритм-игра»)

AAssetDataSource* AAssetDataSource::newFromAssetManager(AAssetManager *assetManager,
const char *filename,
const int32_t channelCount) {

// Load the backing track
AAsset* asset = AAssetManager_open(assetManager, filename, AASSET_MODE_BUFFER);

if (asset == nullptr){
LOGE("Failed to open track, filename %s", filename);
return nullptr;
}

// Get the length of the track (we assume it is stereo 48kHz)
off_t trackLength = AAsset_getLength(asset);

// Load it into memory
auto *audioBuffer = static_cast<const int16_t*>(AAsset_getBuffer(asset));

if (audioBuffer == nullptr){
LOGE("Could not get buffer for track");
return nullptr;
}

// There are 4 bytes per frame because
// each sample is 2 bytes and
// it's a stereo recording which has 2 samples per frame.
int32_t numFrames = static_cast<int32_t>(trackLength / 4);
LOGD("Opened backing track, bytes: %ld frames: %d", trackLength, numFrames);

return new AAssetDataSource(asset, audioBuffer, numFrames, channelCount);
}

Как я могу получить audioBuffer и numFrames, как в методе «newFromAssetManager»?
Спасибо!

-1

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector