Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
b961cdf9
Commit
b961cdf9
authored
Jul 11, 2021
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API CHANGE: Standardize decoder read/seek callbacks.
parent
56202ced
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
47 deletions
+22
-47
miniaudio.h
miniaudio.h
+22
-47
No files found.
miniaudio.h
View file @
b961cdf9
...
...
@@ -6124,9 +6124,8 @@ typedef struct
} ma_decoding_backend_vtable;
/* TODO: Convert read and seek to be consistent with the VFS API (ma_result return value, bytes read moved to an output parameter). */
typedef size_t (* ma_decoder_read_proc)(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead); /* Returns the number of bytes read. */
typedef ma_bool32 (* ma_decoder_seek_proc)(ma_decoder* pDecoder, ma_int64 byteOffset, ma_seek_origin origin);
typedef ma_result (* ma_decoder_read_proc)(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead, size_t* pBytesRead); /* Returns the number of bytes read. */
typedef ma_result (* ma_decoder_seek_proc)(ma_decoder* pDecoder, ma_int64 byteOffset, ma_seek_origin origin);
typedef ma_result (* ma_decoder_tell_proc)(ma_decoder* pDecoder, ma_int64* pCursor);
typedef struct
...
...
@@ -46622,37 +46621,16 @@ Decoding
static ma_result ma_decoder_read_bytes(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead, size_t* pBytesRead)
{
size_t bytesRead;
MA_ASSERT(pDecoder != NULL);
MA_ASSERT(pBufferOut != NULL);
MA_ASSERT(bytesToRead > 0); /* It's an error to call this with a byte count of zero. */
bytesRead = pDecoder->onRead(pDecoder, pBufferOut, bytesToRead);
if (pBytesRead != NULL) {
*pBytesRead = bytesRead;
}
if (bytesRead == 0) {
return MA_AT_END;
}
MA_ASSERT(pDecoder != NULL);
return
MA_SUCCESS
;
return
pDecoder->onRead(pDecoder, pBufferOut, bytesToRead, pBytesRead)
;
}
static ma_result ma_decoder_seek_bytes(ma_decoder* pDecoder, ma_int64 byteOffset, ma_seek_origin origin)
{
ma_bool32 wasSuccessful;
MA_ASSERT(pDecoder != NULL);
wasSuccessful = pDecoder->onSeek(pDecoder, byteOffset, origin);
if (wasSuccessful) {
return MA_SUCCESS;
} else {
return MA_ERROR;
}
return pDecoder->onSeek(pDecoder, byteOffset, origin);
}
static ma_result ma_decoder_tell_bytes(ma_decoder* pDecoder, ma_int64* pCursor)
...
...
@@ -49782,7 +49760,7 @@ MA_API ma_result ma_decoder_init(ma_decoder_read_proc onRead, ma_decoder_seek_pr
}
static
size_t ma_decoder__on_read_memory(ma_decoder* pDecoder, void* pBufferOut, size_t bytesTo
Read)
static
ma_result ma_decoder__on_read_memory(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead, size_t* pBytes
Read)
{
size_t bytesRemaining;
...
...
@@ -49793,18 +49771,26 @@ static size_t ma_decoder__on_read_memory(ma_decoder* pDecoder, void* pBufferOut,
bytesToRead = bytesRemaining;
}
if (bytesRemaining == 0) {
return MA_AT_END;
}
if (bytesToRead > 0) {
MA_COPY_MEMORY(pBufferOut, pDecoder->data.memory.pData + pDecoder->data.memory.currentReadPos, bytesToRead);
pDecoder->data.memory.currentReadPos += bytesToRead;
}
return bytesToRead;
if (pBytesRead != NULL) {
*pBytesRead = bytesToRead;
}
return MA_SUCCESS;
}
static ma_
bool32
ma_decoder__on_seek_memory(ma_decoder* pDecoder, ma_int64 byteOffset, ma_seek_origin origin)
static ma_
result
ma_decoder__on_seek_memory(ma_decoder* pDecoder, ma_int64 byteOffset, ma_seek_origin origin)
{
if (byteOffset > 0 && (ma_uint64)byteOffset > MA_SIZE_MAX) {
return MA_
FALSE; /* Too far. */
return MA_
BAD_SEEK;
}
if (origin == ma_seek_origin_current) {
...
...
@@ -49841,7 +49827,7 @@ static ma_bool32 ma_decoder__on_seek_memory(ma_decoder* pDecoder, ma_int64 byteO
}
}
return MA_
TRUE
;
return MA_
SUCCESS
;
}
static ma_result ma_decoder__on_tell_memory(ma_decoder* pDecoder, ma_int64* pCursor)
...
...
@@ -50068,30 +50054,19 @@ static ma_bool32 ma_path_extension_equal_w(const wchar_t* path, const wchar_t* e
static
size_t ma_decoder__on_read_vfs(ma_decoder* pDecoder, void* pBufferOut, size_t bytesTo
Read)
static
ma_result ma_decoder__on_read_vfs(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead, size_t* pBytes
Read)
{
size_t bytesRead;
MA_ASSERT(pDecoder != NULL);
MA_ASSERT(pBufferOut != NULL);
ma_vfs_or_default_read(pDecoder->data.vfs.pVFS, pDecoder->data.vfs.file, pBufferOut, bytesToRead, &bytesRead);
return bytesRead;
return ma_vfs_or_default_read(pDecoder->data.vfs.pVFS, pDecoder->data.vfs.file, pBufferOut, bytesToRead, pBytesRead);
}
static ma_
bool32
ma_decoder__on_seek_vfs(ma_decoder* pDecoder, ma_int64 offset, ma_seek_origin origin)
static ma_
result
ma_decoder__on_seek_vfs(ma_decoder* pDecoder, ma_int64 offset, ma_seek_origin origin)
{
ma_result result;
MA_ASSERT(pDecoder != NULL);
result = ma_vfs_or_default_seek(pDecoder->data.vfs.pVFS, pDecoder->data.vfs.file, offset, origin);
if (result != MA_SUCCESS) {
return MA_FALSE;
}
return MA_TRUE;
return ma_vfs_or_default_seek(pDecoder->data.vfs.pVFS, pDecoder->data.vfs.file, offset, origin);
}
static ma_result ma_decoder__on_tell_vfs(ma_decoder* pDecoder, ma_int64* pCursor)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment