*/
int ast_audiohook_volume_set(struct ast_channel *chan, enum ast_audiohook_direction direction, int volume);
+/*!
+ * \brief Adjust the volume on frames read from or written to a channel
+ * \param chan Channel to muck with
+ * \param direction Direction to set on
+ * \param volume Value to adjust the volume by
+ * \retval 0 on success
+ * \retval -1 on failure
+ */
+int ast_audiohook_volume_set_float(struct ast_channel *chan, enum ast_audiohook_direction direction, float volume);
+
/*!
* \brief Retrieve the volume adjustment value on frames read from or written to a channel
* \param chan Channel to retrieve volume adjustment from
*/
int ast_audiohook_volume_get(struct ast_channel *chan, enum ast_audiohook_direction direction);
+/*!
+ * \brief Retrieve the volume adjustment value on frames read from or written to a channel
+ * \param chan Channel to retrieve volume adjustment from
+ * \param direction Direction to retrieve
+ * \return adjustment value
+ */
+float ast_audiohook_volume_get_float(struct ast_channel *chan, enum ast_audiohook_direction direction);
+
/*!
* \brief Adjust the volume on frames read from or written to a channel
* \param chan Channel to muck with
*/
int ast_audiohook_volume_adjust(struct ast_channel *chan, enum ast_audiohook_direction direction, int volume);
+/*!
+ * \brief Adjust the volume on frames read from or written to a channel
+ * \param chan Channel to muck with
+ * \param direction Direction to increase
+ * \param volume Value to adjust the adjustment by
+ * \retval 0 on success
+ * \retval -1 on failure
+ */
+int ast_audiohook_volume_adjust_float(struct ast_channel *chan, enum ast_audiohook_direction direction, float volume);
+
/*! \brief Mute frames read from or written to a channel
* \param chan Channel to muck with
* \param source Type of audiohook
/*! \brief Audiohook volume adjustment structure */
struct audiohook_volume {
struct ast_audiohook audiohook; /*!< Audiohook attached to the channel */
- int read_adjustment; /*!< Value to adjust frames read from the channel by */
- int write_adjustment; /*!< Value to adjust frames written to the channel by */
+ float read_adjustment; /*!< Value to adjust frames read from the channel by */
+ float write_adjustment; /*!< Value to adjust frames written to the channel by */
};
/*! \brief Callback used to destroy the audiohook volume datastore
{
struct ast_datastore *datastore = NULL;
struct audiohook_volume *audiohook_volume = NULL;
- int *gain = NULL;
+ float *gain = NULL;
/* If the audiohook is shutting down don't even bother */
if (audiohook->status == AST_AUDIOHOOK_STATUS_DONE) {
/* If an adjustment value is present modify the frame */
if (gain && *gain) {
- ast_frame_adjust_volume(frame, *gain);
+ ast_frame_adjust_volume_float(frame, *gain);
}
return 0;
}
int ast_audiohook_volume_set(struct ast_channel *chan, enum ast_audiohook_direction direction, int volume)
+{
+ return ast_audiohook_volume_adjust_float(chan, direction, (float) volume);
+}
+
+int ast_audiohook_volume_set_float(struct ast_channel *chan, enum ast_audiohook_direction direction, float volume)
{
struct audiohook_volume *audiohook_volume = NULL;
}
int ast_audiohook_volume_get(struct ast_channel *chan, enum ast_audiohook_direction direction)
+{
+ return (int) ast_audiohook_volume_get_float(chan, direction);
+}
+
+float ast_audiohook_volume_get_float(struct ast_channel *chan, enum ast_audiohook_direction direction)
{
struct audiohook_volume *audiohook_volume = NULL;
- int adjustment = 0;
+ float adjustment = 0;
/* Attempt to find the audiohook volume information, but do not create it as we only want to look at the values */
if (!(audiohook_volume = audiohook_volume_get(chan, 0))) {
}
int ast_audiohook_volume_adjust(struct ast_channel *chan, enum ast_audiohook_direction direction, int volume)
+{
+ return ast_audiohook_volume_adjust_float(chan, direction, (float) volume);
+}
+
+int ast_audiohook_volume_adjust_float(struct ast_channel *chan, enum ast_audiohook_direction direction, float volume)
{
struct audiohook_volume *audiohook_volume = NULL;