- moved the sound decoding code to the zmusic project.
Since this gets used by both the sound backend and the music code it needs to be in a place accessible to both.
This commit is contained in:
parent
b883d27a1f
commit
cdf2a17c5a
35 changed files with 544 additions and 426 deletions
39
src/utility/filereadermusicinterface.h
Normal file
39
src/utility/filereadermusicinterface.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#pragma once
|
||||
|
||||
#include "../libraries/music_common/fileio.h"
|
||||
#include "files.h"
|
||||
|
||||
struct FileReaderMusicInterface : public MusicIO::FileInterface
|
||||
{
|
||||
FileReader fr;
|
||||
|
||||
FileReaderMusicInterface(FileReader& fr_in)
|
||||
{
|
||||
fr = std::move(fr_in);
|
||||
}
|
||||
char* gets(char* buff, int n) override
|
||||
{
|
||||
if (!fr.isOpen()) return nullptr;
|
||||
return fr.Gets(buff, n);
|
||||
}
|
||||
long read(void* buff, int32_t size, int32_t nitems) override
|
||||
{
|
||||
if (!fr.isOpen()) return 0;
|
||||
return (long)fr.Read(buff, size * nitems) / size;
|
||||
}
|
||||
long seek(long offset, int whence) override
|
||||
{
|
||||
if (!fr.isOpen()) return 0;
|
||||
return (long)fr.Seek(offset, (FileReader::ESeek)whence);
|
||||
}
|
||||
long tell() override
|
||||
{
|
||||
if (!fr.isOpen()) return 0;
|
||||
return (long)fr.Tell();
|
||||
}
|
||||
FileReader& getReader()
|
||||
{
|
||||
return fr;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -328,4 +328,5 @@ public:
|
|||
TArray<unsigned char> *GetBuffer() { return &mBuffer; }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue