pulse: use GLib instead of util.h/log.h
Use GLib allocation and logging functions.
This commit is contained in:
parent
38df17546a
commit
d692e925a4
@ -17,9 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../output_api.h"
|
#include "../output_api.h"
|
||||||
#include "../utils.h"
|
|
||||||
#include "../log.h"
|
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
#include <pulse/simple.h>
|
#include <pulse/simple.h>
|
||||||
#include <pulse/error.h>
|
#include <pulse/error.h>
|
||||||
|
|
||||||
@ -40,7 +39,7 @@ static struct pulse_data *pulse_new_data(void)
|
|||||||
{
|
{
|
||||||
struct pulse_data *ret;
|
struct pulse_data *ret;
|
||||||
|
|
||||||
ret = xmalloc(sizeof(*ret));
|
ret = g_new(struct pulse_data, 1);
|
||||||
|
|
||||||
ret->s = NULL;
|
ret->s = NULL;
|
||||||
ret->server = NULL;
|
ret->server = NULL;
|
||||||
@ -53,11 +52,9 @@ static struct pulse_data *pulse_new_data(void)
|
|||||||
|
|
||||||
static void pulse_free_data(struct pulse_data *pd)
|
static void pulse_free_data(struct pulse_data *pd)
|
||||||
{
|
{
|
||||||
if (pd->server)
|
g_free(pd->server);
|
||||||
free(pd->server);
|
g_free(pd->sink);
|
||||||
if (pd->sink)
|
g_free(pd);
|
||||||
free(pd->sink);
|
|
||||||
free(pd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
@ -76,8 +73,8 @@ pulse_init(struct audio_output *ao,
|
|||||||
|
|
||||||
pd = pulse_new_data();
|
pd = pulse_new_data();
|
||||||
pd->ao = ao;
|
pd->ao = ao;
|
||||||
pd->server = server ? xstrdup(server->value) : NULL;
|
pd->server = g_strdup(server->value);
|
||||||
pd->sink = sink ? xstrdup(sink->value) : NULL;
|
pd->sink = g_strdup(sink->value);
|
||||||
|
|
||||||
return pd;
|
return pd;
|
||||||
}
|
}
|
||||||
@ -102,8 +99,8 @@ static int pulse_test_default_device(void)
|
|||||||
s = pa_simple_new(NULL, MPD_PULSE_NAME, PA_STREAM_PLAYBACK, NULL,
|
s = pa_simple_new(NULL, MPD_PULSE_NAME, PA_STREAM_PLAYBACK, NULL,
|
||||||
MPD_PULSE_NAME, &ss, NULL, NULL, &error);
|
MPD_PULSE_NAME, &ss, NULL, NULL, &error);
|
||||||
if (!s) {
|
if (!s) {
|
||||||
WARNING("Cannot connect to default PulseAudio server: %s\n",
|
g_message("Cannot connect to default PulseAudio server: %s\n",
|
||||||
pa_strerror(error));
|
pa_strerror(error));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,20 +139,20 @@ pulse_open(void *data, struct audio_format *audio_format)
|
|||||||
&ss, NULL, NULL,
|
&ss, NULL, NULL,
|
||||||
&error);
|
&error);
|
||||||
if (!pd->s) {
|
if (!pd->s) {
|
||||||
ERROR("Cannot connect to server in PulseAudio output "
|
g_warning("Cannot connect to server in PulseAudio output "
|
||||||
"\"%s\" (attempt %i): %s\n",
|
"\"%s\" (attempt %i): %s\n",
|
||||||
audio_output_get_name(pd->ao),
|
audio_output_get_name(pd->ao),
|
||||||
pd->num_connect_attempts, pa_strerror(error));
|
pd->num_connect_attempts, pa_strerror(error));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pd->num_connect_attempts = 0;
|
pd->num_connect_attempts = 0;
|
||||||
|
|
||||||
DEBUG("PulseAudio output \"%s\" connected and playing %i bit, %i "
|
g_debug("PulseAudio output \"%s\" connected and playing %i bit, %i "
|
||||||
"channel audio at %i Hz\n",
|
"channel audio at %i Hz\n",
|
||||||
audio_output_get_name(pd->ao),
|
audio_output_get_name(pd->ao),
|
||||||
audio_format->bits,
|
audio_format->bits,
|
||||||
audio_format->channels, audio_format->sample_rate);
|
audio_format->channels, audio_format->sample_rate);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -166,9 +163,9 @@ static void pulse_cancel(void *data)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (pa_simple_flush(pd->s, &error) < 0)
|
if (pa_simple_flush(pd->s, &error) < 0)
|
||||||
WARNING("Flush failed in PulseAudio output \"%s\": %s\n",
|
g_warning("Flush failed in PulseAudio output \"%s\": %s\n",
|
||||||
audio_output_get_name(pd->ao),
|
audio_output_get_name(pd->ao),
|
||||||
pa_strerror(error));
|
pa_strerror(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pulse_close(void *data)
|
static void pulse_close(void *data)
|
||||||
@ -188,10 +185,10 @@ static int pulse_play(void *data,
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (pa_simple_write(pd->s, playChunk, size, &error) < 0) {
|
if (pa_simple_write(pd->s, playChunk, size, &error) < 0) {
|
||||||
ERROR("PulseAudio output \"%s\" disconnecting due to write "
|
g_warning("PulseAudio output \"%s\" disconnecting due to "
|
||||||
"error: %s\n",
|
"write error: %s\n",
|
||||||
audio_output_get_name(pd->ao),
|
audio_output_get_name(pd->ao),
|
||||||
pa_strerror(error));
|
pa_strerror(error));
|
||||||
pulse_close(pd);
|
pulse_close(pd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user