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
80cebeb6
Commit
80cebeb6
authored
Nov 04, 2017
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a bug with sample rate conversion.
parent
5c31a4b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
13 deletions
+26
-13
mini_al.h
mini_al.h
+26
-13
No files found.
mini_al.h
View file @
80cebeb6
...
@@ -499,7 +499,8 @@ struct mal_src
...
@@ -499,7 +499,8 @@ struct mal_src
struct
struct
{
{
float
alpha
;
float
alpha
;
mal_bool32
isBinLoaded
:
1
;
mal_bool32
isPrevFramesLoaded
:
1
;
mal_bool32
isNextFramesLoaded
:
1
;
}
linear
;
}
linear
;
};
};
};
};
...
@@ -2192,7 +2193,12 @@ static inline void mal_device__send_frames_to_client(mal_device* pDevice, mal_ui
...
@@ -2192,7 +2193,12 @@ static inline void mal_device__send_frames_to_client(mal_device* pDevice, mal_ui
break
;
break
;
}
}
//printf("SENDING TO CLIENT: %d %d\n", chunkFrameCount, framesJustRead);
onRecv
(
pDevice
,
framesJustRead
,
chunkBuffer
);
onRecv
(
pDevice
,
framesJustRead
,
chunkBuffer
);
if
(
framesJustRead
<
chunkFrameCount
)
{
break
;
}
}
}
}
}
}
}
...
@@ -8668,22 +8674,24 @@ mal_uint32 mal_src_read_frames_linear(mal_src* pSRC, mal_uint32 frameCount, void
...
@@ -8668,22 +8674,24 @@ mal_uint32 mal_src_read_frames_linear(mal_src* pSRC, mal_uint32 frameCount, void
mal_assert
(
frameCount
>
0
);
mal_assert
(
frameCount
>
0
);
mal_assert
(
pFramesOut
!=
NULL
);
mal_assert
(
pFramesOut
!=
NULL
);
// Load the bin if it's not been loaded yet.
// For linear SRC, the bin is only 2 frames: 1 prior, 1 future.
if
(
!
pSRC
->
linear
.
isBinLoaded
)
{
mal_uint32
framesRead
=
mal_src_cache_read_frames
(
&
pSRC
->
cache
,
2
,
pSRC
->
bin
);
// Load the bin if necessary.
if
(
!
pSRC
->
linear
.
isPrevFramesLoaded
)
{
mal_uint32
framesRead
=
mal_src_cache_read_frames
(
&
pSRC
->
cache
,
1
,
pSRC
->
bin
);
if
(
framesRead
==
0
)
{
if
(
framesRead
==
0
)
{
return
0
;
return
0
;
}
}
pSRC
->
linear
.
isPrevFramesLoaded
=
MAL_TRUE
;
if
(
framesRead
==
1
)
{
}
mal_pcm_convert
(
pFramesOut
,
pSRC
->
config
.
formatOut
,
pSRC
->
bin
,
mal_format_f32
,
framesRead
*
pSRC
->
config
.
channels
);
if
(
!
pSRC
->
linear
.
isNextFramesLoaded
)
{
return
framesRead
;
mal_uint32
framesRead
=
mal_src_cache_read_frames
(
&
pSRC
->
cache
,
1
,
pSRC
->
bin
+
pSRC
->
config
.
channels
);
if
(
framesRead
==
0
)
{
return
0
;
}
}
pSRC
->
linear
.
isNextFramesLoaded
=
MAL_TRUE
;
pSRC
->
linear
.
isBinLoaded
=
MAL_TRUE
;
}
}
float
factor
=
pSRC
->
ratio
;
float
factor
=
pSRC
->
ratio
;
mal_uint32
totalFramesRead
=
0
;
mal_uint32
totalFramesRead
=
0
;
...
@@ -8712,8 +8720,8 @@ mal_uint32 mal_src_read_frames_linear(mal_src* pSRC, mal_uint32 frameCount, void
...
@@ -8712,8 +8720,8 @@ mal_uint32 mal_src_read_frames_linear(mal_src* pSRC, mal_uint32 frameCount, void
pNextFrame
[
j
]
=
0
;
pNextFrame
[
j
]
=
0
;
}
}
pSRC
->
linear
.
is
Bin
Loaded
=
MAL_FALSE
;
pSRC
->
linear
.
is
NextFrames
Loaded
=
MAL_FALSE
;
return
totalFramesRead
;
// We've exhausted the client data.
break
;
}
}
}
}
...
@@ -8722,6 +8730,11 @@ mal_uint32 mal_src_read_frames_linear(mal_src* pSRC, mal_uint32 frameCount, void
...
@@ -8722,6 +8730,11 @@ mal_uint32 mal_src_read_frames_linear(mal_src* pSRC, mal_uint32 frameCount, void
pFramesOut
=
(
mal_uint8
*
)
pFramesOut
+
(
1
*
pSRC
->
config
.
channels
*
mal_get_sample_size_in_bytes
(
pSRC
->
config
.
formatOut
));
pFramesOut
=
(
mal_uint8
*
)
pFramesOut
+
(
1
*
pSRC
->
config
.
channels
*
mal_get_sample_size_in_bytes
(
pSRC
->
config
.
formatOut
));
frameCount
-=
1
;
frameCount
-=
1
;
totalFramesRead
+=
1
;
totalFramesRead
+=
1
;
// If there's no frames available we need to get out of this loop.
if
(
!
pSRC
->
linear
.
isNextFramesLoaded
)
{
break
;
}
}
}
return
totalFramesRead
;
return
totalFramesRead
;
...
...
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