aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/fmplayer_drumrom_unix.c2
-rw-r--r--gtk/Makefile.am17
-rw-r--r--gtk/configure.ac23
-rw-r--r--soundout/alsaout.c (renamed from gtk/soundout/alsaout.c)21
-rw-r--r--soundout/alsaout.h (renamed from gtk/soundout/alsaout.h)0
-rw-r--r--soundout/jackout.c (renamed from gtk/soundout/jackout.c)0
-rw-r--r--soundout/jackout.h (renamed from gtk/soundout/jackout.h)0
-rw-r--r--soundout/ossout.c (renamed from gtk/soundout/ossout.c)0
-rw-r--r--soundout/pulseout.c (renamed from gtk/soundout/pulseout.c)35
-rw-r--r--soundout/pulseout.h (renamed from gtk/soundout/pulseout.h)0
-rw-r--r--soundout/soundout.c (renamed from gtk/soundout/soundout.c)10
-rw-r--r--soundout/soundout.h (renamed from gtk/soundout/soundout.h)0
12 files changed, 89 insertions, 19 deletions
diff --git a/common/fmplayer_drumrom_unix.c b/common/fmplayer_drumrom_unix.c
index 791b264..9111616 100644
--- a/common/fmplayer_drumrom_unix.c
+++ b/common/fmplayer_drumrom_unix.c
@@ -11,7 +11,7 @@ static struct {
#define DATADIR "/.local/share/fmplayer/"
-void loadfile(void) {
+static void loadfile(void) {
const char *path = "ym2608_adpcm_rom.bin";
const char *home = getenv("HOME");
char *dpath = 0;
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 43a767d..2375b28 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -19,15 +19,22 @@ FMDSP_SRC=../fmdsp/fmdsp.c \
../fmdsp/font_fmdsp_small.c \
../fmdsp/fmdsp_platform_unix.c
-SOUNDOUT_SRC=soundout/soundout.c \
- soundout/pulseout.c \
- soundout/jackout.c \
- soundout/alsaout.c
+SOUNDOUT_SRC=../soundout/soundout.c
+
+if ENABLE_JACK
+SOUNDOUT_SRC+=../soundout/jackout.c
+endif
+if ENABLE_PULSE
+SOUNDOUT_SRC+=../soundout/pulseout.c
+endif
+if ENABLE_ALSA
+SOUNDOUT_SRC+=../soundout/alsaout.c
+endif
#fmplayer_CFLAGS=$(CFLAGS)
#CFLAGS=
fmplayer_CPPFLAGS=-Wall -Wextra -pedantic \
- -I.. -Isoundout \
+ -I.. -I../soundout \
$(GTK3_CFLAGS) $(JACK_CFLAGS) $(PULSE_CFLAGS) $(ALSA_CFLAGS) $(SNDFILE_CFLAGS)
fmplayer_LDADD=$(GTK3_LIBS) $(JACK_LIBS) $(PULSE_LIBS) $(ALSA_LIBS) $(SNDFILE_LIBS) -lm -lpthread
diff --git a/gtk/configure.ac b/gtk/configure.ac
index 8a61ac1..fc79c8c 100644
--- a/gtk/configure.ac
+++ b/gtk/configure.ac
@@ -6,12 +6,29 @@ AC_PROG_RANLIB
AM_PROG_AR
AM_PROG_AS
-PKG_CHECK_MODULES([JACK], [jack soxr])
-PKG_CHECK_MODULES([PULSE], [libpulse])
-PKG_CHECK_MODULES([ALSA], [alsa])
+PKG_CHECK_MODULES([JACK], [jack soxr], [jack_found=yes], [jack_found=no])
+PKG_CHECK_MODULES([PULSE], [libpulse], [pulse_found=yes], [pulse_found=no])
+PKG_CHECK_MODULES([ALSA], [alsa], [alsa_found=yes], [alsa_found=no])
PKG_CHECK_MODULES([GTK3], [gtk+-3.0 cairo])
PKG_CHECK_MODULES([SNDFILE], [sndfile])
+AS_IF([test "x$jack_found" = "xno" -a "x$pulse_found" = "xno" -a "x$alsa_found" = "xno"], [
+ AC_MSG_ERROR([No audio output backend found])
+])
+
+AM_CONDITIONAL([ENABLE_JACK], [test "x$jack_found" = "xyes"])
+AS_IF([test "x$jack_found" = "xyes"], [
+ AC_DEFINE([ENABLE_JACK])
+])
+AM_CONDITIONAL([ENABLE_PULSE], [test "x$pulse_found" = "xyes"])
+AS_IF([test "x$pulse_found" = "xyes"], [
+ AC_DEFINE([ENABLE_PULSE])
+])
+AM_CONDITIONAL([ENABLE_ALSA], [test "x$alsa_found" = "xyes"])
+AS_IF([test "x$alsa_found" = "xyes"], [
+ AC_DEFINE([ENABLE_ALSA])
+])
+
AC_ARG_ENABLE([neon], AS_HELP_STRING([--enable-neon], [Enable NEON optimized functions for SSG sinc filtering and fmdsp palette lookup. Tested on Cortex-A53 (Raspberry PI 3)]))
AM_CONDITIONAL([ENABLE_NEON], [test "x$enable_neon" = "xyes"])
AS_IF([test "x$enable_neon" = "xyes"], [
diff --git a/gtk/soundout/alsaout.c b/soundout/alsaout.c
index 5c5e667..0658206 100644
--- a/gtk/soundout/alsaout.c
+++ b/soundout/alsaout.c
@@ -46,7 +46,8 @@ static void *alsaout_thread(void *ptr) {
if (as->terminate) return 0;
if (as->fds[0].revents) {
uint64_t eventdata;
- read(as->fd_event, &eventdata, sizeof(eventdata));
+ ssize_t t = read(as->fd_event, &eventdata, sizeof(eventdata));
+ (void)t;
}
unsigned short event;
if (snd_pcm_poll_descriptors_revents(
@@ -80,13 +81,20 @@ static void *alsaout_thread(void *ptr) {
static void alsaout_pause(struct sound_state *ss, int pause, int flush) {
struct alsaout_state *as = (struct alsaout_state *)ss;
+ as->paused = pause;
+ if (!pause && flush) {
+ snd_pcm_drop(as->apcm);
+ snd_pcm_prepare(as->apcm);
+ snd_pcm_start(as->apcm);
+ } else {
+ snd_pcm_pause(as->apcm, pause);
+ }
while (atomic_flag_test_and_set_explicit(
&as->cb_flag, memory_order_acquire));
- as->paused = pause;
- snd_pcm_pause(as->apcm, pause);
atomic_flag_clear_explicit(&as->cb_flag, memory_order_release);
uint64_t event = 1;
- write(as->fd_event, &event, sizeof(event));
+ ssize_t t = write(as->fd_event, &event, sizeof(event));
+ (void)t;
}
static void alsaout_free(struct sound_state *ss) {
@@ -95,7 +103,8 @@ static void alsaout_free(struct sound_state *ss) {
if (as->thread_valid) {
as->terminate = true;
uint64_t event = 1;
- write(as->fd_event, &event, sizeof(event));
+ ssize_t t = write(as->fd_event, &event, sizeof(event));
+ (void)t;
pthread_join(as->alsa_thread, 0);
}
if (as->fd_event != -1) {
@@ -144,7 +153,7 @@ struct sound_state *alsaout_init(
goto err;
}
as->thread_valid = true;
- return as;
+ return &as->ss;
err:
alsaout_free(&as->ss);
diff --git a/gtk/soundout/alsaout.h b/soundout/alsaout.h
index cd79c27..cd79c27 100644
--- a/gtk/soundout/alsaout.h
+++ b/soundout/alsaout.h
diff --git a/gtk/soundout/jackout.c b/soundout/jackout.c
index 54e7f16..54e7f16 100644
--- a/gtk/soundout/jackout.c
+++ b/soundout/jackout.c
diff --git a/gtk/soundout/jackout.h b/soundout/jackout.h
index 4b72f2e..4b72f2e 100644
--- a/gtk/soundout/jackout.h
+++ b/soundout/jackout.h
diff --git a/gtk/soundout/ossout.c b/soundout/ossout.c
index 1083f20..1083f20 100644
--- a/gtk/soundout/ossout.c
+++ b/soundout/ossout.c
diff --git a/gtk/soundout/pulseout.c b/soundout/pulseout.c
index 9dbcd6c..5734991 100644
--- a/gtk/soundout/pulseout.c
+++ b/soundout/pulseout.c
@@ -18,16 +18,46 @@ struct pulseout_state {
bool pa_status_changed;
};
+#include <stdio.h>
+
+static void pulseout_success_cb(pa_stream *s, int success, void *userdata) {
+ (void)s;
+ (void)success;
+ struct pulseout_state *ps = userdata;
+ pa_threaded_mainloop_signal(ps->pa_tm, 0);
+}
+
static void pulseout_pause(struct sound_state *ss, int pause, int flush) {
- //return;
struct pulseout_state *ps = (struct pulseout_state *)ss;
if (ps->paused != !!pause) {
if (pause) {
pa_threaded_mainloop_lock(ps->pa_tm);
+ pa_operation *op_cork = pa_stream_cork(ps->pa_s, 1, pulseout_success_cb, ps);
+ while (pa_operation_get_state(op_cork) == PA_OPERATION_RUNNING)
+ pa_threaded_mainloop_wait(ps->pa_tm);
+ pa_operation_unref(op_cork);
}
ps->paused = pause;
if (!pause) {
- if (flush) ps->flush = true;
+ //if (flush) ps->flush = true;
+ if (flush) {
+ pa_operation *op_flush = pa_stream_flush(ps->pa_s, pulseout_success_cb, ps);
+ if (op_flush) {
+ while (pa_operation_get_state(op_flush) == PA_OPERATION_RUNNING)
+ pa_threaded_mainloop_wait(ps->pa_tm);
+ pa_operation_unref(op_flush);
+ } else {
+ fprintf(stderr, "FLUSH ERR\n");
+ }
+ }
+ pa_operation *op_cork = pa_stream_cork(ps->pa_s, 0, pulseout_success_cb, ps);
+ if (op_cork) {
+ while (pa_operation_get_state(op_cork) == PA_OPERATION_RUNNING)
+ pa_threaded_mainloop_wait(ps->pa_tm);
+ pa_operation_unref(op_cork);
+ } else {
+ fprintf(stderr, "CORK ERR\n");
+ }
pa_threaded_mainloop_unlock(ps->pa_tm);
}
}
@@ -70,6 +100,7 @@ static void pulseout_cb(pa_stream *p, size_t bytes, void *userdata) {
}
static void pa_c_cb(pa_context *pa_c, void *userdata) {
+ (void)pa_c;
struct pulseout_state *ps = userdata;
ps->pa_status_changed = true;
pa_threaded_mainloop_signal(ps->pa_tm, 0);
diff --git a/gtk/soundout/pulseout.h b/soundout/pulseout.h
index d9fbb20..d9fbb20 100644
--- a/gtk/soundout/pulseout.h
+++ b/soundout/pulseout.h
diff --git a/gtk/soundout/soundout.c b/soundout/soundout.c
index 56134be..a749fe4 100644
--- a/gtk/soundout/soundout.c
+++ b/soundout/soundout.c
@@ -5,10 +5,16 @@
struct sound_state *sound_init(const char *clientname, unsigned srate, sound_callback cbfunc, void *userptr) {
struct sound_state *ss = 0;
- //ss = jackout_init(clientname, srate, cbfunc, userptr);
+#ifdef ENABLE_JACK
+ ss = jackout_init(clientname, srate, cbfunc, userptr);
+#endif
if (ss) return ss;
- //ss = pulseout_init(clientname, srate, cbfunc, userptr);
+#ifdef ENABLE_PULSE
+ ss = pulseout_init(clientname, srate, cbfunc, userptr);
+#endif
if (ss) return ss;
+#ifdef ENABLE_ALSA
ss = alsaout_init(clientname, srate, cbfunc, userptr);
+#endif
return ss;
}
diff --git a/gtk/soundout/soundout.h b/soundout/soundout.h
index aea926f..aea926f 100644
--- a/gtk/soundout/soundout.h
+++ b/soundout/soundout.h