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
17189c2b
Commit
17189c2b
authored
Apr 27, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update dr_mp3.
parent
4603322a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletion
+17
-1
extras/dr_mp3.h
extras/dr_mp3.h
+17
-1
No files found.
extras/dr_mp3.h
View file @
17189c2b
// MP3 audio decoder. Public domain. See "unlicense" statement at the end of this file.
// MP3 audio decoder. Public domain. See "unlicense" statement at the end of this file.
// dr_mp3 - v0.2
- 2018-04-21
// dr_mp3 - v0.2
.1 - 2018-04-27
//
//
// David Reid - mackron@gmail.com
// David Reid - mackron@gmail.com
//
//
...
@@ -225,6 +225,7 @@ typedef struct
...
@@ -225,6 +225,7 @@ typedef struct
size_t
dataSize
;
size_t
dataSize
;
size_t
dataCapacity
;
size_t
dataCapacity
;
drmp3_uint8
*
pData
;
drmp3_uint8
*
pData
;
drmp3_bool32
atEnd
:
1
;
struct
struct
{
{
const
drmp3_uint8
*
pData
;
const
drmp3_uint8
*
pData
;
...
@@ -2290,6 +2291,10 @@ static drmp3_bool32 drmp3_decode_next_frame(drmp3* pMP3)
...
@@ -2290,6 +2291,10 @@ static drmp3_bool32 drmp3_decode_next_frame(drmp3* pMP3)
drmp3_assert
(
pMP3
!=
NULL
);
drmp3_assert
(
pMP3
!=
NULL
);
drmp3_assert
(
pMP3
->
onRead
!=
NULL
);
drmp3_assert
(
pMP3
->
onRead
!=
NULL
);
if
(
pMP3
->
atEnd
)
{
return
DRMP3_FALSE
;
}
do
do
{
{
// minimp3 recommends doing data submission in 16K chunks. If we don't have at least 16K bytes available, get more.
// minimp3 recommends doing data submission in 16K chunks. If we don't have at least 16K bytes available, get more.
...
@@ -2305,10 +2310,16 @@ static drmp3_bool32 drmp3_decode_next_frame(drmp3* pMP3)
...
@@ -2305,10 +2310,16 @@ static drmp3_bool32 drmp3_decode_next_frame(drmp3* pMP3)
}
}
size_t
bytesRead
=
pMP3
->
onRead
(
pMP3
->
pUserData
,
pMP3
->
pData
+
pMP3
->
dataSize
,
(
pMP3
->
dataCapacity
-
pMP3
->
dataSize
));
size_t
bytesRead
=
pMP3
->
onRead
(
pMP3
->
pUserData
,
pMP3
->
pData
+
pMP3
->
dataSize
,
(
pMP3
->
dataCapacity
-
pMP3
->
dataSize
));
if
(
bytesRead
==
0
)
{
pMP3
->
atEnd
=
DRMP3_TRUE
;
return
DRMP3_FALSE
;
// No data.
}
pMP3
->
dataSize
+=
bytesRead
;
pMP3
->
dataSize
+=
bytesRead
;
}
}
if
(
pMP3
->
dataSize
>
INT_MAX
)
{
if
(
pMP3
->
dataSize
>
INT_MAX
)
{
pMP3
->
atEnd
=
DRMP3_TRUE
;
return
DRMP3_FALSE
;
// File too big.
return
DRMP3_FALSE
;
// File too big.
}
}
...
@@ -2343,6 +2354,7 @@ static drmp3_bool32 drmp3_decode_next_frame(drmp3* pMP3)
...
@@ -2343,6 +2354,7 @@ static drmp3_bool32 drmp3_decode_next_frame(drmp3* pMP3)
// Fill in a chunk.
// Fill in a chunk.
size_t
bytesRead
=
pMP3
->
onRead
(
pMP3
->
pUserData
,
pMP3
->
pData
+
pMP3
->
dataSize
,
(
pMP3
->
dataCapacity
-
pMP3
->
dataSize
));
size_t
bytesRead
=
pMP3
->
onRead
(
pMP3
->
pUserData
,
pMP3
->
pData
+
pMP3
->
dataSize
,
(
pMP3
->
dataCapacity
-
pMP3
->
dataSize
));
if
(
bytesRead
==
0
)
{
if
(
bytesRead
==
0
)
{
pMP3
->
atEnd
=
DRMP3_TRUE
;
return
DRMP3_FALSE
;
// Error reading more data.
return
DRMP3_FALSE
;
// Error reading more data.
}
}
...
@@ -2616,6 +2628,7 @@ drmp3_bool32 drmp3_seek_to_frame(drmp3* pMP3, drmp3_uint64 frameIndex)
...
@@ -2616,6 +2628,7 @@ drmp3_bool32 drmp3_seek_to_frame(drmp3* pMP3, drmp3_uint64 frameIndex)
pMP3
->
framesConsumed
=
0
;
pMP3
->
framesConsumed
=
0
;
pMP3
->
framesRemaining
=
0
;
pMP3
->
framesRemaining
=
0
;
pMP3
->
dataSize
=
0
;
pMP3
->
dataSize
=
0
;
pMP3
->
atEnd
=
DRMP3_FALSE
;
// TODO: Optimize.
// TODO: Optimize.
//
//
...
@@ -2744,6 +2757,9 @@ void drmp3_free(void* p)
...
@@ -2744,6 +2757,9 @@ void drmp3_free(void* p)
// REVISION HISTORY
// REVISION HISTORY
// ===============
// ===============
//
//
// v0.2.1 - 2018-04-27
// - Efficiency improvements when the decoder reaches the end of the stream.
//
// v0.2 - 2018-04-21
// v0.2 - 2018-04-21
// - Bring up to date with minimp3.
// - Bring up to date with minimp3.
// - Start using major.minor.revision versioning.
// - Start using major.minor.revision versioning.
...
...
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