capture: use uint for requested counter id

Also document this thing so it is more obvious what is going on with the
resulting counter ranges.
This commit is contained in:
Christian Hergert
2018-05-17 12:19:54 +01:00
parent 2282e90165
commit 3d14ce4eaa
2 changed files with 18 additions and 2 deletions

View File

@ -1150,7 +1150,20 @@ sp_capture_writer_set_counters (SpCaptureWriter *self,
return TRUE;
}
gint
/**
* sp_capture_writer_request_counter:
*
* This requests a series of counter identifiers for the capture.
*
* The returning number is always greater than zero. The resulting counter
* values are monotonic starting from the resulting value.
*
* For example, if you are returned 5, and requested 3 counters, the counter
* ids you should use are 5, 6, and 7.
*
* Returns: The next series of counter values or zero on failure.
*/
guint
sp_capture_writer_request_counter (SpCaptureWriter *self,
guint n_counters)
{
@ -1158,6 +1171,9 @@ sp_capture_writer_request_counter (SpCaptureWriter *self,
g_assert (self != NULL);
if (G_MAXUINT - n_counters < self->next_counter_id)
return 0;
ret = self->next_counter_id;
self->next_counter_id += n_counters;

View File

@ -106,7 +106,7 @@ gboolean sp_capture_writer_flush (SpCaptureWriter *
gboolean sp_capture_writer_save_as (SpCaptureWriter *self,
const gchar *filename,
GError **error);
gint sp_capture_writer_request_counter (SpCaptureWriter *self,
guint sp_capture_writer_request_counter (SpCaptureWriter *self,
guint n_counters);
SpCaptureReader *sp_capture_writer_create_reader (SpCaptureWriter *self,
GError **error);