Rework virtual filesystem implementation

This commit is contained in:
Alex
2023-04-21 18:32:20 +03:00
parent f2eab6c64f
commit dc7b1fc4c9
14 changed files with 138 additions and 136 deletions

View File

@ -70,25 +70,25 @@ namespace Recovery
return;
}
std::shared_ptr<VirtualFileSystem::File> pcm = vfs->Open(AudioFile);
VirtualFileSystem::File pcm = vfs->Open(AudioFile);
if (pcm->Status != FileStatus::OK)
if (!pcm.IsOK())
{
error("Cannot open audio file! Cannot play audio!");
return;
}
void *PCMRaw = KernelAllocator.RequestPages(TO_PAGES(pcm->node->Length + 1));
memcpy(PCMRaw, (void *)pcm->node->Address, pcm->node->Length);
void *PCMRaw = KernelAllocator.RequestPages(TO_PAGES(pcm.node->Length + 1));
memcpy(PCMRaw, (void *)pcm.node->Address, pcm.node->Length);
KernelCallback callback{};
callback.Reason = SendReason;
callback.AudioCallback.Send.Data = (uint8_t *)PCMRaw;
callback.AudioCallback.Send.Length = pcm->node->Length;
callback.AudioCallback.Send.Length = pcm.node->Length;
debug("Playing audio...");
int status = DriverManager->IOCB(AudioDrv.DriverUID, &callback);
debug("Audio played! %d", status);
KernelAllocator.FreePages((void *)PCMRaw, TO_PAGES(pcm->node->Length + 1));
KernelAllocator.FreePages((void *)PCMRaw, TO_PAGES(pcm.node->Length + 1));
vfs->Close(pcm);
TEXIT(0);
}