Skip to content

Commit ac8ab50

Browse files
committed
Implement RETRO_ENVIRONMENT_GET_TARGET_SAMPLE_RATE - optional to implement.
Lets the core query the frontend for the desired target output samplerate. Will return false if the output samplerate cannot be queried, will return true if it's implemented. data returned will be of unsigned type
1 parent a073235 commit ac8ab50

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

libretro-common/include/libretro.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2575,6 +2575,18 @@ enum retro_mod
25752575
*/
25762576
#define RETRO_ENVIRONMENT_GET_FILE_BROWSER_START_DIRECTORY 80
25772577

2578+
/**
2579+
* Returns the audio sample rate the frontend is targeting, in Hz.
2580+
* The intended use case is for the core to use the result to select an ideal sample rate.
2581+
*
2582+
* @param[out] data <tt>float *</tt>.
2583+
* Pointer to the \c float in which the frontend will store its target sample rate.
2584+
* Behavior is undefined if \c data is <tt>NULL</tt>.
2585+
* @return \c true if this environment call is available,
2586+
* regardless of the value returned in \c data.
2587+
*/
2588+
#define RETRO_ENVIRONMENT_GET_TARGET_SAMPLE_RATE (81 | RETRO_ENVIRONMENT_EXPERIMENTAL)
2589+
25782590
/**@}*/
25792591

25802592
/**

runloop.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3333,6 +3333,15 @@ bool runloop_environment_cb(unsigned cmd, void *data)
33333333
*(unsigned *)data = 2;
33343334
break;
33353335

3336+
case RETRO_ENVIRONMENT_GET_TARGET_SAMPLE_RATE:
3337+
{
3338+
if (!settings)
3339+
return false;
3340+
3341+
*(unsigned *)data = settings->uints.audio_output_sample_rate;
3342+
break;
3343+
}
3344+
33363345
case RETRO_ENVIRONMENT_GET_TARGET_REFRESH_RATE:
33373346
{
33383347
/* Try to use the polled refresh rate first. */

0 commit comments

Comments
 (0)