Fix a potential race condition in chromecast init. #1178.