Possible to specify audio device and default to hw:0 to stop using PusleAudio

This commit is contained in:
Iwan Timmer
2014-02-12 17:53:39 +01:00
parent 56eea63aad
commit 54c72cd0f0
7 changed files with 39 additions and 13 deletions
+2 -2
View File
@@ -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(&params);
+1 -1
View File
@@ -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);
+12 -2
View File
@@ -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