The idea that you have to tackle an armed person has always been in my head. As I've mentioned a lot, I don't carry a firearm, so shooting back isn't an option in any case. So, within a range of 10 feet I am fairly confident, I train that way. I don't doubt my death would be at that moment, but at such a range you don't have time to wait for them to stop shooting. At a mid range from 15 to 25 feet there's still more of a chance for being shot and less of a chance you will be able to wait until they stop firing. Any distance after that you are less likely to be shot and have a better chance of waiting for a reload.
This is simply my observation, don't take my word on it. As a variable, you could have between 15 and 50 other people in the room. The more there are, the better and worse it may be. Swarms of fish confuse predators and make it more difficult to focus on one. However, more people could mean more casualties. When to act may be decided on time and distance, but it will always be more influenced by who else/how many people is/are in the room.
That being said, I would go for the weapon shoulder as any natural reaction is a predictable retreat back and this helps the tackle. After that, the shoulder controls the arm. Being sure to have the arm locked out to the best of your abilities is a plus, as you may get shot still, however controlling the arm on the ground is where you can have control of the gun. As for a rifle you have the same idea. They have the ability to hold on with both hands however, so effort must be made on the firing hand not the support hand. If you have a knife use it. I prefer to make a thrust during the tackle, that way some damage is done if I don't accomplish to disarm them. Distractions as were mentioned are a plus, but more so if you aren't doing it.
Those are my observations and opinions. I am definitely NOT going to do nothing. I haven't lived long enough.
"Today is victory over yourself of yesterday; tomorrow is your victory over lesser men." - Miyamoto Musashi
[Insert random irrelevant religious quote here]