Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/unstable' into gfx-rdp
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky committed Oct 15, 2023
2 parents 2e8ab42 + a659ffb commit 68d5fbe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,18 @@ void mixer_unthrottle(void);
*/
void mixer_poll(int16_t *out, int nsamples);

/**
* @brief Request the mixer to try and write audio samples to be played,
* if possible.
*
* This function is a user helper for asking the mixer and audio subsystems
* to play audio during a game frame. You should call this function many times
* during one frame (eg. during the render step or after processing each game
* object) as many times as necessary. Not polling the audio subsystem often
* enough will result in audio stutter.
*/
void mixer_try_play();

/**
* @brief Callback invoked by mixer_poll at a specified time
*
Expand Down
10 changes: 10 additions & 0 deletions src/audio/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,3 +750,13 @@ void mixer_poll(int16_t *out16, int num_samples) {
}
}
}

void mixer_try_play()
{
if (audio_can_write())
{
short *buf = audio_write_begin();
mixer_poll(buf, audio_get_buffer_length());
audio_write_end();
}
}

0 comments on commit 68d5fbe

Please sign in to comment.