void run(threaded_process_status & p_status,abort_callback & p_abort) { try { const t_uint32 decode_flags = input_flag_no_seeking | input_flag_no_looping; // tell the decoders that we won't seek and that we don't want looping on formats that support looping. input_helper input; audio_hash.set_count(m_items.get_size()); for(t_size walk = 0; walk < m_items.get_size(); ++walk) { p_abort.check(); // in case the input we're working with fails at doing this p_status.set_progress(walk, m_items.get_size()); p_status.set_progress_secondary(0); p_status.set_item_path( m_items[walk]->get_path() ); input.open(NULL, m_items[walk], decode_flags, p_abort); double length; { // fetch the track length for proper dual progress display; file_info_impl info; // input.open should have preloaded relevant info, no need to query the input itself again. // Regular get_info() may not retrieve freshly loaded info yet at this point (it will start giving the new info when relevant info change callbacks are dispatched); we need to use get_info_async. if (m_items[walk]->get_info_async(info)) length = info.get_length(); else length = 0; } memset( &ctx, 0, sizeof( sha1_context ) ); sha1_starts( &ctx ); audio_chunk_impl_temporary l_chunk; double decoded = 0; while(input.run(l_chunk, p_abort)) { // main decode loop sha1_update(&ctx,(unsigned char*)l_chunk.get_data(),l_chunk.get_data_length()); //m_peak = l_chunk.get_peak(m_peak); if (length > 0) { // don't bother for unknown length tracks decoded += l_chunk.get_duration(); if (decoded > length) decoded = length; p_status.set_progress_secondary_float(decoded / length); } p_abort.check(); // in case the input we're working with fails at doing this } unsigned char sha1sum[20] ={0}; sha1_finish(&ctx,sha1sum); pfc::string_formatter msg; for(int i = 0; i < 20; i++ ) { msg <<pfc::format_hex(sha1sum[i]); audio_hash[walk] =msg; } } } catch(std::exception const & e) { m_failMsg = e.what(); } }