void cmdline_mode(int argc, char *argv[]) { int p, t; AppData *appdata = g_new(AppData, 1); appdata->runmode = CMDLINE; appdata->playlist = playlist_new(); appdata->decoder = decoder_new(); appdata->stream = NULL; /* setup callbacks */ playlist_set_play_cb(appdata->playlist, play_cb, (void *) appdata); playlist_next(appdata->playlist); while (TRUE) { if (decoder_is_playing(appdata->decoder)) { p = decoder_get_position(appdata->decoder); t = decoder_get_total(appdata->decoder); printf("%s: %d / %d\n", appdata->decoder->tag_title, p, t); } else if (decoder_has_finished(appdata->decoder)) { playlist_next(appdata->playlist); } usleep(500); } }
Decoder* init_decoder() { Decoder* obj = decoder_new(); char *filename = FILENAME; FILE *pF = fopen( filename, "rb" ); obj->pOpaqueSource = (void*) pF; decoder_reg_read( obj, read_fp ); decoder_reg_seek( obj, seek_fp ); decoder_init( obj ); decoder_load_info( obj ); return obj; }
int XAudPlayer::Init(char * const szFileName, const int volume) { m_fStarted = false; /* open the mp3 file (name passed as program argument */ if (fopen_s(&file, szFileName, "rb")) { //fprintf(stderr, "cannot open input file\n"); return 0; } /* create a decoder */ if (decoder_new(&m_decoder) != XA_SUCCESS) { //fprintf(stderr, "cannot create decoder"); return 0; } /* register mpeg audio codec */ { XA_CodecModule module; mpeg_codec_module_register(&module); decoder_codec_module_register(m_decoder, &module); } /* register the memory input module */ { XA_InputModule module; memory_input_module_register(&module); decoder_input_module_register(m_decoder, &module); } /* create and open input object */ const int status = decoder_input_new(m_decoder, NULL, XA_DECODER_INPUT_AUTOSELECT); if (status != XA_SUCCESS) { //error("cannot create input [%d]\n", status); } if (decoder_input_open(m_decoder) != XA_SUCCESS) { printf("cannot open input\n"); return 0; } CreateBuffer(volume); return 1; }
void gui_mode(int argc, char *argv[]) { osso_context_t *osso_context; char *versionstring; AppData *appdata = g_new(AppData, 1); appdata->runmode = GUI; gtk_init(&argc, &argv); /* register OSSO service */ osso_context = osso_initialize(NAME, VERSION, TRUE, NULL); if (! osso_context) fprintf(stderr, "Could not initialize OSSO."); appdata->playlist = playlist_new(); appdata->decoder = decoder_new(); appdata->stream = NULL; appdata->gui = gui_new(appdata->playlist); versionstring = g_strconcat(FULLNAME, " ", VERSION, NULL); gui_set_title(appdata->gui, "", versionstring, ""); g_free(versionstring); /* setup callbacks */ playlist_set_play_cb(appdata->playlist, play_cb, (void *) appdata); /* setup GUI callbacks */ gui_set_open_cb(appdata->gui, open_cb, (void *) appdata); gui_set_volume_cb(appdata->gui, volume_cb, (void *) appdata); gui_set_seek_cb(appdata->gui, seek_cb, (void *) appdata); gui_set_control_cb(appdata->gui, control_cb, (void *) appdata); g_timeout_add(500, (GSourceFunc) status_cb, appdata); gui_run(); }