SDL-1.2.13 SDL_mixer-1.2.8 测试程序
来源:互联网 发布:淘宝上的手办是真假 编辑:程序博客网 时间:2024/06/17 05:38
工程结构:
/SDLTestWav
---- /build
---- /music
---- m2.wav
/SDLTestWav
---- /build
---- /music
---- m2.wav
---- CMakeLists.txt
---- SdlPlayTest.c
SdlPlayTest.c 清单:
/* Sound_Init(); Sound_Play("123.wav");*/#include <stdlib.h>#include <stdio.h>#include <string.h>#include <signal.h>#ifdef unix#include <unistd.h>#endif#include "SDL.h"#include "SDL_mixer.h"static int audio_open = 0;static Mix_Music *music = NULL;static int next_track = 0;static int initresult = -1;void CleanUp(int exitcode){if( Mix_PlayingMusic() ) {Mix_FadeOutMusic(1500);SDL_Delay(1500);}if ( music ) {Mix_FreeMusic(music);music = NULL;}if ( audio_open ) {Mix_CloseAudio();audio_open = 0;}SDL_Quit();exit(exitcode);}void IntHandler(int sig){switch (sig) { case SIGINT:next_track++;break;}}int Sound_Init(){ const int TMP_FREQ = MIX_DEFAULT_FREQUENCY; const Uint16 TMP_FORMAT = MIX_DEFAULT_FORMAT; const int TMP_CHAN = 1; const int TMP_CHUNK_SIZE = 4096; return Mix_OpenAudio(TMP_FREQ,TMP_FORMAT,TMP_CHAN,TMP_CHUNK_SIZE);}int Sound_Play(const char *file_name){ printf("Enter %s filename = %s\n",__func__, file_name); if((music = Mix_LoadMUS(file_name)) == NULL) { printf("call Mix_LoadMUS failed:%s\n",Mix_GetError()); return -1; } if(Mix_PlayMusic(music,-1) == -1) { printf("call Mix_PlayMusic failed\n"); return -1; }next_track = 0;/* Play and then exit */printf("Playing %s\n", file_name);Mix_FadeInMusic(music,0,2000);
while ( !next_track && (Mix_PlayingMusic() || Mix_PausedMusic()) ) {SDL_Delay(100);}Mix_FreeMusic(music);music = NULL;
/* If the user presses Ctrl-C more than once, exit. */SDL_Delay(500);CleanUp(0);<span style="white-space:pre"></span>printf("after call Mix_PlayMusic\n"); return 0;}int main(int argc, char *argv[]){/* Initialize the SDL library */if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) {printf("Couldn't initialize SDL: %s\n",SDL_GetError());return(255);}signal(SIGINT, IntHandler);signal(SIGTERM, CleanUp);initresult = Sound_Init();printf("call Sound_Init initresult = %d\n",initresult);audio_open = 1;Sound_Play("./music/m2.wav");return 0;}
cmake_minimum_required(VERSION 2.6)# Set the project name.project(sdlplaytest)# Search for C header files in these directories.include_directories(/usr/local/include/SDL)link_directories(/usr/local/lib)set(APP_SRC ./SdlPlayTest.c)ADD_EXECUTABLE(sdlplaytest ${APP_SRC})TARGET_LINK_LIBRARIES( sdlplaytest SDL SDL_mixer)### CMakeLists.txt ends here
0 0
- SDL-1.2.13 SDL_mixer-1.2.8 测试程序
- 基于SDL的SDL_mixer音乐播放器
- 基于SDL的SDL_mixer库的音乐播放器
- android SDL系列讲解(十三) 播放音乐库 SDL_mixer教程
- (SDL)(02) Differences Between SDL 1.2 And SDL 2.0
- SDL-1.2.13 arm-linux-gcc配置
- 基于SDL-1.2.13的ARM环境下的编译
- 测试SDL配置是否正确
- 安装SDL_mixer with smpeg
- wince 6.0 移植sdl 1.2.14
- ubuntu12.10上调试SDL-1.2
- SDL 1.2版本显示YUYV422数据
- SDL 1.2 到 2.0 的函数变化
- ubuntu12.10上调试SDL-1.2
- sdl 1.2 到2.0 迁移指南
- SDL的C++程序框架
- SDL的FreeBASIC程序框架
- SDL自学教程-SDL的安装与测试
- JAVA调用 TSC 打印机 打印中文问题/JNA中文乱码
- 运算符“/”和“%”的学习记录
- GetComponentsInChildren Not Work In OnDisable[Unity]
- 二叉树的下一个结点
- poj1005
- SDL-1.2.13 SDL_mixer-1.2.8 测试程序
- lazy懒加载(延迟加载)UITableView
- K均值聚类——如何提高聚类的性能
- js 数组对象根据某一属性排序
- 非递归的归并排序
- [mysql]ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.
- MySQL体系结构
- 【微软100题】逆置链表
- MAC Intellij IDEA 常用快捷键(本人亲自测试过)