Is it useful to put AudioRecord.getState() in a loop?
<p>I'm working with some code that calls the <a href="http://developer.android.com/reference/android/media/AudioRecord.html" rel="nofollow">AudioRecord</a> constructor:</p>

<pre><code>AudioRecord listener = new AudioRecord(list of parameters);
do {} while (listener.getState() != AudioRecord.STATE_INITIALIZED);
</code></pre>

<p>This code would seem to make sense if AudioRecord goes off in another thread and takes time to initialize. I'm not sure of this is the case though, and if it isn't it would seem a lot better to have the code just check and return an exception, lest an infinite loop is started at some point when initialization does actually fail (although I could just limit the number of checks to something finite).</p>

<p>Should I leave the code as it is or replace the second line with something like the following?</p>

<pre><code>if(listener.getState() != AudioRecord.STATE_INITIALIZED) {
    throw new Exception("AudioRecord failed to initialize");
}
</code></pre>
