forked from love2d/love
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate NAV audio decoding routines to Decoder.
- Loading branch information
1 parent
3d11743
commit 274742c
Showing
6 changed files
with
495 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include "navinput.h" | ||
|
||
#include "Exception.h" | ||
|
||
namespace love | ||
{ | ||
|
||
static void closeStream(void **udata) | ||
{ | ||
Stream *stream = *(Stream **) udata; | ||
stream->release(); | ||
*udata = nullptr; | ||
} | ||
|
||
static size_t readStream(void *udata, void *dest, size_t size) | ||
{ | ||
Stream *stream = (Stream *) udata; | ||
return (size_t) stream->read(dest, (int64) size); | ||
} | ||
|
||
static nav_bool seekStream(void *udata, uint64_t pos) | ||
{ | ||
Stream *stream = (Stream *) udata; | ||
return (nav_bool) stream->seek((int64) pos); | ||
} | ||
|
||
static uint64_t tellStream(void *udata) | ||
{ | ||
Stream *stream = (Stream *) udata; | ||
return (uint64_t) stream->tell(); | ||
} | ||
|
||
static uint64_t sizeStream(void *udata) | ||
{ | ||
Stream *stream = (Stream *) udata; | ||
return (uint64_t) stream->getSize(); | ||
} | ||
|
||
nav_input streamToNAVInput(love::Stream *stream) | ||
{ | ||
if (!stream->isReadable()) | ||
throw Exception("stream is not readable"); | ||
if (!stream->isSeekable()) | ||
throw Exception("stream is not seekable"); | ||
|
||
stream->retain(); | ||
return { | ||
stream, | ||
&closeStream, | ||
&readStream, | ||
&seekStream, | ||
&tellStream, | ||
&sizeStream | ||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef LOVE_NAVINPUT_H | ||
#define LOVE_NAVINPUT_H | ||
|
||
// LOVE | ||
#include "Stream.h" | ||
|
||
// nav | ||
#include "nav/nav.h" | ||
|
||
namespace love | ||
{ | ||
|
||
nav_input streamToNAVInput(love::Stream *stream); | ||
|
||
} | ||
|
||
#endif |
Oops, something went wrong.