mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-22 18:15:14 +00:00
improved AudioInInput
This commit is contained in:
parent
e0eabac115
commit
32f643ca95
@ -71,6 +71,17 @@ int SDLAudioIn::AudioInInput(int handle, void* out_buffer) {
|
|||||||
|
|
||||||
const int bytesToRead = port.samples_num * port.sample_size * port.channels_num;
|
const int bytesToRead = port.samples_num * port.sample_size * port.channels_num;
|
||||||
|
|
||||||
|
if (out_buffer == nullptr) {
|
||||||
|
int attempts = 0;
|
||||||
|
while (SDL_GetAudioStreamAvailable(port.stream) > 0) {
|
||||||
|
SDL_Delay(1);
|
||||||
|
if (++attempts > 1000) {
|
||||||
|
return ORBIS_AUDIO_IN_ERROR_TIMEOUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0; // done
|
||||||
|
}
|
||||||
|
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
while (SDL_GetAudioStreamAvailable(port.stream) < bytesToRead) {
|
while (SDL_GetAudioStreamAvailable(port.stream) < bytesToRead) {
|
||||||
SDL_Delay(1);
|
SDL_Delay(1);
|
||||||
@ -79,11 +90,14 @@ int SDLAudioIn::AudioInInput(int handle, void* out_buffer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_GetAudioStreamData(port.stream, out_buffer, bytesToRead) != 0) {
|
int result = SDL_GetAudioStreamData(port.stream, out_buffer, bytesToRead);
|
||||||
|
if (result < 0) {
|
||||||
|
// SDL_GetAudioStreamData failed
|
||||||
|
SDL_Log("AudioInInput error: %s", SDL_GetError());
|
||||||
return ORBIS_AUDIO_IN_ERROR_STREAM_FAIL;
|
return ORBIS_AUDIO_IN_ERROR_STREAM_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytesToRead;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLAudioIn::AudioInClose(int handle) {
|
void SDLAudioIn::AudioInClose(int handle) {
|
||||||
|
Loading…
Reference in New Issue
Block a user