s/ad/pd/ in the PluseAudio plugin (I forgot to rename when copying from alsa)
git-svn-id: https://svn.musicpd.org/mpd/trunk@4404 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
2728853ec1
commit
3187eb300b
@ -56,28 +56,28 @@ static PulseData * newPulseData()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void freePulseData(PulseData * ad)
|
static void freePulseData(PulseData * pd)
|
||||||
{
|
{
|
||||||
if (ad->server) free(ad->server);
|
if (pd->server) free(pd->server);
|
||||||
if (ad->sink) free(ad->sink);
|
if (pd->sink) free(pd->sink);
|
||||||
free(ad);
|
free(pd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pulse_initDriver(AudioOutput * audioOutput, ConfigParam * param)
|
static int pulse_initDriver(AudioOutput * audioOutput, ConfigParam * param)
|
||||||
{
|
{
|
||||||
BlockParam * server = NULL;
|
BlockParam * server = NULL;
|
||||||
BlockParam * sink = NULL;
|
BlockParam * sink = NULL;
|
||||||
PulseData * ad;
|
PulseData * pd;
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
server = getBlockParam(param, "server");
|
server = getBlockParam(param, "server");
|
||||||
sink = getBlockParam(param, "sink");
|
sink = getBlockParam(param, "sink");
|
||||||
}
|
}
|
||||||
|
|
||||||
ad = newPulseData();
|
pd = newPulseData();
|
||||||
ad->server = server ? strdup(server->value) : NULL;
|
pd->server = server ? strdup(server->value) : NULL;
|
||||||
ad->sink = sink ? strdup(sink->value) : NULL;
|
pd->sink = sink ? strdup(sink->value) : NULL;
|
||||||
audioOutput->data = ad;
|
audioOutput->data = pd;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -112,21 +112,21 @@ static int pulse_testDefault()
|
|||||||
|
|
||||||
static int pulse_openDevice(AudioOutput * audioOutput)
|
static int pulse_openDevice(AudioOutput * audioOutput)
|
||||||
{
|
{
|
||||||
PulseData * ad;
|
PulseData * pd;
|
||||||
AudioFormat * audioFormat;
|
AudioFormat * audioFormat;
|
||||||
pa_sample_spec ss;
|
pa_sample_spec ss;
|
||||||
time_t t;
|
time_t t;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
t = time(NULL);
|
t = time(NULL);
|
||||||
ad = audioOutput->data;
|
pd = audioOutput->data;
|
||||||
audioFormat = &audioOutput->outAudioFormat;
|
audioFormat = &audioOutput->outAudioFormat;
|
||||||
|
|
||||||
if (ad->connAttempts != 0 &&
|
if (pd->connAttempts != 0 &&
|
||||||
(t - ad->lastAttempt) < CONN_ATTEMPT_INTERVAL) return -1;
|
(t - pd->lastAttempt) < CONN_ATTEMPT_INTERVAL) return -1;
|
||||||
|
|
||||||
ad->connAttempts++;
|
pd->connAttempts++;
|
||||||
ad->lastAttempt = t;
|
pd->lastAttempt = t;
|
||||||
|
|
||||||
if (audioFormat->bits != 16) {
|
if (audioFormat->bits != 16) {
|
||||||
ERROR("PulseAudio doesn't support %i bit audio\n",
|
ERROR("PulseAudio doesn't support %i bit audio\n",
|
||||||
@ -138,17 +138,17 @@ static int pulse_openDevice(AudioOutput * audioOutput)
|
|||||||
ss.rate = audioFormat->sampleRate;
|
ss.rate = audioFormat->sampleRate;
|
||||||
ss.channels = audioFormat->channels;
|
ss.channels = audioFormat->channels;
|
||||||
|
|
||||||
ad->s = pa_simple_new(ad->server, MPD_PULSE_NAME, PA_STREAM_PLAYBACK,
|
pd->s = pa_simple_new(pd->server, MPD_PULSE_NAME, PA_STREAM_PLAYBACK,
|
||||||
ad->sink, audioOutput->name, &ss, NULL, NULL,
|
pd->sink, audioOutput->name, &ss, NULL, NULL,
|
||||||
&error);
|
&error);
|
||||||
if (!ad->s) {
|
if (!pd->s) {
|
||||||
ERROR("Cannot connect to server in PulseAudio output " \
|
ERROR("Cannot connect to server in PulseAudio output " \
|
||||||
"\"%s\" (attempt %i): %s\n", audioOutput->name,
|
"\"%s\" (attempt %i): %s\n", audioOutput->name,
|
||||||
ad->connAttempts, pa_strerror(error));
|
pd->connAttempts, pa_strerror(error));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ad->connAttempts = 0;
|
pd->connAttempts = 0;
|
||||||
audioOutput->open = 1;
|
audioOutput->open = 1;
|
||||||
|
|
||||||
DEBUG("PulseAudio output \"%s\" connected and playing %i bit, %i " \
|
DEBUG("PulseAudio output \"%s\" connected and playing %i bit, %i " \
|
||||||
@ -160,23 +160,23 @@ static int pulse_openDevice(AudioOutput * audioOutput)
|
|||||||
|
|
||||||
static void pulse_dropBufferedAudio(AudioOutput * audioOutput)
|
static void pulse_dropBufferedAudio(AudioOutput * audioOutput)
|
||||||
{
|
{
|
||||||
PulseData * ad;
|
PulseData * pd;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
ad = audioOutput->data;
|
pd = audioOutput->data;
|
||||||
if (pa_simple_flush(ad->s, &error) < 0)
|
if (pa_simple_flush(pd->s, &error) < 0)
|
||||||
WARNING("Flush failed in PulseAudio output \"%s\": %s\n",
|
WARNING("Flush failed in PulseAudio output \"%s\": %s\n",
|
||||||
audioOutput->name, pa_strerror(error));
|
audioOutput->name, pa_strerror(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pulse_closeDevice(AudioOutput * audioOutput)
|
static void pulse_closeDevice(AudioOutput * audioOutput)
|
||||||
{
|
{
|
||||||
PulseData * ad;
|
PulseData * pd;
|
||||||
|
|
||||||
ad = audioOutput->data;
|
pd = audioOutput->data;
|
||||||
if (ad->s) {
|
if (pd->s) {
|
||||||
pa_simple_drain(ad->s, NULL);
|
pa_simple_drain(pd->s, NULL);
|
||||||
pa_simple_free(ad->s);
|
pa_simple_free(pd->s);
|
||||||
}
|
}
|
||||||
|
|
||||||
audioOutput->open = 0;
|
audioOutput->open = 0;
|
||||||
@ -185,12 +185,12 @@ static void pulse_closeDevice(AudioOutput * audioOutput)
|
|||||||
static int pulse_playAudio(AudioOutput * audioOutput, char * playChunk,
|
static int pulse_playAudio(AudioOutput * audioOutput, char * playChunk,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
PulseData * ad;
|
PulseData * pd;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
ad = audioOutput->data;
|
pd = audioOutput->data;
|
||||||
|
|
||||||
if (pa_simple_write(ad->s, playChunk, size, &error) < 0) {
|
if (pa_simple_write(pd->s, playChunk, size, &error) < 0) {
|
||||||
ERROR("PulseAudio output \"%s\" disconnecting due to write " \
|
ERROR("PulseAudio output \"%s\" disconnecting due to write " \
|
||||||
"error: %s\n", audioOutput->name, pa_strerror(error));
|
"error: %s\n", audioOutput->name, pa_strerror(error));
|
||||||
pulse_closeDevice(audioOutput);
|
pulse_closeDevice(audioOutput);
|
||||||
|
Loading…
Reference in New Issue
Block a user