mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-11 18:36:17 +00:00
Better audio error catching
This commit is contained in:
@@ -19,13 +19,21 @@ int nv_alsa_init(unsigned int channelCount, unsigned int sampleRate) {
|
|||||||
snd_pcm_hw_params_alloca(¶ms);
|
snd_pcm_hw_params_alloca(¶ms);
|
||||||
snd_pcm_hw_params_any(handle, params);
|
snd_pcm_hw_params_any(handle, params);
|
||||||
|
|
||||||
snd_pcm_hw_params_set_access(handle, params, SND_PCM_ACCESS_RW_INTERLEAVED);
|
if ((rc = snd_pcm_hw_params_set_access(handle, params, SND_PCM_ACCESS_RW_INTERLEAVED)) != 0)
|
||||||
snd_pcm_hw_params_set_format(handle, params, SND_PCM_FORMAT_S16_LE);
|
return rc;
|
||||||
snd_pcm_hw_params_set_channels(handle, params, channelCount);
|
|
||||||
snd_pcm_hw_params_set_rate_near(handle, params, &sampleRate, &dir);
|
if ((rc = snd_pcm_hw_params_set_format(handle, params, SND_PCM_FORMAT_S16_LE)) != 0)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
if ((rc = snd_pcm_hw_params_set_channels(handle, params, channelCount)) != 0)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
if ((rc = snd_pcm_hw_params_set_rate_near(handle, params, &sampleRate, &dir)) != 0)
|
||||||
|
return rc;
|
||||||
|
|
||||||
snd_pcm_uframes_t frames = 32;
|
snd_pcm_uframes_t frames = 32;
|
||||||
snd_pcm_hw_params_set_period_size_near(handle, params, &frames, &dir);
|
if ((rc = snd_pcm_hw_params_set_period_size_near(handle, params, &frames, &dir)) != 0)
|
||||||
|
return rc;
|
||||||
|
|
||||||
if ((rc = snd_pcm_hw_params(handle, params)) != 0)
|
if ((rc = snd_pcm_hw_params(handle, params)) != 0)
|
||||||
return rc;
|
return rc;
|
||||||
@@ -51,4 +59,4 @@ int nv_alsa_play(const unsigned char* indata, int data_len) {
|
|||||||
int nv_alsa_close(void) {
|
int nv_alsa_close(void) {
|
||||||
snd_pcm_drain(handle);
|
snd_pcm_drain(handle);
|
||||||
snd_pcm_close(handle);
|
snd_pcm_close(handle);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ public class AlsaAudioRenderer implements AudioRenderer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void streamInitialized(int channelCount, int sampleRate) {
|
public void streamInitialized(int channelCount, int sampleRate) {
|
||||||
AlsaAudio.init(channelCount, sampleRate);
|
int ret = AlsaAudio.init(channelCount, sampleRate);
|
||||||
|
if (ret != 0)
|
||||||
|
throw new IllegalStateException("AVC decoder initialization failure: "+ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user