Audio Jack Repair and Plug Sense

A common issue, especially with unibody MacBooks and MacBook Pros (2008-2012 era) is that the system will stop giving sound output through their main speakers and/or through the headphone jack. 
This is most often due to having something stuck in the audio jack (e.g. a broken off headphone plug tip) OR due to AUD_CONNJ1_TIPDET losing default electrically disconnecting from AUD_CONNJ1_TIP when nothing is inserted into the jack.
NOTE: In later models (like the MacBook Pro 2015 13in 820-4924 board, for example) AUD_CONNJ1_TIP has been renamed to AUD_CONN_HP_LEFT and AUD_CONNJ1_TIPDET has been renamed to AUD_CONN_TIPDET2. In TRS connectors (see graphic below) the tip is the left channel, and HP presumably is short for "headphone". Despite the different naming scheme, all of the principles described below apply in a one-to-one manner.
===Common Symptoms:===
*Still hear the Apple chime on boot (if it's not turned down in system preferences, and you can reset it to standard volume with a NVRAM reset for testing purposes);
*Not hear any sound from within MacOS itself;
*See "Digital Out" / "Optical digital-out port" as the name / type of the only output device listed in the System Preferences -> Sound -> Output tab (unless you have a second audio interface connected to the system); and
*See a dim red illumination coming out of the headphone jack itself when the system is powered on and booted into MacOS.
===Background:===
Headphone jacks for most unibody and all modern Macs support several types of connectivity across different variations of the 3.5mm (1/8in) standard. These include:
*The standard TRS (tip, ring, sleeve) analog headphone / line-out output where the audio signal for the left channel is passed to the output device using the tip of the jack, the right channel is passed to the output device using the ring of the jack, and both channels share a common ground in the sleeve around the base;
*The increasingly common TRRS (tip, ring, ring, sleeve) analog in/out configuration where the tip is the left channel, the ring adjacent to the tip is the right channel, the ring adjacent to the sleeve is the common ground, and the sleeve is the integrated mic input; and
*The mini-TOSLINK digital optical plug type which uses a single fiberoptic channel to transmit digital audio using the S/PDIF protocol and which is built with a nonconductive plastic sleeve.
MacBooks use a tip-detect pin and a sleeve-detect pin to determine which of these three types of plug is inserted into its headphone jack, or if no plug is inserted at all. 
The behavior described above is due to the jack passing erroneous tip and/or sleeve detection to the onboard audio codec chip.
===Functional Mechanisms:===
As indicated by the schematic, the audio jack is physically built so that AUD_CONNJ1_TIPDET normally has a physical electrical connection to AUD_CONNJ1_TIP. When a plug is inserted into the jack, the metal-to-metal conductive connection within the jack is physically opened by the plug's physical presence mechanically lifting the top arm up from the base with which it is normally in contact. This tells the MacBook's audio codec chip that there is something in the jack physically. 
Furthermore, the jack is built so that AUD_CONNJ1_SLEEVEDET will not have any continuity to AUD_CONNJ1_SLEEVE unless a conductive plug (TRS/TRRS) is inserted into the jack. When a TRS or TRRS plug is inserted into the jack, AUD_CONNJ1_SLEEVEDET is shorted to AUD_CONNJ1_SLEEVE, indicating to the audio codec chip that the plug in the jack is an analog audio plug. 
The configurations for the audio jack, then, are as follows:
HEADPHONE JACK SENSE CONFIGURATIONS
 	TIP-TIPDET Closed 	TIP-TIPDET Open
SLEEVE-SLEEVEDET Open 	Sense: Nothing is inserted into the 3.5mm jack
Output: Internal speakers ENGAGED	Sense: Mini-TOSLINK is inserted into the jack
Output: Digital optical out only
SLEEVE-SLEEVEDET Closed	Where did you get that banana?	Sense: TRS/TRS analog plug inserted
Output: Analog audio out for headphones / line-out
NOTE: The default configuration of the jack with nothing inserted is for TIP-TIPDET to be CLOSED and SLEEVE-SLEEVEDET to be OPEN.
*** Mic detection is not detailed here. See the "AUDIO: JACK TRANSLATORS" page of the schematic for more information. ***	NOTE: The default configuration of the jack with nothing inserted is for TIP-TIPDET to be CLOSED and SLEEVE-SLEEVEDET to be OPEN.
*** Mic detection is not detailed here. See the "AUDIO: JACK TRANSLATORS" page of the schematic for more information. ***	NOTE: The default configuration of the jack with nothing inserted is for TIP-TIPDET to be CLOSED and SLEEVE-SLEEVEDET to be OPEN.
*** Mic detection is not detailed here. See the "AUDIO: JACK TRANSLATORS" page of the schematic for more information. ***
===Dysfunctional Mechanisms:===
Assuming that there is nothing jammed in the jack that would cause the physical connection between AUD_CONNJ1_TIPDET and AUD_CONNJ1_TIP in the jack mechanics to open, then either:
*The two metal pieces inside the jack have oxidized or accumulated debris at their point of contact, and as a result the connection now has too much resistance on the line to provide a reliable continuity and so the audio codec chip has decided that there is something in the jack when there is, in fact, nothing inserted; or
*The top metal piece has developed fatigue and no longer makes physical contact with the plate to which it would normally make contact.
===Preoperative Diagnostic Testing:===
Before performing any invasive surgeries on your MacBook, be sure that faulty tip detection is your problem! A functional tip detection mechanism should give ~0 ohms resistance between the headphone jack's AUD_CONNJ1_TIP (pin 1) and AUD_CONNJ1_TIPDET (pin 2) when nothing is inserted, and when there IS a plug inserted, it should give an OL when measuring the resistance between those same pins. 
If the functional behavior is not as expected but the jack's electrical measurements ARE as expected, then you may need to trace the signal path deeper into the board, ensuring no filter caps are shorted to ground, that the filtering inductors on the line are not failed open, and that proper supply voltages are being passed to the logic gates that handle the detections and pass the AUD_SENSE signals on to the audio codec chip.
===Reference Photos (A1278):===
File:Mac Headphone Jack Revealed (3).jpg|alt=The TIP-TIPDET connection point is circled here. Note that when a plug is inserted the top piece of metal is lifted off of the base connection slightly, thereby opening the default-closed TIP-TIPDET connection.|The TIP-TIPDET connection point is circled here. Note that when a plug is inserted the top piece of metal is lifted off of the base connection slightly, thereby opening the default-closed TIP-TIPDET connection.
File:Mac Headphone Jack Revealed (2).jpg|alt=Headphone jack with a plug inserted and the TIP-TIPDET interface OPEN|Headphone jack with a plug inserted and the TIP-TIPDET interface OPEN
File:Mac Headphone Jack Revealed (1).jpg|alt=Headphone jack with no plug inserted and the TIP-TIPDET interface CLOSED|Headphone jack with no plug inserted and the TIP-TIPDET interface CLOSED
===Solutions:===
*Easy but unlikely to be a persistent fix: If the connection point is simply oxidized you may be able to resolve the issue by disconnecting the system battery, spraying DeoxIT D5 in the headphone jack, and then inserting and removing the 3.5mm plug repeatedly to break up the oxidation between the two contact points.
*Involved but likely permanent fix: Expose the internal mechanisms of the headphone jack by removing the logic board from the system, exposing the jack's internal TIP-TIPDET connection point, and then cleaning / bending / modifying the exposed metal contacts so that they make reliable electrical contact (~0 ohms resistance between pins 1 and 2) when nothing is inserted and also separate reliably when a plug is inserted to the jack (OL between pins 1 and 2).
**Usually DeoxIT and a slight bending will work for me (Crumblenaut), but in the past I've also had to file the contact a bit and then tin one or both sides with solder to get it just right
*You can expose the internal mechanisms several ways, including by:
**Desoldering, removing, and disassembling the jack to remove the shielding; or
**Using flush cutters to snip the shielding connection points on the exposed side and the rear of the jack, leaving the unexposed side connected, and then by bending the metal shielding back; or
**Using a Dremel drill and a fine cutting blade to VERY CAREFULLY cut through the exposed side and rear of the jack, leaving the unexposed side connected, and then bending the metal shielding back
*ORRRRRRR... YOU COULD JUST REPLACE THE JACK. ¯\_(ツ)_/¯
GOOD LUCK, FRIENDS! :::D