mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-15 09:44:04 +00:00
jack audio connection kit data
This commit is contained in:
parent
b0a22d534d
commit
501bdc03e8
@ -780,6 +780,29 @@ fi
|
||||
if test x$want_alsa = xyes; then
|
||||
AC_CHECK_LIB(asound, snd_pcm_open,conky_LIBS="$conky_LIBS -lasound", want_alsa=no)
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl jack audio connection kit
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE([jack],
|
||||
AC_HELP_STRING([--enable-jack], [enable Jack Audio Connection Kit support @<:@default=no@:>@]),
|
||||
[want_jack="$enableval"], [want_jack=no])
|
||||
|
||||
if test "x$want_jack" = "xyes"; then
|
||||
AC_CHECK_HEADER(jack/jack.h,, want_jack=no)
|
||||
fi
|
||||
if test "x$want_jack" = "xyes"; then
|
||||
AC_CHECK_LIB(jack, jack_client_open,conky_LIBS="$conky_LIBS -ljack", want_jack=no)
|
||||
fi
|
||||
|
||||
if test "x$want_jack" = "xyes"; then
|
||||
AC_DEFINE(JACK, 1, [Define if you want JACK support])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(BUILD_JACK, test x$want_jack = xyes)
|
||||
|
||||
|
||||
dnl
|
||||
dnl Some headers
|
||||
dnl
|
||||
@ -960,6 +983,7 @@ if test "x$want_profiling" = "xyes" -a $ac_cv_c_compiler_gnu != no; then
|
||||
AC_DEFINE([PROFILING], [], [Define for profiling (gprof and gcov) support])
|
||||
fi
|
||||
|
||||
|
||||
AC_SUBST(conky_CFLAGS)
|
||||
AC_SUBST(conky_LIBS)
|
||||
AC_SUBST(X11_LIBS)
|
||||
@ -1010,6 +1034,7 @@ dnl OpenMP: $want_openmp
|
||||
config-output: $want_config_output
|
||||
Imlib2: $want_imlib2
|
||||
ALSA mixer: $want_alsa
|
||||
JACK: $want_jack
|
||||
apcupsd: $want_apcupsd
|
||||
I/O stats: $want_iostats
|
||||
ncurses: $want_ncurses
|
||||
|
@ -83,12 +83,13 @@ nvidia = nvidia.c nvidia.h
|
||||
imlib2 = imlib2.c imlib2.h
|
||||
apcupsd = apcupsd.c apcupsd.h
|
||||
iconv = iconv_tools.c iconv_tools.h
|
||||
jack = jack.c jack.h
|
||||
|
||||
# make sure the files from above are always included in the distfile
|
||||
EXTRA_DIST = $(audacious) $(bmpx) $(ibm) $(mpd) $(moc) $(xmms2) $(linux) \
|
||||
$(solaris) $(freebsd) $(netbsd) $(openbsd) $(port_monitors) \
|
||||
$(x11) $(hddtemp) $(eve) $(ccurl_thread) $(rss) $(weather) \
|
||||
$(lua) $(nvidia) $(imlib2) $(apcupsd)
|
||||
$(lua) $(nvidia) $(imlib2) $(apcupsd) $(jack)
|
||||
|
||||
# collect all selected optional sources
|
||||
optional_sources =
|
||||
@ -161,6 +162,9 @@ endif
|
||||
if BUILD_ICONV
|
||||
optional_sources += $(iconv)
|
||||
endif
|
||||
if BUILD_JACK
|
||||
optional_sources += $(jack)
|
||||
endif
|
||||
|
||||
# linux takes the standard to the max
|
||||
if BUILD_LINUX
|
||||
|
23
src/conky.c
23
src/conky.c
@ -2368,6 +2368,29 @@ void generate_text_internal(char *p, int p_max_size,
|
||||
cur->apcupsd.items[APCUPSD_LASTXFER]);
|
||||
}
|
||||
#endif /* APCUPSD */
|
||||
#ifdef JACK
|
||||
OBJ(if_jack_active) {
|
||||
if (!cur->jack.active) {
|
||||
DO_JUMP;
|
||||
}
|
||||
}
|
||||
OBJ(jack_cpu_load) {
|
||||
snprintf(p, p_max_size, "%2.2f",
|
||||
cur->jack.cpu_load);
|
||||
}
|
||||
OBJ(jack_buffer_size) {
|
||||
snprintf(p, p_max_size, "%u",
|
||||
cur->jack.buffer_size);
|
||||
}
|
||||
OBJ(jack_sample_rate) {
|
||||
snprintf(p, p_max_size, "%u",
|
||||
cur->jack.sample_rate);
|
||||
}
|
||||
OBJ(jack_xruns) {
|
||||
snprintf(p, p_max_size, "%d",
|
||||
cur->jack.xruns);
|
||||
}
|
||||
#endif /* JACK */
|
||||
break;
|
||||
}
|
||||
#undef DO_JUMP
|
||||
|
@ -125,6 +125,10 @@ struct text_object;
|
||||
#include "apcupsd.h"
|
||||
#endif
|
||||
|
||||
#ifdef JACK
|
||||
#include "jack.h"
|
||||
#endif
|
||||
|
||||
/* sony support */
|
||||
#include "sony.h"
|
||||
|
||||
@ -269,6 +273,10 @@ struct information {
|
||||
APCUPSD_S apcupsd;
|
||||
#endif
|
||||
|
||||
#ifdef JACK
|
||||
struct jack_s jack;
|
||||
#endif
|
||||
|
||||
short kflags; /* kernel settings, see enum KFLAG */
|
||||
};
|
||||
|
||||
|
16
src/core.c
16
src/core.c
@ -1150,6 +1150,13 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
END OBJ(apcupsd_temp, &update_apcupsd)
|
||||
END OBJ(apcupsd_lastxfer, &update_apcupsd)
|
||||
#endif /* APCUPSD */
|
||||
#ifdef JACK
|
||||
END OBJ_IF(if_jack_active, &update_jack)
|
||||
END OBJ(jack_cpu_load, &update_jack)
|
||||
END OBJ(jack_buffer_size, &update_jack)
|
||||
END OBJ(jack_sample_rate, &update_jack)
|
||||
END OBJ(jack_xruns, &update_jack)
|
||||
#endif /* JACK */
|
||||
END {
|
||||
char buf[text_buffer_size];
|
||||
|
||||
@ -1832,6 +1839,15 @@ void free_text_objects(struct text_object *root, int internal)
|
||||
}
|
||||
break;
|
||||
#endif /* X11 */
|
||||
#ifdef JACK
|
||||
case OBJ_if_jack_active:
|
||||
case OBJ_jack_cpu_load:
|
||||
case OBJ_jack_buffer_size:
|
||||
case OBJ_jack_sample_rate:
|
||||
case OBJ_jack_xruns:
|
||||
jack_close();
|
||||
break;
|
||||
#endif /* JACK */
|
||||
}
|
||||
if(obj->special_data)
|
||||
free(obj->special_data);
|
||||
|
133
src/jack.c
Normal file
133
src/jack.c
Normal file
@ -0,0 +1,133 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
*
|
||||
* Conky, a system monitor, based on torsmo
|
||||
*
|
||||
* Any original torsmo code is licensed under the BSD license
|
||||
*
|
||||
* All code written since the fork of torsmo is licensed under the GPL
|
||||
*
|
||||
* Please see COPYING for details
|
||||
*
|
||||
* Copyright (c) 2005-2012 Brenden Matthews, Philip Kovacs, et. al.
|
||||
* (see AUTHORS)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
|
||||
#include <jack/jack.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
static jack_client_t* client = 0;
|
||||
static sem_t zombified;
|
||||
|
||||
void jack_shutdown_cb(void* arg)
|
||||
{
|
||||
/* this is called from JACK's thread */
|
||||
struct jack_s* jackdata = (struct jack_s*)arg;
|
||||
int z = 0;
|
||||
if (sem_getvalue(&zombified, &z) == 0 && z == 0) {
|
||||
sem_post (&zombified);
|
||||
}
|
||||
}
|
||||
|
||||
int jack_buffer_size_cb(jack_nframes_t nframes, void* arg)
|
||||
{
|
||||
struct jack_s* jackdata = (struct jack_s*)arg;
|
||||
/*printf("jack buffer size changing to %u\n", nframes);*/
|
||||
jackdata->buffer_size = nframes;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int jack_sample_rate_cb(jack_nframes_t nframes, void* arg)
|
||||
{
|
||||
struct jack_s* jackdata = (struct jack_s*)arg;
|
||||
/*printf("jack sample rate changing to %u\n", nframes);*/
|
||||
jackdata->sample_rate = nframes;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int jack_xrun_cb(void* arg)
|
||||
{
|
||||
struct jack_s* jackdata = (struct jack_s*)arg;
|
||||
/*printf("jack xrun\n");*/
|
||||
jackdata->xruns++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int connect_jack(struct jack_s* jackdata)
|
||||
{
|
||||
/*printf("connecting jack... ");*/
|
||||
if ((client = jack_client_open("conky", JackNoStartServer, NULL)) == 0) {
|
||||
/*printf("fail\n");*/
|
||||
return -1;
|
||||
}
|
||||
/*printf("ok\n");*/
|
||||
sem_init(&zombified, 0, 0);
|
||||
jackdata->buffer_size = jack_get_buffer_size(client);
|
||||
jackdata->sample_rate = jack_get_sample_rate(client);
|
||||
jack_on_shutdown(client, jack_shutdown_cb, jackdata);
|
||||
jack_set_buffer_size_callback(client, jack_buffer_size_cb, jackdata);
|
||||
jack_set_sample_rate_callback(client, jack_sample_rate_cb, jackdata);
|
||||
jack_set_xrun_callback(client, jack_xrun_cb, jackdata);
|
||||
}
|
||||
|
||||
int update_jack(void)
|
||||
{
|
||||
struct information *current_info = &info;
|
||||
struct jack_s* jackdata = ¤t_info->jack;
|
||||
/*printf("jack active: '%s'\n", jackdata->active ? "yes" : "no");*/
|
||||
if (!jackdata->active) {
|
||||
jackdata->active = 0;
|
||||
jackdata->cpu_load = 0;
|
||||
jackdata->buffer_size = 0;
|
||||
jackdata->sample_rate = 0;
|
||||
jackdata->xruns = 0;
|
||||
if (connect_jack(jackdata) == 0) {
|
||||
if (jack_activate(client) == 0) {
|
||||
printf("activated jack client\n");
|
||||
jackdata->active = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (jackdata->active) {
|
||||
int z = 0;
|
||||
jackdata->cpu_load = jack_cpu_load(client);
|
||||
if (sem_getvalue (&zombified, &z) == 0 && z > 0) {
|
||||
/*printf("jack zombified client\n");*/
|
||||
sem_destroy(&zombified);
|
||||
jackdata->active = 0;
|
||||
client = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void jack_close(void)
|
||||
{
|
||||
if (client) {
|
||||
/*printf("closing jack client... ");*/
|
||||
if (jack_client_close(client) == 0) {
|
||||
/*printf("ok\n");*/
|
||||
}
|
||||
else {
|
||||
/*printf("fail\n");*/
|
||||
}
|
||||
client = 0;
|
||||
}
|
||||
}
|
||||
|
45
src/jack.h
Normal file
45
src/jack.h
Normal file
@ -0,0 +1,45 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
*
|
||||
* Conky, a system monitor, based on torsmo
|
||||
*
|
||||
* Any original torsmo code is licensed under the BSD license
|
||||
*
|
||||
* All code written since the fork of torsmo is licensed under the GPL
|
||||
*
|
||||
* Please see COPYING for details
|
||||
*
|
||||
* Copyright (c) 2005-2012 Brenden Matthews, Philip Kovacs, et. al.
|
||||
* (see AUTHORS)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef JACK_H_
|
||||
#define JACK_H_
|
||||
|
||||
#include <jack/jack.h>
|
||||
|
||||
struct jack_s {
|
||||
int active;
|
||||
float cpu_load;
|
||||
jack_nframes_t buffer_size;
|
||||
jack_nframes_t sample_rate;
|
||||
int xruns;
|
||||
};
|
||||
|
||||
int update_jack(void);
|
||||
void jack_close(void);
|
||||
|
||||
#endif /*JACK_H_*/
|
@ -469,6 +469,13 @@ enum text_object_type {
|
||||
OBJ_apcupsd_temp,
|
||||
OBJ_apcupsd_lastxfer,
|
||||
#endif /* APCUPSD */
|
||||
#ifdef JACK
|
||||
OBJ_if_jack_active,
|
||||
OBJ_jack_cpu_load,
|
||||
OBJ_jack_buffer_size,
|
||||
OBJ_jack_sample_rate,
|
||||
OBJ_jack_xruns
|
||||
#endif /* JACK */
|
||||
};
|
||||
|
||||
struct text_object {
|
||||
|
Loading…
Reference in New Issue
Block a user