[Home]

Reporter:Clod Patry (junky)Labels:
Date Opened:2009-03-30 14:18:22Date Closed:2011-06-07 14:03:25
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Functions/func_volume
Versions:Frequency of
Occurrence
Related
Issues:
Description:Currently, with VOLUME() with can only set values with that function.

In some cases, it could be useful to read the existing value.

****** ADDITIONAL INFORMATION ******

Here's the tests i've made:
exten => 141,1,Set(VOLUME(rx)=4);
exten => 141,n,NooP(volume rx is \${VOLUME(rx)});
exten => 141,n,Set(VOLUME(tx)=-3);
exten => 141,n,NooP(volume rx is \${VOLUME(rx)});
exten => 141,n,NooP(volume tx is \${VOLUME(tx)});
exten => 141,n,Set(VOLUME(tx)=\$[\${VOLUME(tx)} + 4]);
exten => 141,n,NooP(volume tx is \${VOLUME(tx)});suppose to get 1 (-3+4)
exten => 141,n,NoOp(volume invalid is \${VOLUME(junky)});

and here's the result:
shooter*CLI> console dial 141@default
== Console is full duplex
-- Executing [141@default:1] Set("Console/dsp", "VOLUME(rx)=4") in new stack
-- Executing [141@default:2] NoOp("Console/dsp", "volume rx is 4") in new stack
-- Executing [141@default:3] Set("Console/dsp", "VOLUME(tx)=-3") in new stack
-- Executing [141@default:4] NoOp("Console/dsp", "volume rx is 4") in new stack
-- Executing [141@default:5] NoOp("Console/dsp", "volume tx is -3") in new stack
-- Executing [141@default:6] Set("Console/dsp", "VOLUME(tx)=1") in new stack
-- Executing [141@default:7] NoOp("Console/dsp", "volume tx is 1") in new stack
-- Executing [141@default:8] NoOp("Console/dsp", "volume invalid is INVALID") in new stack
Comments:By: Clod Patry (junky) 2009-03-30 14:30:00

That new version doesnt init datastore, as pointed per eliel on IRC.

By: Mark Michelson (mmichelson) 2009-03-30 14:38:32

Good idea, JunK-Y. There are some issues with your patch though.

1. This will not compile in dev mode because you have mixed declarations with the rest of the code. If you move the *buf = '\0'; line to after the declarations, this warning will go away.

2. Always make sure to lock the channel when performing datastore operations.

3. The portion of code which handles if the datastore cannot be found is incomplete. You create the datastore and the volume_information struct; however, you never attach the datastore to the channel, nor do you set the datastore's data field to point to the newly created volume_information struct.

4. The last item is a minor coding guidelines violation. For one-line if statements, you should use curly braces.

By: Mark Michelson (mmichelson) 2009-03-30 14:52:23

Ah, I notice that a lot of the volume_read function was copied from volume_write. volume_write has several of the same problems that I mentioned in ~102421.

By: Eliel Sardanons (eliel) 2009-04-01 14:38:59

You have removed the code that initialize the audiohook, that is correct, but you also need to avoid creating a datastore on that channel if you are reading the value. Just reply with a ast_copy_string(buf, "0", len);

If you allocate a datastore, then the next call to valume_write won't create the audiohook.