seeking_test_c.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <html>
  2. <head>
  3. <title>vorbisfile - seeking_test.c</title>
  4. <link rel=stylesheet href="style.css" type="text/css">
  5. </head>
  6. <body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">
  7. <table border=0 width=100%>
  8. <tr>
  9. <td><p class=tiny>Vorbisfile documentation</p></td>
  10. <td align=right><p class=tiny>vorbisfile version 1.2.0 - 20070723</p></td>
  11. </tr>
  12. </table>
  13. <h1>seeking_test.c</h1>
  14. <p>
  15. The example program source:
  16. <br><br>
  17. <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
  18. <tr bgcolor=#cccccc>
  19. <td>
  20. <pre><b>
  21. #include <stdlib.h>
  22. #include <stdio.h>
  23. #include "vorbis/codec.h"
  24. #include "vorbis/vorbisfile.h"
  25. int main(){
  26. OggVorbis_File ov;
  27. int i;
  28. #ifdef _WIN32 /* We need to set stdin to binary mode under Windows */
  29. _setmode( _fileno( stdin ), _O_BINARY );
  30. #endif
  31. /* open the file/pipe on stdin */
  32. if(ov_open_callbacks(stdin,&ov,NULL,-1,OV_CALLBACKS_NOCLOSE)==-1){
  33. printf("Could not open input as an OggVorbis file.\n\n");
  34. exit(1);
  35. }
  36. /* print details about each logical bitstream in the input */
  37. if(ov_seekable(&ov)){
  38. double length=ov_time_total(&ov,-1);
  39. printf("testing seeking to random places in %g seconds....\n",length);
  40. for(i=0;i<100;i++){
  41. double val=(double)rand()/RAND_MAX*length;
  42. ov_time_seek(&ov,val);
  43. printf("\r\t%d [%gs]... ",i,val);
  44. fflush(stdout);
  45. }
  46. printf("\r \nOK.\n\n");
  47. }else{
  48. printf("Standard input was not seekable.\n");
  49. }
  50. ov_clear(&ov);
  51. return 0;
  52. }
  53. </b></pre>
  54. </td>
  55. </tr>
  56. </table>
  57. <br><br>
  58. <hr noshade>
  59. <table border=0 width=100%>
  60. <tr valign=top>
  61. <td><p class=tiny>copyright &copy; 2007 Xiph.org</p></td>
  62. <td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/index.html">Ogg Vorbis</a><br><a href="mailto:team@vorbis.org">team@vorbis.org</a></p></td>
  63. </tr><tr>
  64. <td><p class=tiny>Vorbisfile documentation</p></td>
  65. <td align=right><p class=tiny>vorbisfile version 1.2.0 - 20070723</p></td>
  66. </tr>
  67. </table>
  68. </body>
  69. </html>