Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
tyrquake
Commits
fc198131
Commit
fc198131
authored
Mar 17, 2020
by
Vladimir Serbinenko
Browse files
Make audio buffer size variable
parent
639a85bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
common/libretro.c
View file @
fc198131
...
...
@@ -97,6 +97,12 @@ static bool libretro_supports_bitmasks = false;
#define SAMPLERATE 48000
#define MAX_AUDIO_BUFFER_SIZE (10240)
static
int16_t
audio_buffer
[
MAX_AUDIO_BUFFER_SIZE
];
static
int
audio_buffer_size
;
static
unsigned
audio_buffer_ptr
;
// System analog stick range is -0x8000 to 0x8000
#define ANALOG_RANGE 0x8000
// Default deadzone: 15%
...
...
@@ -731,6 +737,12 @@ static void update_variables(bool startup)
}
else
framerate
=
60
.
0
f
;
if
(
framerate
>
49
.
0
)
audio_buffer_size
=
2048
;
else
audio_buffer_size
=
2
*
SAMPLERATE
/
framerate
;
if
(
audio_buffer_size
>
MAX_AUDIO_BUFFER_SIZE
)
audio_buffer_size
=
MAX_AUDIO_BUFFER_SIZE
;
}
var
.
key
=
"tyrquake_colored_lighting"
;
...
...
@@ -1268,11 +1280,6 @@ void D_EndDirectRect(int x, int y, int width, int height)
* SOUND (TODO)
*/
#define BUFFER_SIZE (10240)
static
int16_t
audio_buffer
[
BUFFER_SIZE
];
static
unsigned
audio_buffer_ptr
;
static
void
audio_process
(
void
)
{
/* adds music raw samples and/or advances midi driver */
...
...
@@ -1305,8 +1312,8 @@ static void audio_callback(void)
int
samples_per_frame
=
(
nchans
*
SAMPLERATE
)
/
framerate
;
unsigned
read_end
=
audio_buffer_ptr
+
samples_per_frame
;
if
(
read_end
>
BUFFER_SIZE
)
read_end
=
BUFFER_SIZE
;
if
(
read_end
>
audio_buffer_size
)
read_end
=
audio_buffer_size
;
read_first
=
read_end
-
audio_buffer_ptr
;
read_second
=
samples_per_frame
-
read_first
;
...
...
@@ -1327,7 +1334,7 @@ qboolean SNDDMA_Init(dma_t *dma)
shm
->
samplepos
=
0
;
shm
->
samplebits
=
16
;
shm
->
signed8
=
0
;
shm
->
samples
=
BUFFER_SIZE
;
shm
->
samples
=
audio_buffer_size
;
shm
->
buffer
=
(
unsigned
char
*
volatile
)
audio_buffer
;
return
true
;
...
...
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