Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
boytacean
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
João Magalhães
boytacean
Commits
1aae3b6e
Commit
1aae3b6e
authored
1 year ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
Fix Linux issue with libretro audio
parent
d2bc2be6
No related branches found
No related tags found
1 merge request
!30
Fix Linux issue with libretro audio
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontends/libretro/src/lib.rs
+3
-10
3 additions, 10 deletions
frontends/libretro/src/lib.rs
frontends/sdl/src/main.rs
+1
-16
1 addition, 16 deletions
frontends/sdl/src/main.rs
with
4 additions
and
26 deletions
frontends/libretro/src/lib.rs
+
3
−
10
View file @
1aae3b6e
...
@@ -219,7 +219,7 @@ pub extern "C" fn retro_set_controller_port_device() {
...
@@ -219,7 +219,7 @@ pub extern "C" fn retro_set_controller_port_device() {
pub
extern
"C"
fn
retro_run
()
{
pub
extern
"C"
fn
retro_run
()
{
let
emulator
=
unsafe
{
EMULATOR
.as_mut
()
.unwrap
()
};
let
emulator
=
unsafe
{
EMULATOR
.as_mut
()
.unwrap
()
};
let
video_refresh_cb
=
unsafe
{
VIDEO_REFRESH_CALLBACK
.as_ref
()
.unwrap
()
};
let
video_refresh_cb
=
unsafe
{
VIDEO_REFRESH_CALLBACK
.as_ref
()
.unwrap
()
};
let
sample_cb
=
unsafe
{
AUDIO_SAMPLE_CALLBACK
.as_ref
()
.unwrap
()
};
let
sample_
batch_
cb
=
unsafe
{
AUDIO_SAMPLE_
BATCH_
CALLBACK
.as_ref
()
.unwrap
()
};
let
input_poll_cb
=
unsafe
{
INPUT_POLL_CALLBACK
.as_ref
()
.unwrap
()
};
let
input_poll_cb
=
unsafe
{
INPUT_POLL_CALLBACK
.as_ref
()
.unwrap
()
};
let
input_state_cb
=
unsafe
{
INPUT_STATE_CALLBACK
.as_ref
()
.unwrap
()
};
let
input_state_cb
=
unsafe
{
INPUT_STATE_CALLBACK
.as_ref
()
.unwrap
()
};
let
key_states
=
unsafe
{
KEY_STATES
.as_mut
()
.unwrap
()
};
let
key_states
=
unsafe
{
KEY_STATES
.as_mut
()
.unwrap
()
};
...
@@ -265,20 +265,13 @@ pub extern "C" fn retro_run() {
...
@@ -265,20 +265,13 @@ pub extern "C" fn retro_run() {
// in case there's new audio data available in the emulator
// in case there's new audio data available in the emulator
// we must handle it by sending it to the audio callback
// we must handle it by sending it to the audio callback
if
!
emulator
.audio_buffer
()
.is_empty
()
{
if
emulator
.audio_buffer
()
.len
()
>=
64
{
// obtains the audio buffer reference and queues it
// in a batch manner using the audio callback at the
// the end of the operation clears the buffer
let
audio_buffer
=
emulator
let
audio_buffer
=
emulator
.audio_buffer
()
.audio_buffer
()
.iter
()
.iter
()
.map
(|
v
|
*
v
as
i16
*
256
)
.map
(|
v
|
*
v
as
i16
*
256
)
.collect
::
<
Vec
<
i16
>>
();
.collect
::
<
Vec
<
i16
>>
();
sample_batch_cb
(
audio_buffer
.as_ptr
(),
audio_buffer
.len
()
/
2_usize
);
for
chunk
in
audio_buffer
.chunks_exact
(
2
)
{
sample_cb
(
chunk
[
0
],
chunk
[
1
]);
}
emulator
.clear_audio_buffer
();
emulator
.clear_audio_buffer
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
frontends/sdl/src/main.rs
+
1
−
16
View file @
1aae3b6e
...
@@ -474,7 +474,7 @@ impl Emulator {
...
@@ -474,7 +474,7 @@ impl Emulator {
// in case there's new significant new audio data available in
// in case there's new significant new audio data available in
// the emulator we must handle it, sending it to the audio callback
// the emulator we must handle it, sending it to the audio callback
if
self
.system
.audio_buffer
()
.len
()
>
self
.max_audio_buffer
as
usize
{
if
self
.system
.audio_buffer
()
.len
()
>
=
self
.max_audio_buffer
as
usize
{
if
let
Some
(
audio
)
=
self
.audio
.as_mut
()
{
if
let
Some
(
audio
)
=
self
.audio
.as_mut
()
{
let
audio_buffer
=
self
let
audio_buffer
=
self
.system
.system
...
@@ -488,21 +488,6 @@ impl Emulator {
...
@@ -488,21 +488,6 @@ impl Emulator {
}
}
}
}
// in case there's pending audio data available in the emulator
// we must handle it, sending it to the audio callback
if
self
.system
.audio_buffer
()
.is_empty
()
{
if
let
Some
(
audio
)
=
self
.audio
.as_mut
()
{
let
audio_buffer
=
self
.system
.audio_buffer
()
.iter
()
.map
(|
v
|
*
v
as
f32
/
VOLUME
)
.collect
::
<
Vec
<
f32
>>
();
audio
.device
.queue_audio
(
&
audio_buffer
)
.unwrap
();
}
self
.system
.clear_audio_buffer
();
}
// in case there's at least one new frame that was drawn during
// in case there's at least one new frame that was drawn during
// during the current tick, then we need to flush it to the canvas,
// during the current tick, then we need to flush it to the canvas,
// this separation between texture creation and canvas flush prevents
// this separation between texture creation and canvas flush prevents
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment