diff --git a/src/libsysprof-profile/sysprof-recording.c b/src/libsysprof-profile/sysprof-recording.c index eb3b19c7..4971796c 100644 --- a/src/libsysprof-profile/sysprof-recording.c +++ b/src/libsysprof-profile/sysprof-recording.c @@ -690,3 +690,37 @@ sysprof_recording_get_event_count (SysprofRecording *self) + self->stat.frame_count[SYSPROF_CAPTURE_FRAME_MARK] + self->stat.frame_count[SYSPROF_CAPTURE_FRAME_LOG]; } + +/** + * sysprof_recording_create_reader: + * @self: a #SysprofRecording + * + * Creates a new reader for the recording's writer. + * + * Returns: (transfer full): a #SysprofCaptureReader + */ +SysprofCaptureReader * +sysprof_recording_create_reader (SysprofRecording *self) +{ + g_return_val_if_fail (SYSPROF_IS_RECORDING (self), NULL); + + return sysprof_capture_writer_create_reader (self->writer); +} + +/** + * sysprof_recording_dup_fd: + * @self: a #SysprofRecording + * + * Duplicates the FD that is being used for writing the recording. This can + * be useful if you want to open the recording using a + * #SysprofDocumentLoader. + * + * Returns: a FD that the caller should `close()` when no longer in use. + */ +int +sysprof_recording_dup_fd (SysprofRecording *self) +{ + g_return_val_if_fail (SYSPROF_IS_RECORDING (self), -1); + + return _sysprof_capture_writer_dup_fd (self->writer); +} diff --git a/src/libsysprof-profile/sysprof-recording.h b/src/libsysprof-profile/sysprof-recording.h index 6bf9fba0..34b930f7 100644 --- a/src/libsysprof-profile/sysprof-recording.h +++ b/src/libsysprof-profile/sysprof-recording.h @@ -32,28 +32,32 @@ SYSPROF_AVAILABLE_IN_ALL G_DECLARE_FINAL_TYPE (SysprofRecording, sysprof_recording, SYSPROF, RECORDING, GObject) SYSPROF_AVAILABLE_IN_ALL -GListModel *sysprof_recording_list_diagnostics (SysprofRecording *self); +GListModel *sysprof_recording_list_diagnostics (SysprofRecording *self); SYSPROF_AVAILABLE_IN_ALL -gint64 sysprof_recording_get_duration (SysprofRecording *self); +gint64 sysprof_recording_get_duration (SysprofRecording *self); SYSPROF_AVAILABLE_IN_ALL -gint64 sysprof_recording_get_event_count (SysprofRecording *self); +gint64 sysprof_recording_get_event_count (SysprofRecording *self); SYSPROF_AVAILABLE_IN_ALL -void sysprof_recording_wait_async (SysprofRecording *self, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); +void sysprof_recording_wait_async (SysprofRecording *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); SYSPROF_AVAILABLE_IN_ALL -gboolean sysprof_recording_wait_finish (SysprofRecording *self, - GAsyncResult *result, - GError **error); +gboolean sysprof_recording_wait_finish (SysprofRecording *self, + GAsyncResult *result, + GError **error); SYSPROF_AVAILABLE_IN_ALL -void sysprof_recording_stop_async (SysprofRecording *self, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); +SysprofCaptureReader *sysprof_recording_create_reader (SysprofRecording *self); SYSPROF_AVAILABLE_IN_ALL -gboolean sysprof_recording_stop_finish (SysprofRecording *self, - GAsyncResult *result, - GError **error); +int sysprof_recording_dup_fd (SysprofRecording *self) G_GNUC_WARN_UNUSED_RESULT; +SYSPROF_AVAILABLE_IN_ALL +void sysprof_recording_stop_async (SysprofRecording *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +SYSPROF_AVAILABLE_IN_ALL +gboolean sysprof_recording_stop_finish (SysprofRecording *self, + GAsyncResult *result, + GError **error); G_END_DECLS