mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 19:16:15 +00:00
func_volume: Accept decimal number as argument
Allow voice volume to be multiplied or divided by a floating point number. ASTERISK-28813 Change-Id: I5b42b890ec4e1f6b0b3400cb44ff16522b021c8c
This commit is contained in:
committed by
Friendly Automation
parent
7a00db673a
commit
ef4255f6ed
@@ -70,8 +70,8 @@
|
||||
|
||||
struct volume_information {
|
||||
struct ast_audiohook audiohook;
|
||||
int tx_gain;
|
||||
int rx_gain;
|
||||
float tx_gain;
|
||||
float rx_gain;
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
@@ -107,7 +107,7 @@ static int volume_callback(struct ast_audiohook *audiohook, struct ast_channel *
|
||||
{
|
||||
struct ast_datastore *datastore = NULL;
|
||||
struct volume_information *vi = NULL;
|
||||
int *gain = NULL;
|
||||
float *gain = NULL;
|
||||
|
||||
/* If the audiohook is stopping it means the channel is shutting down.... but we let the datastore destroy take care of it */
|
||||
if (audiohook->status == AST_AUDIOHOOK_STATUS_DONE)
|
||||
@@ -141,7 +141,7 @@ static int volume_callback(struct ast_audiohook *audiohook, struct ast_channel *
|
||||
if (!(gain = (direction == AST_AUDIOHOOK_DIRECTION_READ) ? &vi->rx_gain : &vi->tx_gain) || !*gain)
|
||||
return 0;
|
||||
/* Apply gain to frame... easy as pi */
|
||||
ast_frame_adjust_volume(frame, *gain);
|
||||
ast_frame_adjust_volume_float(frame, *gain);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -193,9 +193,9 @@ static int volume_write(struct ast_channel *chan, const char *cmd, char *data, c
|
||||
}
|
||||
|
||||
if (!strcasecmp(args.direction, "tx")) {
|
||||
vi->tx_gain = atoi(value);
|
||||
vi->tx_gain = atof(value);
|
||||
} else if (!strcasecmp(args.direction, "rx")) {
|
||||
vi->rx_gain = atoi(value);
|
||||
vi->rx_gain = atof(value);
|
||||
} else {
|
||||
ast_log(LOG_ERROR, "Direction must be either RX or TX\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user