aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/jack_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-30 19:43:31 +0100
committerMax Kellermann <max@duempel.org>2009-01-30 19:43:31 +0100
commita93e73bea8dd7659d2af6f3a3045e8a3406263fc (patch)
tree3f394a0bd51d343829b7ea331139acb16723d2b7 /src/output/jack_plugin.c
parent590082767530834ed3abff9009f9169dba4bd16f (diff)
downloadmpd-a93e73bea8dd7659d2af6f3a3045e8a3406263fc.tar.gz
mpd-a93e73bea8dd7659d2af6f3a3045e8a3406263fc.tar.xz
mpd-a93e73bea8dd7659d2af6f3a3045e8a3406263fc.zip
jack: removed sample_rate callback
Currently, the JACK plugin manipulates the audio_format struct which was passed to the open() method. This is very likely to break, because the plugin must not permanently store this pointer. After this patch, MPD ignores sample rate changes. It looks like other software is doing the same, and I guess this is a non-issue. This patch converts the audio_format pointer within jack_data into a static audio_format struct.
Diffstat (limited to 'src/output/jack_plugin.c')
-rw-r--r--src/output/jack_plugin.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/src/output/jack_plugin.c b/src/output/jack_plugin.c
index 4f2edbf87..3a2fc7cad 100644
--- a/src/output/jack_plugin.c
+++ b/src/output/jack_plugin.c
@@ -47,8 +47,8 @@ struct jack_data {
char *output_ports[2];
int ringbuffer_size;
- /* for srate() only */
- struct audio_format *audio_format;
+ /* the current audio format */
+ struct audio_format audio_format;
/* jack library stuff */
jack_port_t *ports[2];
@@ -102,17 +102,6 @@ mpd_jack_finish(void *data)
}
static int
-mpd_jack_srate(G_GNUC_UNUSED jack_nframes_t rate, void *data)
-{
- struct jack_data *jd = (struct jack_data *)data;
- struct audio_format *audioFormat = jd->audio_format;
-
- audioFormat->sample_rate = (int)jack_get_sample_rate(jd->client);
-
- return 0;
-}
-
-static int
mpd_jack_process(jack_nframes_t nframes, void *arg)
{
struct jack_data *jd = (struct jack_data *) arg;
@@ -222,10 +211,8 @@ mpd_jack_test_default_device(void)
}
static bool
-mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
+mpd_jack_connect(struct jack_data *jd)
{
- jd->audio_format = audio_format;
-
for (unsigned i = 0; i < G_N_ELEMENTS(jd->ringbuffer); ++i)
jd->ringbuffer[i] =
jack_ringbuffer_create(jd->ringbuffer_size);
@@ -238,7 +225,6 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
}
jack_set_process_callback(jd->client, mpd_jack_process, jd);
- jack_set_sample_rate_callback(jd->client, mpd_jack_srate, jd);
jack_on_shutdown(jd->client, mpd_jack_shutdown, jd);
for (unsigned i = 0; i < G_N_ELEMENTS(jd->ports); ++i) {
@@ -299,12 +285,13 @@ mpd_jack_open(void *data, struct audio_format *audio_format)
assert(jd != NULL);
- if (!mpd_jack_connect(jd, audio_format)) {
+ if (!mpd_jack_connect(jd)) {
mpd_jack_client_free(jd);
return false;
}
set_audioformat(jd, audio_format);
+ jd->audio_format = *audio_format;
return true;
}
@@ -372,7 +359,7 @@ static void
mpd_jack_write_samples(struct jack_data *jd, const void *src,
unsigned num_samples)
{
- switch (jd->audio_format->bits) {
+ switch (jd->audio_format.bits) {
case 16:
mpd_jack_write_samples_16(jd, (const int16_t*)src,
num_samples);
@@ -392,7 +379,7 @@ static bool
mpd_jack_play(void *data, const char *buff, size_t size)
{
struct jack_data *jd = data;
- const size_t frame_size = audio_format_frame_size(jd->audio_format);
+ const size_t frame_size = audio_format_frame_size(&jd->audio_format);
size_t space, space1;
if (jd->shutdown) {