mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-03 18:12:14 +02:00
Introducing wrapper function for buffer playback
This commit is contained in:
parent
0acaf0462f
commit
da712eb4df
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#define DEVICE_NAME_LENGTH 0x100
|
#define DEVICE_NAME_LENGTH 0x100
|
||||||
#define DEFAULT_SAMPLE_RATE 0xBB80
|
#define DEFAULT_SAMPLE_RATE 0xBB80
|
||||||
#define CHANNEL_COUNT_MAGIC 0xCAFE0000
|
#define DEFAULT_CHANNEL_COUNT 0x00020000
|
||||||
|
|
||||||
static Service g_audoutSrv;
|
static Service g_audoutSrv;
|
||||||
static Service g_audoutIAudioOut;
|
static Service g_audoutIAudioOut;
|
||||||
@ -32,7 +32,7 @@ Result audoutInitialize(void)
|
|||||||
char DeviceNameIn[DEVICE_NAME_LENGTH] = {0};
|
char DeviceNameIn[DEVICE_NAME_LENGTH] = {0};
|
||||||
char DeviceNameOut[DEVICE_NAME_LENGTH] = {0};
|
char DeviceNameOut[DEVICE_NAME_LENGTH] = {0};
|
||||||
|
|
||||||
rc = audoutOpenAudioOut(DeviceNameIn, DeviceNameOut, DEFAULT_SAMPLE_RATE, CHANNEL_COUNT_MAGIC, &g_sampleRate, &g_channelCount, &g_pcmFormat, &g_deviceState);
|
rc = audoutOpenAudioOut(DeviceNameIn, DeviceNameOut, DEFAULT_SAMPLE_RATE, DEFAULT_CHANNEL_COUNT, &g_sampleRate, &g_channelCount, &g_pcmFormat, &g_deviceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_FAILED(rc))
|
if (R_FAILED(rc))
|
||||||
@ -68,6 +68,37 @@ AudioOutState audoutGetDeviceState(void) {
|
|||||||
return g_deviceState;
|
return g_deviceState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool audoutPlayBuffer(Handle *event, AudioOutBuffer *source, AudioOutBuffer *released, u64 duration) {
|
||||||
|
bool timeout = false;
|
||||||
|
u64 time_now = svcGetSystemTick();
|
||||||
|
|
||||||
|
while ((svcGetSystemTick() - time_now) < duration)
|
||||||
|
{
|
||||||
|
Result do_wait = svcWaitSynchronizationSingle(*event, U64_MAX);
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(do_wait))
|
||||||
|
{
|
||||||
|
svcResetSignal(*event);
|
||||||
|
|
||||||
|
u32 released_count = 0;
|
||||||
|
Result do_release = audoutGetReleasedAudioOutBuffer(released, &released_count);
|
||||||
|
|
||||||
|
while (R_SUCCEEDED(do_release) && (released_count > 0))
|
||||||
|
{
|
||||||
|
do_release = audoutGetReleasedAudioOutBuffer(released, &released_count);
|
||||||
|
audoutAppendAudioOutBuffer(source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
timeout = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return timeout;
|
||||||
|
}
|
||||||
|
|
||||||
Result audoutListAudioOuts(char *DeviceNames, u32 *DeviceNamesCount) {
|
Result audoutListAudioOuts(char *DeviceNames, u32 *DeviceNamesCount) {
|
||||||
IpcCommand c;
|
IpcCommand c;
|
||||||
ipcInitialize(&c);
|
ipcInitialize(&c);
|
||||||
|
Loading…
Reference in New Issue
Block a user