]> code.delx.au - pulseaudio/commitdiff
libpulse: introduce pa_context_get_tile_size() call
authorLennart Poettering <lennart@poettering.net>
Wed, 28 Oct 2009 22:26:48 +0000 (23:26 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 28 Oct 2009 22:26:48 +0000 (23:26 +0100)
src/map-file
src/pulse/context.c
src/pulse/context.h

index 6f7bdace6079da94f51abcd90c6821aa3aad2026..50111224c24467046dde68a3f81a052ade88b164 100644 (file)
@@ -66,6 +66,7 @@ pa_context_get_source_info_list;
 pa_context_get_source_output_info;
 pa_context_get_source_output_info_list;
 pa_context_get_state;
+pa_context_get_tile_size;
 pa_context_is_local;
 pa_context_is_pending;
 pa_context_kill_client;
index 7468d0a94fe254cd6bdfb83b87c635ac26885b38..e33143d95a20a52848a834e2730f4f3a1e8ac9c0 100644 (file)
@@ -1488,6 +1488,7 @@ pa_time_event* pa_context_rttime_new(pa_context *c, pa_usec_t usec, pa_time_even
     struct timeval tv;
 
     pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
     pa_assert(c->mainloop);
 
     if (usec == PA_USEC_INVALID)
@@ -1502,8 +1503,10 @@ void pa_context_rttime_restart(pa_context *c, pa_time_event *e, pa_usec_t usec)
     struct timeval tv;
 
     pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
     pa_assert(c->mainloop);
 
+
     if (usec == PA_USEC_INVALID)
         c->mainloop->time_restart(e, NULL);
     else {
@@ -1511,3 +1514,17 @@ void pa_context_rttime_restart(pa_context *c, pa_time_event *e, pa_usec_t usec)
         c->mainloop->time_restart(e, &tv);
     }
 }
+
+size_t pa_context_get_tile_size(pa_context *c, const pa_sample_spec *ss) {
+    size_t fs, mbs;
+
+    pa_assert(c);
+    pa_assert(PA_REFCNT_VALUE(c) >= 1);
+
+    PA_CHECK_VALIDITY_RETURN_ANY(c, !pa_detect_fork(), PA_ERR_FORKED, (size_t) -1);
+    PA_CHECK_VALIDITY_RETURN_ANY(c, !ss || pa_sample_spec_valid(ss), PA_ERR_INVALID, (size_t) -1);
+
+    fs = ss ? pa_frame_size(ss) : 1;
+    mbs = PA_ROUND_DOWN(pa_mempool_block_size_max(c->mempool), fs);
+    return PA_MAX(mbs, fs);
+}
index ecff58dfcce060918c71e8f981c1e62751f07e9f..6ac8ee566bd90748992e076fcaf5d418a4f721c1 100644 (file)
@@ -255,12 +255,28 @@ pa_operation *pa_context_proplist_remove(pa_context *c, const char *const keys[]
 uint32_t pa_context_get_index(pa_context *s);
 
 /** Create a new timer event source for the specified time (wrapper
   for mainloop->time_new). \since 0.9.16 */
* for mainloop->time_new). \since 0.9.16 */
 pa_time_event* pa_context_rttime_new(pa_context *c, pa_usec_t usec, pa_time_event_cb_t cb, void *userdata);
-/** Restart a running or expired timer event source (wrapper
-    for mainloop->time_restart). \since 0.9.16 */
+
+/** Restart a running or expired timer event source (wrapper for
+ * mainloop->time_restart). \since 0.9.16 */
 void pa_context_rttime_restart(pa_context *c, pa_time_event *e, pa_usec_t usec);
 
+/* Return the optimal block size for passing around audio buffers. It
+ * is recommended to allocate buffers of the size returned here when
+ * writing audio data to playback streams, if the latency constraints
+ * permit this. It is not recommended writing larger blocks than this
+ * because usually they will then be split up internally into chunks
+ * of this size. It is not recommended writing smaller blocks than
+ * this (unless required due to latency demands) because this
+ * increases CPU usage. If ss is NULL you will be returned the
+ * byte-exact tile size. If you pass a valid ss, then the tile size
+ * will be rounded down to multiple of the frame size. This is
+ * supposed to be used in a construct such as
+ * pa_context_get_tile_size(pa_stream_get_context(s),
+ * pa_stream_get_sample_spec(ss)); \since 0.9.20 */
+size_t pa_context_get_tile_size(pa_context *c, const pa_sample_spec *ss);
+
 PA_C_DECL_END
 
 #endif