Registering callback functions
Using libmp3splt
Collaboration diagram for Registering callback functions:

## Typedefs

typedef struct splt_progres | splt_progress

## Enumerations

enum | splt_message_type { SPLT_MESSAGE_INFO, SPLT_MESSAGE_DEBUG }
enum | splt_progress_messages { SPLT_PROGRESS_PREPARE, SPLT_PROGRESS_CREATE, SPLT_PROGRESS_SEARCH_SYNC, SPLT_PROGRESS_SCAN_SILENCE }

## Functions

int | mp3splt_progress_get_current_split (const splt_progress *p_bar)
char * | mp3splt_progress_get_filename_shorted (const splt_progress *p_bar)
int | mp3splt_progress_get_max_splits (const splt_progress *p_bar)
float | mp3splt_progress_get_percent_progress (const splt_progress *p_bar)
float | mp3splt_progress_get_silence_db_level (const splt_progress *p_bar)
int | mp3splt_progress_get_silence_found_tracks (const splt_progress *p_bar)
int | mp3splt_progress_get_type (const splt_progress *p_bar)
splt_code | mp3splt_set_message_function (splt_state *state, void(*message_cb)(const char *message, splt_message_type type, void *cb_data), void *cb_data)
splt_code | mp3splt_set_pretend_to_split_write_function (splt_state *state, void(*write_cb)(const void *ptr, size_t size, size_t nmemb, void *cb_data), void *cb_data)
splt_code | mp3splt_set_progress_function (splt_state *state, void(*progress_cb)(splt_progress *p_bar, void *cb_data), void *cb_data)
splt_code | mp3splt_set_silence_level_function (splt_state *state, void(*get_silence_cb)(long time, float level, void *user_data), void *user_data)
splt_code | mp3splt_set_split_filename_function (splt_state *state, void(*file_cb)(const char *filename, void *cb_data), void *cb_data)

## Detailed Description

## Typedef Documentation

typedef struct splt_progres splt_progress

Structure containing all information needed to display a progress bar.

All members are private.

It is passed as parameter to the callback function registered with mp3splt_set_progress_function.

See Also
  mp3splt_progress_get_type
  mp3splt_progress_get_filename_shorted
  mp3splt_progress_get_current_split
  mp3splt_progress_get_max_splits
  mp3splt_progress_get_silence_found_tracks
  mp3splt_progress_get_silence_db_level
  mp3splt_progress_get_percent_progress

Definition at line 1169 of file mp3splt.h.

## Enumeration Type Documentation

enum splt_message_type

Type of the message sent to the client.

See Also
  mp3splt_set_message_function

Enumerator
SPLT_MESSAGE_INFO | Info message.
SPLT_MESSAGE_DEBUG | Debug message.

Definition at line 1059 of file mp3splt.h.

enum splt_progress_messages

Type of messages sent to the client using the callback registered with mp3splt_set_progress_function.

Enumerator
SPLT_PROGRESS_PREPARE | Preparing to split a song.
SPLT_PROGRESS_CREATE | Creating the output file.
SPLT_PROGRESS_SEARCH_SYNC | Searching for synchronisation errors - when using SPLT_OPTION_ERROR_MODE.
SPLT_PROGRESS_SCAN_SILENCE | Scanning for silence - when using SPLT_OPTION_SILENCE_MODE, SPLT_OPT_AUTO_ADJUST, mp3splt_set_silence_points or mp3splt_set_trim_silence_points.

Definition at line 1134 of file mp3splt.h.

## Function Documentation

int mp3splt_progress_get_current_split | ( | const splt_progress * | p_bar | ) |

Returns
  The current split number.

char* mp3splt_progress_get_filename_shorted | ( | const splt_progress * | p_bar | ) |

Returns
  The filename being processed. Result must be freed.

int mp3splt_progress_get_max_splits | ( | const splt_progress * | p_bar | ) |

Returns
  The total number of files to be created.

float mp3splt_progress_get_percent_progress | ( | const splt_progress * | p_bar | ) |

Returns
  The progress percentage between 0 and 1.

float mp3splt_progress_get_silence_db_level | ( | const splt_progress * | p_bar | ) |

Returns
  The audio threshold level.

int mp3splt_progress_get_silence_found_tracks | ( | const splt_progress * | p_bar | ) |

Returns
  The number of silence spots found.

int mp3splt_progress_get_type | ( | const splt_progress * | p_bar | ) |

Returns
  The type of splt_progress_messages.

splt_code mp3splt_set_message_function | ( | splt_state * | state,
|  | void(*)(const char *message, splt_message_type type, void *cb_data) | message_cb,
|  | void * | cb_data
| ) |  |

Register callback function used to send text messages to the client.

Parameters

  [in] | state | Main state.
  [in] | message_cb | Callback function to be called.
  [in] | cb_data | User data sent through `message_cb`.

Returns
  Possible error.

Parameters of the callback `message_cb` function:

`message` Text message received.
`type` Type of the text message received.
`cb_data` The user data passed to the mp3splt_set_message_function.

See Also
  splt_message_type

splt_code mp3splt_set_pretend_to_split_write_function | ( | splt_state * | state,
|  | void(*)(const void *ptr, size_t size, size_t nmemb, void *cb_data) | write_cb,
|  | void * | cb_data
| ) |  |

Register callback function that is called when SPLT_OPT_PRETEND_TO_SPLIT is SPLT_TRUE.

This callback function allows getting the bytes that would have been written. Please note that currently the mp3 Xing header is skipped when setting the input not seekable with SPLT_OPT_INPUT_NOT_SEEKABLE.

Parameters

  [in] | state | Main state.
  [in] | write_cb | Callback function to be called.
  [in] | cb_data | User data sent through `write_cb`.

Returns
  Possible error.

Parameters of the callback `write_cb` function:

`ptr` Bytes that would have been written to the output file.
`size` Size of one element stored in `ptr`.
`nmemb` Number of elements to be written from `ptr`.
`cb_data` The user data passed to the mp3splt_set_pretend_to_split_write_function.

splt_code mp3splt_set_progress_function | ( | splt_state * | state,
|  | void(*)(splt_progress *p_bar, void *cb_data) | progress_cb,
|  | void * | cb_data
| ) |  |

Register callback function called to keep track of the current progress.

Parameters

  [in] | state | Main state.
  [in] | progress_cb | Callback function to be called.
  [in] | cb_data | User data sent through `progress_cb`.

Returns
  Possible error.

Parameters of the callback `progress_cb` function:

`p_bar` Progress bar informations.
`cb_data` The user data passed to the mp3splt_set_progress_function.

splt_code mp3splt_set_silence_level_function | ( | splt_state * | state,
|  | void(*)(long time, float level, void *user_data) | get_silence_cb,
|  | void * | user_data
| ) |  |

Register callback function that is called when looking for silence detection.

Parameters

  [in] | state | Main state.
  [in] | get_silence_cb | Callback function to be called.
  [in] | user_data | User data sent through `get_silence_cb`.

Returns
  Possible error.

Parameters of the callback `get_silence_cb` function:

`time` Current time in hundreths of seconds.
`level` Current silence level.
`user_data` The user data passed to the mp3splt_set_silence_level_function.

splt_code mp3splt_set_split_filename_function | ( | splt_state * | state,
|  | void(*)(const char *filename, void *cb_data) | file_cb,
|  | void * | cb_data
| ) |  |

Register callback function that is called when an output file is created.

Parameters

  [in] | state | Main state.
  [in] | file_cb | Callback function to be called.
  [in] | cb_data | User data sent through `file_cb`.

Returns
  Possible error.

Parameters of the callback `file_cb` function:

`filename` Output filename that has been created.
`cb_data` The user data passed to the mp3splt_set_split_filename_function.