synchronized( this ){
copy_outstanding = true;
async_dispatcher.dispatch(
new AERunnable()
{
public void
runSupport()
{
setPersistentBooleanProperty( PP_COPY_OUTSTANDING, true );
}
});
}
while( true ){
if ( copy_sem.reserve( 60*1000 )){
while( copy_sem.reserveIfAvailable());
}
boolean auto_start = getAutoStartDevice();
synchronized( this ){
if ( itunes == null || ( !is_running && !( auto_start && is_installed ))){
if ( !( copy_outstanding || copy_outstanding_set )){
copy_thread = null;
break;
}
continue;
}
copy_outstanding_set = false;
}
TranscodeFileImpl[] files = getFiles();
List<TranscodeFileImpl> to_copy = new ArrayList<TranscodeFileImpl>();
boolean borked_exist = false;
for ( TranscodeFileImpl file: files ){
if ( file.isComplete() && !file.isCopiedToDevice()){
if ( file.getCopyToDeviceFails() < 3 ){
to_copy.add( file );
}else{
borked_exist = true;
}
}
}
if ( borked_exist ){
setError( COPY_ERROR_KEY, MessageText.getString( "device.error.copyfail2") );
}
synchronized( this ){
if ( to_copy.size() == 0 && !copy_outstanding_set && !borked_exist ){
copy_outstanding = false;
async_dispatcher.dispatch(
new AERunnable()
{
public void
runSupport()
{
setError( COPY_ERROR_KEY, null );