Edit: there seems to be some confusion here.
Based on the description in the question, I'm assuming you have two devices that output a line-level signal, and you want to connect those to a device that only has one input available.
If this is the case: don't wire the cables together directly. This may damage your devices: the output voltage from one device ends up in the output stage of the other device, which isn't designed to handle that.
There are several ways to do this safely:
- use a switch, to connect one output at a time to the input. Simple, but requires you to turn down the output volume because a simple switch isn't guaranteed to make the switch silently.
- use a mixer.
- use a passive summing mixer. In its simplest form, this is just two resistors wired into the cable. This will result in a 6 dB signal loss.
INPUT 1 -------\/\/\/\---+
---+ R1 10K +------------ OUTPUT
| | +----
INPUT 2 -------\/\/\/\---+ |
---+ R2 10K |
| (shields) |
The other way round: splitting the output of one device to feed 2 devices, is described in danmcb's answer.