Following the deadly shooting in Charleston, S.C., President Obama said Americans will have to "come to grips" with the frequency with which gun violence happens in the U.S. as compared to other countries. (AP)

The killing of nine black worshipers at a church in South Carolina has compelled President Obama to look back with anger, then melancholy and finally some distance at the two most in­trac­table issues he has faced as president: guns and race.

In the White House briefing room, at a fundraiser at the home of a movie star, before a roomful of the country’s mayors and in a garage in Pasadena, Calif., Obama has reflected not only on the Charleston shootings but also on the missed opportunities and unfinished business of his presidency.

“Increasingly, I’ve spent my time thinking about how do I try to break out of these old patterns that our politics have fallen into,” Obama said in Pasadena, where he recorded a podcast interview that was released Monday. He wondered how to have a normal conversation that’s “not this battle in a steel cage between one side and another.”

The pain laid bare by Charleston has led Obama to an unusually frank assessment of his presidency and an acknowledgment that he hasn’t been the unifying, transformational figure that many hoped he would be.

President Barack Obama, with Vice President Biden, leaves after making a statement at the White House regarding the church shootings in Charleston, S.C., on June 18, the day after the massacre. (Alex Wong/Getty Images)

On Friday, he will travel to Emanuel African Methodist Episcopal Church in Charleston to deliver another eulogy, this time for a pastor who was one of the earliest supporters of the movement that in 2008 propelled Obama to the White House. That campaign’s most enthusiastic backers believed that a newly mobilized and enthusiastic citizenry could radically improve the nature of the political debate in Washington.

Just hours after the June 17 shootings in Charleston, Obama stood before the cameras in the White House briefing room and spoke mournfully of the Rev. Clementa Pinckney and the eight other parishioners killed during an evening Bible study.

Obama was thinking about the dead. But his frustration and disgust in that moment sprang just as much from the killing of 20 elementary school students in Connecticut three years earlier, his aides said.

Obama has described the Newtown massacre as the “worst day” of his presidency and Congress’s inability to pass gun control legislation as his most stinging defeat.

“Let’s be clear,” he said in the briefing room last week, his voice edged with anger. “At some point we as a country will have to reckon with the fact that this type of mass violence does not happen in other advanced countries. It doesn’t happen in other places with this kind of frequency. And it is in our power to do something about it. I say that recognizing the politics in this town foreclose a lot of those avenues right now.”

The next day, the president bristled at the suggestion that his remarks had amounted to surrender to the gun lobby. “I am not resigned,” he told a gathering of the nation’s mayors in San Francisco. Indeed, he suggested that lawmakers’ and lobbyists’ resistance on gun control had cost American lives.

Had there been tougher congressional action, he told the mayors, “some families might still be whole. You all might have to attend fewer funerals. And we should be strong enough to acknowledge this.”

By week’s end, the president’s staff had begun planning his trip to South Carolina. Obama was in Pasadena for a podcast interview with comedian Marc Maron that aired Monday. The two spoke in the recording studio in Maron’s garage, and the president, dressed in shirtsleeves and suit pants, took on a more reflective tone.“What happens now?” Maron asked about Charleston.

In the near term, Obama said, gun sales will increase and gun manufacturers will “make out like bandits, partly because this fear that’s churned up that the federal government and the black helicopters are all coming to get your guns.”

For Obama, the failure on gun control was now a symptom of the country’s larger political disease, one that he had hoped to cure but has paradoxically grown worse on his watch. “The problem is that there’s a big gap between who we are as people and how our politics expresses itself,” he said. “You get a negative feedback loop . . . then the public withdraws, and you get even worse political gridlock and polarization.”

If Obama sought to curb gun violence through direct legislative action in Washington, he has chosen a more indirect route on race. His own political ascendancy showed how the United States had changed and seemed to offer the promise of a post-racial nation.

Few anticipated that his presence in the White House would become a flashpoint for racial anxiety as well. “If you are a white man in America, this country is changing dramatically. You have always been in charge,” said a senior administration official who spoke on the condition of anonymity be candid. “So there is something to white men feeling like something has been taken away from them.”

That awareness has bred a sense of caution, one heightened during the first months of Obama’s presidency when he criticized a white police officer who confronted Harvard University professor Henry Louis Gates Jr., who is black.

Since then, Obama has spoken about race in fits and starts, gradually becoming more explicit. He compared himself to black teenager Trayvon Martin, who was killed in Florida, and after the riots in Baltimore urged Americans to search their souls on the question of race.

After the Charleston killings, he talked about the long shadow of slavery, Jim Crow and discrimination that exists “in almost every institution of our lives.”

“It’s not just a matter of it not being polite to say ‘n-----’ in public,” Obama said in the podcast interview, his first public use of the epithet as president.

The conversation showed that he has become more at ease talking about race. “I know what I’m doing, and I’m fearless,” Obama said, reflecting on the confidence that comes from six years of experience.

But he still recognizes the risk that his intervention can backfire. On the question of whether to remove the Confederate flag from the South Carolina capitol grounds, he stayed largely silent. “Good point, Mitt,” he tweeted Saturday after his 2012 GOP presidential rival called for the flag to be taken down.

Aides cited South Carolina Gov. Nikki Haley’s call for the battle flag’s removal as a sign of progress. “It just shows what can happen quickly when the American people let their voices be heard loudly and clearly,” White House senior adviser Valerie Jarrett said.

Obama’s prescriptions for racial reconciliation have focused on modest and largely noncontroversial policy initiatives. “Early childhood education works,” he said in the podcast interview. “That’s one way to break the legacy of racism and poverty.” In his remarks before the Conference of Mayors last week, Obama touted his My Brother’s Keeper initiative, which provides grants to programs aimed at young men of color.

The small advances, however, haven’t erased his larger frustrations with Washington.

“Congress doesn’t work the way it should,” Obama said at a fundraiser held last week at the home of actor and filmmaker Tyler Perry. “Issues are left untended. Folks are more interested in scoring political points than getting things done.”

The system was still broken. Even during the early and optimistic days of his presidency, Obama reminded the group, he never promised to fix Washington alone.

“I didn’t say, ‘Yes, I can,’ ” he said. “I said — what?”

In 2008, stadiums full of people screamed it. Now it fell to a small party of wealthy Democrats to sing the chorus.

“Yes, we can,” they said.