Another patch from Jose
git-svn-id: https://svn.musicpd.org/mpd/trunk@5733 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
8553a98c84
commit
ef0397bf5b
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
static char *name = "mpd";
|
static char *name = "mpd";
|
||||||
static char *output_ports[2];
|
static char *output_ports[2];
|
||||||
static int ringbuf_sz = 32768;
|
static int ringbuf_sz = 65536;
|
||||||
|
|
||||||
typedef struct _JackData {
|
typedef struct _JackData {
|
||||||
jack_port_t *ports[2];
|
jack_port_t *ports[2];
|
||||||
@ -201,7 +201,7 @@ static void set_audioformat(AudioOutput *audioOutput)
|
|||||||
audioFormat->channels = 2;
|
audioFormat->channels = 2;
|
||||||
audioFormat->bits = 16;
|
audioFormat->bits = 16;
|
||||||
jd->bps = audioFormat->channels
|
jd->bps = audioFormat->channels
|
||||||
* sizeof(jack_default_audio_sample_t)*8
|
* sizeof(jack_default_audio_sample_t)
|
||||||
* audioFormat->sampleRate;
|
* audioFormat->sampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ static int jack_initDriver(AudioOutput *audioOutput, ConfigParam *param)
|
|||||||
val = strtol(bp->value, &endptr, 10);
|
val = strtol(bp->value, &endptr, 10);
|
||||||
|
|
||||||
if ( errno == 0 && endptr != bp->value) {
|
if ( errno == 0 && endptr != bp->value) {
|
||||||
ringbuf_sz = val < 32768 ? 32768 : val;
|
ringbuf_sz = val < 65536 ? 65536 : val;
|
||||||
ERROR("ringbuffer_size=%d\n", ringbuf_sz);
|
ERROR("ringbuffer_size=%d\n", ringbuf_sz);
|
||||||
} else {
|
} else {
|
||||||
ERROR("%s is not a number; ringbuf_size=%d\n",
|
ERROR("%s is not a number; ringbuf_size=%d\n",
|
||||||
@ -397,10 +397,10 @@ static int jack_playAudio(AudioOutput * audioOutput, char *buff, int size)
|
|||||||
{
|
{
|
||||||
JackData *jd = audioOutput->data;
|
JackData *jd = audioOutput->data;
|
||||||
size_t space;
|
size_t space;
|
||||||
char *samples1;
|
|
||||||
char *samples2;
|
|
||||||
int i;
|
int i;
|
||||||
short *buffer = (short *) buff;
|
short *buffer = (short *) buff;
|
||||||
|
jack_default_audio_sample_t sample;
|
||||||
|
size_t samples = size/4;
|
||||||
|
|
||||||
ERROR("jack_playAudio: (pid=%d)!\n", getpid());
|
ERROR("jack_playAudio: (pid=%d)!\n", getpid());
|
||||||
|
|
||||||
@ -411,60 +411,39 @@ static int jack_playAudio(AudioOutput * audioOutput, char *buff, int size)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*jd->can_process=0;*/
|
|
||||||
/* if ( jd->our_xrun ) { */
|
|
||||||
/* ERROR("xrun\n"); */
|
|
||||||
/* jd->our_xrun = 0; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/*ERROR("jack_playAudio: size=%d\n", size/4);*/
|
/*ERROR("jack_playAudio: size=%d\n", size/4);*/
|
||||||
/*ERROR("jack_playAudio - INICIO\n");*/
|
/*ERROR("jack_playAudio - INICIO\n");*/
|
||||||
|
|
||||||
if ( ! jd->samples1 ) {
|
while ( samples && !jd->shutdown ) {
|
||||||
ERROR("jd->samples1=xmalloc\n");
|
/*ERROR("\t samples=%d\n", samples);*/
|
||||||
jd->samples1 = (jack_default_audio_sample_t *)
|
|
||||||
xmalloc(size*sizeof(jack_default_audio_sample_t));
|
|
||||||
}
|
|
||||||
if ( ! jd->samples2 ) {
|
|
||||||
ERROR("jd->samples2=xmalloc\n");
|
|
||||||
jd->samples2 = (jack_default_audio_sample_t *)
|
|
||||||
xmalloc(size*sizeof(jack_default_audio_sample_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* primero convierto todo el buffer al formato que usa jack */
|
|
||||||
for (i=0; i<size; i++) {
|
|
||||||
*(jd->samples1 + i) =
|
|
||||||
(jack_default_audio_sample_t) *(buffer++) / 32768;
|
|
||||||
*(jd->samples2 + i) =
|
|
||||||
(jack_default_audio_sample_t) *(buffer++) / 32768;
|
|
||||||
/*
|
|
||||||
*(jd->samples1 + i) =
|
|
||||||
(jack_default_audio_sample_t) *(buff + i) / 32768;
|
|
||||||
*(jd->samples2 + i) =
|
|
||||||
(jack_default_audio_sample_t) *(buff + i) / 32768;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
samples1 = (char *)jd->samples1;
|
|
||||||
samples2 = (char *)jd->samples2;
|
|
||||||
while ( size && !jd->shutdown ) {
|
|
||||||
if ( (space = jack_ringbuffer_write_space(jd->ringbuffer[0]))
|
if ( (space = jack_ringbuffer_write_space(jd->ringbuffer[0]))
|
||||||
>= size ) {
|
>= samples*sizeof(jack_default_audio_sample_t) ) {
|
||||||
/*ERROR("\t size=%d space=%d\n", size, space);*/
|
/*ERROR("\t samples_b=%d space=%d\n", samples*sizeof(jack_default_audio_sample_t), space);*/
|
||||||
space = MIN(space, size);
|
|
||||||
jack_ringbuffer_write(jd->ringbuffer[0],samples1,space);
|
space = MIN(space, samples*sizeof(jack_default_audio_sample_t));
|
||||||
jack_ringbuffer_write(jd->ringbuffer[1],samples2,space);
|
|
||||||
size -= space;
|
for(i=0; i<space/sizeof(jack_default_audio_sample_t); i++) {
|
||||||
samples1 += space;
|
sample = (jack_default_audio_sample_t) *(buffer++)/32768.0;
|
||||||
samples2 += space;
|
|
||||||
|
jack_ringbuffer_write(jd->ringbuffer[0], (void*)&sample,
|
||||||
|
sizeof(jack_default_audio_sample_t));
|
||||||
|
|
||||||
|
sample = (jack_default_audio_sample_t) *(buffer++)/32768.0;
|
||||||
|
|
||||||
|
jack_ringbuffer_write(jd->ringbuffer[1], (void*)&sample,
|
||||||
|
sizeof(jack_default_audio_sample_t));
|
||||||
|
|
||||||
|
samples--;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* ERROR("\t space=%d\n", space); */
|
/* ERROR("\t space=%d\n", space); */
|
||||||
/* ERROR("\t size=%d\n", size); */
|
/* ERROR("\t size=%d\n", size); */
|
||||||
usleep((unsigned long)
|
usleep((unsigned long)
|
||||||
((size-space)/jd->bps) * 1000000.0);
|
((samples*sizeof(jack_default_audio_sample_t)
|
||||||
|
- space)/jd->bps) * 1000000.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* jd->can_process=1; */
|
|
||||||
|
|
||||||
/*ERROR("jack_playAudio - FIN\n");*/
|
/*ERROR("jack_playAudio - FIN\n");*/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user