Code Samples:Simple audio player

From The Neuros Technology Wiki

(Redirected from OSD:make-your-own-software)
Jump to: navigation, search

The basics

Writing your own software to run on the OSD is really simple. First make you have successfully setup the development environment according to the official guide for example.

Then make sure you have all the right environment variables set by running source OSD/neuros-bsp/neuros-env (where OSD is the place you have your dev environment setup).

Audio playback

NOTE: This example would not work for me. Looks like changes have been made to nmsd.

Use this simple example program to play audio on the neuros: "/etc/init.d/extrasetup start" will have to be run before you try this code. if you are not auto starting osdmain.

#include <signal.h> 
#include <unistd.h> 
#include "client-nms.h" 
#include "nmsplugin.h" 

static media_info_t media_info; 

void stop_now(int signo){ 

int main(int argc, char *argv[]){ 
   if(argc != 2){ 
       printf("Please supply a filename\n"); 
       return 1; 

   signal(SIGQUIT, stop_now); 
   signal(SIGINT, stop_now); 

   printf("initializing nms\n"); 
   if (NmsConnect()) 
       printf("NMS initialization failed!\n"); 
       return 1; 

   printf("Nms: %s\n", NmsGetVersion()); 

   printf("Genre: %s\n", media_info.genre); 
   printf("Title: %s\n",media_info.title); 
   printf("Artist: %s\n",  media_info.artist); 
   printf("Album: %s\n", media_info.album); 
   printf("Comment: %s\n", media_info.comment); 
   printf("Year: %s\n",  media_info.year); 

   printf("stop record\n"); 
   printf("start playing\n"); 
   NmsPlay(0, argv[1]); 

   int cur_time; 
       cur_time = NmsGetPlaytime(); 
       printf("%i\n", cur_time); 
       if(cur_time == -1){ 


Save it as audiotest.c and compile it as follows:

arm-linux-gcc -O0 -D BUILD_TARGET_ARM -g -Wall -c audiotest.c -I#BSPROOT#/Neuros-Cooler/include/ -I#BSPROOT#/neuros-bsp/kernels/linux-2.6.15/include/ 
arm-linux-gcc -O0 audiotest.o -L. -lncooler -lcomnmsc -o audiotest
Personal tools