summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-02-23 03:23:22 +0100
committerLennart Poettering <lennart@poettering.net>2010-02-23 03:23:22 +0100
commitd11cd33e3aff14fdd66826b3252d90b1b0e38c48 (patch)
tree90d9a7b25b807a1137f539815f9d16299fcd4f58
parentc97013109494f9bc977db38d6ae4e972e59574f4 (diff)
alsa: don't make use of tsched related variables when tsched is disabled
-rw-r--r--src/modules/alsa/alsa-sink.c34
-rw-r--r--src/modules/alsa/alsa-source.c28
2 files changed, 40 insertions, 22 deletions
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 60c10c49f..581b94306 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -629,11 +629,14 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polle
}
}
- *sleep_usec = pa_bytes_to_usec(left_to_play, &u->sink->sample_spec);
+ if (u->use_tsched) {
+ *sleep_usec = pa_bytes_to_usec(left_to_play, &u->sink->sample_spec);
- if (*sleep_usec > process_usec)
- *sleep_usec -= process_usec;
- else
+ if (*sleep_usec > process_usec)
+ *sleep_usec -= process_usec;
+ else
+ *sleep_usec = 0;
+ } else
*sleep_usec = 0;
return work_done ? 1 : 0;
@@ -766,11 +769,14 @@ static int unix_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polle
}
}
- *sleep_usec = pa_bytes_to_usec(left_to_play, &u->sink->sample_spec);
+ if (u->use_tsched) {
+ *sleep_usec = pa_bytes_to_usec(left_to_play, &u->sink->sample_spec);
- if (*sleep_usec > process_usec)
- *sleep_usec -= process_usec;
- else
+ if (*sleep_usec > process_usec)
+ *sleep_usec -= process_usec;
+ else
+ *sleep_usec = 0;
+ } else
*sleep_usec = 0;
return work_done ? 1 : 0;
@@ -1267,6 +1273,9 @@ static void sink_update_requested_latency_cb(pa_sink *s) {
struct userdata *u = s->userdata;
size_t before;
pa_assert(u);
+ pa_assert(u->use_tsched); /* only when timer scheduling is used
+ * we can dynamically adjust the
+ * latency */
if (!u->pcm_handle)
return;
@@ -1301,7 +1310,10 @@ static int process_rewind(struct userdata *u) {
return -1;
}
- unused_nbytes = u->tsched_watermark + (size_t) unused * u->frame_size;
+ unused_nbytes = (size_t) unused * u->frame_size;
+
+ if (u->use_tsched)
+ unused_nbytes += u->tsched_watermark;
if (u->hwbuf_size > unused_nbytes)
limit_nbytes = u->hwbuf_size - unused_nbytes;
@@ -1862,7 +1874,8 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
}
u->sink->parent.process_msg = sink_process_msg;
- u->sink->update_requested_latency = sink_update_requested_latency_cb;
+ if (u->use_tsched)
+ u->sink->update_requested_latency = sink_update_requested_latency_cb;
u->sink->set_state = sink_set_state_cb;
u->sink->set_port = sink_set_port_cb;
u->sink->userdata = u;
@@ -1906,7 +1919,6 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
} else
pa_sink_set_fixed_latency(u->sink, pa_bytes_to_usec(u->hwbuf_size, &ss));
-
reserve_update(u);
if (update_sw_params(u) < 0)
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index f8b583ead..1022d0d33 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -603,12 +603,14 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled
}
}
- *sleep_usec = pa_bytes_to_usec(left_to_record, &u->source->sample_spec);
+ if (u->use_tsched) {
+ *sleep_usec = pa_bytes_to_usec(left_to_record, &u->source->sample_spec);
- if (*sleep_usec > process_usec)
- *sleep_usec -= process_usec;
- else
- *sleep_usec = 0;
+ if (*sleep_usec > process_usec)
+ *sleep_usec -= process_usec;
+ else
+ *sleep_usec = 0;
+ }
return work_done ? 1 : 0;
}
@@ -730,12 +732,14 @@ static int unix_read(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled
}
}
- *sleep_usec = pa_bytes_to_usec(left_to_record, &u->source->sample_spec);
+ if (u->use_tsched) {
+ *sleep_usec = pa_bytes_to_usec(left_to_record, &u->source->sample_spec);
- if (*sleep_usec > process_usec)
- *sleep_usec -= process_usec;
- else
- *sleep_usec = 0;
+ if (*sleep_usec > process_usec)
+ *sleep_usec -= process_usec;
+ else
+ *sleep_usec = 0;
+ }
return work_done ? 1 : 0;
}
@@ -1205,6 +1209,7 @@ static int source_set_port_cb(pa_source *s, pa_device_port *p) {
static void source_update_requested_latency_cb(pa_source *s) {
struct userdata *u = s->userdata;
pa_assert(u);
+ pa_assert(u->use_tsched);
if (!u->pcm_handle)
return;
@@ -1693,7 +1698,8 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
}
u->source->parent.process_msg = source_process_msg;
- u->source->update_requested_latency = source_update_requested_latency_cb;
+ if (u->use_tsched)
+ u->source->update_requested_latency = source_update_requested_latency_cb;
u->source->set_state = source_set_state_cb;
u->source->set_port = source_set_port_cb;
u->source->userdata = u;