aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutputs/audioOutput_jack.c
diff options
context:
space:
mode:
authorJosé Anarch <anarchsss@gmail.com>2007-04-11 17:41:10 +0000
committerJosé Anarch <anarchsss@gmail.com>2007-04-11 17:41:10 +0000
commit51ec5b154211c733ea102860bfe09f417c0bf9fe (patch)
tree9943378582c85668c689efc99e13c73f0b758801 /src/audioOutputs/audioOutput_jack.c
parentde5667b288ca61d7b441e5f45b88f706f7422da8 (diff)
downloadmpd-51ec5b154211c733ea102860bfe09f417c0bf9fe.tar.gz
mpd-51ec5b154211c733ea102860bfe09f417c0bf9fe.tar.xz
mpd-51ec5b154211c733ea102860bfe09f417c0bf9fe.zip
Only a few changes in jack_playAudio.
git-svn-id: https://svn.musicpd.org/mpd/trunk@5909 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/audioOutputs/audioOutput_jack.c')
-rw-r--r--src/audioOutputs/audioOutput_jack.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/audioOutputs/audioOutput_jack.c b/src/audioOutputs/audioOutput_jack.c
index fb0ea463b..1563c8fae 100644
--- a/src/audioOutputs/audioOutput_jack.c
+++ b/src/audioOutputs/audioOutput_jack.c
@@ -38,10 +38,13 @@ pthread_cond_t play_audio = PTHREAD_COND_INITIALIZER;
/*#include "dmalloc.h"*/
#define MIN(a, b) ((a) < (b) ? (a) : (b))
+/*#define SAMPLE_SIZE sizeof(jack_default_audio_sample_t);*/
+
static char *name = "mpd";
static char *output_ports[2];
static int ringbuf_sz = 32768;
+size_t sample_size = sizeof(jack_default_audio_sample_t);
typedef struct _JackData {
jack_port_t *ports[2];
@@ -129,11 +132,11 @@ static int process(jack_nframes_t nframes, void *arg)
avail_data = jack_ringbuffer_read_space(jd->ringbuffer[1]);
if ( avail_data > 0 ) {
- avail_frames = avail_data / sizeof(jack_default_audio_sample_t);
+ avail_frames = avail_data / sample_size;
if (avail_frames > nframes) {
avail_frames = nframes;
- avail_data = nframes*sizeof(jack_default_audio_sample_t);
+ avail_data = nframes*sample_size;
}
jack_ringbuffer_read(jd->ringbuffer[0], (char *)out[0],
@@ -390,29 +393,32 @@ static int jack_playAudio(AudioOutput * audioOutput, char *buff, int size)
while ( samples && !jd->shutdown ) {
if ( (space = jack_ringbuffer_write_space(jd->ringbuffer[0]))
- >= samples*sizeof(jack_default_audio_sample_t) ) {
-
+ >= samples*sample_size ) {
- space = MIN(space, samples*sizeof(jack_default_audio_sample_t));
+ /*space = MIN(space, samples*sample_size);*/
+ /*space = samples*sample_size;*/
- for(i=0; i<space/sizeof(jack_default_audio_sample_t); i++) {
+ /*for(i=0; i<space/sample_size; i++) {*/
+ for(i=0; i<samples; i++) {
sample = (jack_default_audio_sample_t) *(buffer++)/32768.0;
jack_ringbuffer_write(jd->ringbuffer[0], (void*)&sample,
- sizeof(jack_default_audio_sample_t));
+ sample_size);
sample = (jack_default_audio_sample_t) *(buffer++)/32768.0;
jack_ringbuffer_write(jd->ringbuffer[1], (void*)&sample,
- sizeof(jack_default_audio_sample_t));
+ sample_size);
- samples--;
+ /*samples--;*/
}
+ samples=0;
- }
- pthread_mutex_lock(&play_audio_lock);
- pthread_cond_wait(&play_audio, &play_audio_lock);
- pthread_mutex_unlock(&play_audio_lock);
+ } else {
+ pthread_mutex_lock(&play_audio_lock);
+ pthread_cond_wait(&play_audio, &play_audio_lock);
+ pthread_mutex_unlock(&play_audio_lock);
+ }
}
return 0;