Difference between revisions of "Truxton media get percent complete"
Jump to navigation
Jump to search
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
This retrieves the percent complete of the processing of the media. | This retrieves the percent complete of the processing of the media. | ||
| − | This corresponds to the <code>[PercentComplete]</code> column of the <code>[Media]</code> table. | + | This corresponds to the <code>[PercentComplete]</code> column of the <code><nowiki>[</nowiki>[[Media Table|Media]]<nowiki>]</nowiki></code> table. |
=Syntax= | =Syntax= | ||
| − | < | + | <source lang="C"> |
uint64_t truxton_media_get_percent_complete( uint64_t media_handle ); | uint64_t truxton_media_get_percent_complete( uint64_t media_handle ); | ||
| − | </ | + | </source> |
=Parameters= | =Parameters= | ||
| Line 15: | Line 15: | ||
=Sample= | =Sample= | ||
| − | < | + | <source lang="C" highlight="3"> |
| − | void is_complete(uint64_t media) | + | void is_complete( uint64_t media ) |
{ | { | ||
uint64_t percent_complete = truxton_media_get_percent_complete( media ); | uint64_t percent_complete = truxton_media_get_percent_complete( media ); | ||
| Line 28: | Line 28: | ||
printf( "The media is %" PRIu64 " percent complete\n", percent_complete ); | printf( "The media is %" PRIu64 " percent complete\n", percent_complete ); | ||
} | } | ||
| − | }</ | + | }</source> |
| + | |||
| + | The <code>PRIu64</code> in the sample code above is a standard way of [https://en.wikipedia.org/wiki/C_data_types#Printf_and_scanf_format_specifiers formatting] a 64-bit unsigned integer in C. | ||
| + | Over the years, different compilers on different operating systems used different format specifiers for things, these <code>PRI</code> macros, along with some tricky string concatenation the compilers perform for you, allow you to maintain a single code base without a bunch of macro magic. | ||
Latest revision as of 07:43, 3 February 2024
This retrieves the percent complete of the processing of the media.
This corresponds to the [PercentComplete] column of the [Media] table.
Syntax
uint64_t truxton_media_get_percent_complete( uint64_t media_handle );
Parameters
media_handle
The handle created by the truxton_media_open_id or truxton_media_create call.
Return value
The percentage of completeness of the processing of the data in the media.
Sample
void is_complete( uint64_t media )
{
uint64_t percent_complete = truxton_media_get_percent_complete( media );
if ( percent_complete > 99 )
{
printf( "The media has done\n" );
}
else
{
printf( "The media is %" PRIu64 " percent complete\n", percent_complete );
}
}
The PRIu64 in the sample code above is a standard way of formatting a 64-bit unsigned integer in C.
Over the years, different compilers on different operating systems used different format specifiers for things, these PRI macros, along with some tricky string concatenation the compilers perform for you, allow you to maintain a single code base without a bunch of macro magic.