Hey man!
I have the same problem as you do.
I have a aftermarket deck with ipod dock wire which works fine with my new iphone4(got it yesterday) but what i noticed is when my iphone is fully chrged (100%) it works fine. soonest the charge is lower than 70% lets say, it would reboot after 5 to 10 min plugged in.
This does not happen when car is off.
Now im an electronic engineer, and @ my work one of my duties is to test car accessories and chargers to see if there isnt any spikes that would damage the unit. so i know spikes are deadly and thats what most likely is causing the issue.
You said it doesnt happen when music is not playing.
It makes perfect sense since all the spikes increase dramatically when current draw increases. so when your iphone is idling it doesnt suck as much current so the emmisions are lower and not big enough to cause ipod to restart. soonest you listen to music your current draw increases causing the spikes to increase.
Anyways, your issue might be just too long extension cable. but you can veryfi it by chargin it to 100% and see if it does the same thing fully charged. it shouldnt. iphone automatically shuts down the current use to minimum when fully charged, hence smaller spikes = no reboot.
another way to test it + fix is to just tap into the wire and cut the +3.3V or +5V wire, not sure which one is in your cable. probably 5V since its a usb. mine plugs in at the back of my deck and it looks like a ps/2 connector (like a pc mouse one) so im guessing mine uses 5V.
This will cause your iphone to stop chargin while plugged in. but if that works you know right away that charging voltage is your issue.
There is few ways to fix inregular voltage. simplest one is just to put a filtering cap (just a normal capacitor) rated for minimum 12V to be safe and bigger capacity is better. anywhere around 2000-2700uF should do, if it doenst work try bigger.
Another way would be installing a voltage regulator for 5V. you can use a LM series regulators which will work fine.
But either way you need a cap as well.
Im goin to do it this weekend if i have time. Ill let you know how it goes but im prett sure it will fix the problem.