player.c

来自「MP3 Cyclone的source code 利用FPGGA實現MP3的功能」· C语言 代码 · 共 51 行

C
51
字号
/***********************************************************************
 *                                                                     *
 * File:     player.c                                                  *
 *                                                                     *
 * Purpose:  Top level file for Nios II MP3 Player application.        *
 *                                                                     *
 * Author:   N. Knight                                                 *
 *           Altera Corporation                                        *
 *           Aug 2005                                                  *
 **********************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include "player_lib.h"

int main( void )
{
  /* This structure stores all the MP3 file information */
  nios_mp3_file_struct* mp3_files;
  
  /* Get some memory for the file structure */
  mp3_files =( nios_mp3_file_struct* ) malloc( sizeof( nios_mp3_file_struct ) );
  
  /* Initialize file system */
  if( NiosIIMP3_FileInit( mp3_files ) == SUCCESS )
  {
    /* Get first file */
    NiosIIMP3_GetMP3File( mp3_files , mp3_files->file_number );
    NiosIIMP3_DisplayNowPlaying( mp3_files );
  
    while( 1 )
    {
      /* Start decoding */
      NiosIIMP3_Decode( mp3_files );
      /* If the file's finished, grab the next one and start over */
      if( NiosIIMP3_FileFinished( mp3_files ) )
      {
        NiosIIMP3_NextFile( mp3_files );
        NiosIIMP3_GetMP3File( mp3_files , mp3_files->file_number );
        NiosIIMP3_DisplayNowPlaying( mp3_files );
      }
    }

    /* Give back what we've taken */
    free( mp3_files->file_buffer );
  }
  free( mp3_files );
    
  return( 0 );
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?