Some states have what are called "notice and demand" statutes which require the prosecution to give notice that they intend to rely on an affidavit, and give the accused a certain amount of time to demand the prosecution produce the witness at trial.  The Supreme Court spoke favorably about those statutes because they simply limit the window within which an accused must demand witnesses be brought to court.