mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-06-15 21:31:12 +00:00
Possible to specify audio device and default to hw:0 to stop using PusleAudio
This commit is contained in:
@@ -7,13 +7,13 @@
|
||||
|
||||
snd_pcm_t *handle;
|
||||
|
||||
int nv_alsa_init(unsigned int channelCount, unsigned int sampleRate) {
|
||||
int nv_alsa_init(unsigned int channelCount, unsigned int sampleRate, unsigned char* device) {
|
||||
int rc;
|
||||
snd_pcm_hw_params_t *params;
|
||||
int dir;
|
||||
|
||||
/* Open PCM device for playback. */
|
||||
if ((rc = snd_pcm_open(&handle, "default", SND_PCM_STREAM_PLAYBACK, 0)) != 0)
|
||||
if ((rc = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0)) != 0)
|
||||
return rc;
|
||||
|
||||
snd_pcm_hw_params_alloca(¶ms);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <jni.h>
|
||||
|
||||
int nv_alsa_init(unsigned int channelCount, unsigned int sampleRate);
|
||||
int nv_alsa_init(unsigned int channelCount, unsigned int sampleRate, unsigned char* indata);
|
||||
int nv_alsa_play(unsigned char* indata, int inlen);
|
||||
void nv_alsa_close(void);
|
||||
|
||||
@@ -6,9 +6,19 @@
|
||||
// This function must be called before
|
||||
// any other decoding functions
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_limelight_binding_audio_AlsaAudio_init(JNIEnv *env, jobject this, jint channelCount, jint sampleRate)
|
||||
Java_com_limelight_binding_audio_AlsaAudio_init(JNIEnv *env, jobject this, jint channelCount, jint sampleRate, jbyteArray device)
|
||||
{
|
||||
return nv_alsa_init(channelCount, sampleRate);
|
||||
jint ret;
|
||||
jbyte* jni_device;
|
||||
|
||||
jni_device = (*env)->GetByteArrayElements(env, device, 0);
|
||||
|
||||
ret = nv_alsa_init(channelCount, sampleRate, jni_device);
|
||||
|
||||
// The input data isn't changed so it can be safely aborted
|
||||
(*env)->ReleaseByteArrayElements(env, device, jni_device, JNI_ABORT);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
|
||||
Reference in New Issue
Block a user