I always used to prefer a broker, and still do in most cases. The reason is a good mortgage broker can take a buyer's individual circumstances into account when deciding which lender to send it to.
The only problem is that a number of the big banks decided a year or so ago to stop cooperating with mortgage brokers, so the only way to get a quote from, say Bank of America, is to work with an in-house mortgage officer.
That means that to compare the whole market (like a broker used to be able to do), they now have to go to B of A, and every other big bank directly. By the time they get to bank #6, the terms have changed at bank #1 anyway.
It is not a consumer-friendly system today