jack: use GLib instead of utils.h
This commit is contained in:
parent
1fe129330e
commit
051e906d85
@ -25,6 +25,12 @@
|
|||||||
#include <jack/types.h>
|
#include <jack/types.h>
|
||||||
#include <jack/ringbuffer.h>
|
#include <jack/ringbuffer.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#undef G_LOG_DOMAIN
|
#undef G_LOG_DOMAIN
|
||||||
#define G_LOG_DOMAIN "jack"
|
#define G_LOG_DOMAIN "jack"
|
||||||
|
|
||||||
@ -58,9 +64,7 @@ mpd_jack_name(const struct jack_data *jd)
|
|||||||
static struct jack_data *
|
static struct jack_data *
|
||||||
mpd_jack_new(void)
|
mpd_jack_new(void)
|
||||||
{
|
{
|
||||||
struct jack_data *ret;
|
struct jack_data *ret = g_new(struct jack_data, 1);
|
||||||
|
|
||||||
ret = xcalloc(sizeof(*ret), 1);
|
|
||||||
|
|
||||||
ret->ringbuffer_size = 32768;
|
ret->ringbuffer_size = 32768;
|
||||||
|
|
||||||
@ -92,19 +96,14 @@ mpd_jack_client_free(struct jack_data *jd)
|
|||||||
static void
|
static void
|
||||||
mpd_jack_free(struct jack_data *jd)
|
mpd_jack_free(struct jack_data *jd)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
assert(jd != NULL);
|
assert(jd != NULL);
|
||||||
|
|
||||||
mpd_jack_client_free(jd);
|
mpd_jack_client_free(jd);
|
||||||
|
|
||||||
g_free(jd->name);
|
g_free(jd->name);
|
||||||
|
|
||||||
for ( i = ARRAY_SIZE(jd->output_ports); --i >= 0; ) {
|
for (unsigned i = 0; i < G_N_ELEMENTS(jd->output_ports); ++i)
|
||||||
if (!jd->output_ports[i])
|
g_free(jd->output_ports[i]);
|
||||||
continue;
|
|
||||||
xfree(jd->output_ports[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(jd);
|
free(jd);
|
||||||
}
|
}
|
||||||
@ -211,19 +210,19 @@ mpd_jack_init(struct audio_output *ao,
|
|||||||
bp->name, bp->line, bp->value);
|
bp->name, bp->line, bp->value);
|
||||||
|
|
||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
jd->output_ports[0] = xstrdup(bp->value);
|
jd->output_ports[0] = g_strdup(bp->value);
|
||||||
*cp++ = ',';
|
*cp++ = ',';
|
||||||
|
|
||||||
if (!*cp)
|
if (!*cp)
|
||||||
g_error("expected a second value for '%s' at line %d: %s",
|
g_error("expected a second value for '%s' at line %d: %s",
|
||||||
bp->name, bp->line, bp->value);
|
bp->name, bp->line, bp->value);
|
||||||
|
|
||||||
jd->output_ports[1] = xstrdup(cp);
|
jd->output_ports[1] = g_strdup(cp);
|
||||||
|
|
||||||
if (strchr(cp,','))
|
if (strchr(cp,','))
|
||||||
g_error("Only %d values are supported for '%s' "
|
g_error("Only %d values are supported for '%s' "
|
||||||
"at line %d",
|
"at line %d",
|
||||||
(int)ARRAY_SIZE(jd->output_ports),
|
(int)G_N_ELEMENTS(jd->output_ports),
|
||||||
bp->name, bp->line);
|
bp->name, bp->line);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +241,7 @@ mpd_jack_init(struct audio_output *ao,
|
|||||||
|
|
||||||
if ( (bp = getBlockParam(param, "name"))
|
if ( (bp = getBlockParam(param, "name"))
|
||||||
&& (strcmp(bp->value, "mpd") != 0) ) {
|
&& (strcmp(bp->value, "mpd") != 0) ) {
|
||||||
jd->name = xstrdup(bp->value);
|
jd->name = g_strdup(bp->value);
|
||||||
g_debug("name=%s", jd->name);
|
g_debug("name=%s", jd->name);
|
||||||
} else
|
} else
|
||||||
jd->name = NULL;
|
jd->name = NULL;
|
||||||
@ -315,7 +314,7 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
|
|||||||
memset(jd->ringbuffer[0]->buf, 0, jd->ringbuffer[0]->size);
|
memset(jd->ringbuffer[0]->buf, 0, jd->ringbuffer[0]->size);
|
||||||
memset(jd->ringbuffer[1]->buf, 0, jd->ringbuffer[1]->size);
|
memset(jd->ringbuffer[1]->buf, 0, jd->ringbuffer[1]->size);
|
||||||
|
|
||||||
port_name = xmalloc(sizeof(char) * (7 + strlen(name)));
|
port_name = g_malloc(sizeof(port_name[0]) * (7 + strlen(name)));
|
||||||
|
|
||||||
sprintf(port_name, "%s:left", name);
|
sprintf(port_name, "%s:left", name);
|
||||||
if ( (jack_connect(jd->client, port_name,
|
if ( (jack_connect(jd->client, port_name,
|
||||||
|
Loading…
Reference in New Issue
Block a user