VoxPlayer::~VoxPlayer() { pthread_mutex_destroy(&m_cs); ao_shutdown(); mpg123_exit(); }
int main(int argc, char **argv) { mpg123_handle *m; int i; if(argc < 2) { fprintf(stderr, "\nI will give you the estimated and exact sample lengths of MPEG audio files.\n"); fprintf(stderr, "\nUsage: %s <mpeg audio file list>\n\n", argv[0]); return -1; } mpg123_init(); m = mpg123_new(NULL, NULL); mpg123_param(m, MPG123_RESYNC_LIMIT, -1, 0); /* New in library version 0.0.1 . */ for(i = 1; i < argc; ++i) { off_t a, b; mpg123_open(m, argv[i]); a = mpg123_length(m); mpg123_scan(m); b = mpg123_length(m); mpg123_close(m); printf("File %i: estimated %li vs. scanned %li\n", i, (long)a, (long)b); } mpg123_delete(m); mpg123_exit(); return 0; }
SimpleAudioEngine::~SimpleAudioEngine() { #ifdef ENABLE_MPG123 mpg123_exit(); #endif alutExit(); }
static void libmpg123_shutdown() { if(mh != NULL) { mpg123_close(mh); } mpg123_exit(); #ifdef BS_SIZE if (bs_buffer) { free(bs_buffer); bs_buffer = NULL; } #endif if (pcm_buffer) { free(pcm_buffer); pcm_buffer = NULL; } #ifdef BS_SIZE if (mp3_fd) { fs_close(mp3_fd); mp3_fd = 0; } #endif }
int main(int argc, char *argv[]){ if(argc < 2) return 0; ao_initialize(); mpg123_init(); mh = mpg123_new(NULL, NULL); mpg123_open_feed(mh); CURL *curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, play_stream); curl_easy_setopt(curl, CURLOPT_URL, argv[1]); curl_easy_perform(curl); curl_easy_cleanup(curl); mpg123_close(mh); mpg123_delete(mh); mpg123_exit(); ao_close(dev); ao_shutdown(); return 0; }
void safe_exit(int code) { char *dummy, *dammy; dump_close(); #ifdef HAVE_TERMIOS if(param.term_ctrl) term_restore(); #endif if(have_output) exit_output(ao, intflag); if(mh != NULL) mpg123_delete(mh); if(cleanup_mpg123) mpg123_exit(); httpdata_free(&htd); #ifdef WANT_WIN32_UNICODE win32_cmdline_free(argc, argv); /* This handles the premature argv == NULL, too. */ #endif #if defined (WANT_WIN32_SOCKETS) win32_net_deinit(); #endif /* It's ugly... but let's just fix this still-reachable memory chunk of static char*. */ split_dir_file("", &dummy, &dammy); exit(code); }
void cleanup(mpg123_handle *mh) { /* It's really to late for error checks here;-) */ mpg123_close(mh); mpg123_delete(mh); mpg123_exit(); }
int main(int argc, char **argv) { int ret = 0; size_t errs[2] = {0, 0}; size_t errs_ntom[2] = {0, 0}; if(argc < arg_total) { fprintf(stderr, "\nUsage: %s <decoder> <preframes> <mpeg audio file>\n\n", argv[0]); return -1; } mpg123_init(); m = mpg123_new(argv[arg_decoder], NULL); mpg123_param(m, MPG123_RESYNC_LIMIT, -1, 0); if(mpg123_param(m, MPG123_PREFRAMES, atol(argv[arg_preframes]), 0) == MPG123_OK) printf("Testing library with preframes set to %li\n", atol(argv[arg_preframes])); filename = argv[arg_file]; ret = check_seeking(errs); if(ret == 0) { printf("Now with NtoM resampling to 33333 Hz!"); mpg123_param(m, MPG123_FORCE_RATE, 33333, 0); ret = check_seeking(errs_ntom); } else fprintf(stderr, "Some failure occured! Unable to test properly!"); printf("\n"); printf("1to1 indexed seek errors: %"SIZE_P" / %"SIZE_P"\n", (size_p)errs[0],(size_p)samples); printf("1to1 non-indexed seek errors: %"SIZE_P" / %"SIZE_P"\n", (size_p)errs[1],(size_p)samples); printf("NtoM indexed seek errors: %"SIZE_P" / %"SIZE_P"\n", (size_p)errs_ntom[0],(size_p)samples); printf("NtoM non-indexed seek errors: %"SIZE_P" / %"SIZE_P"\n", (size_p)errs_ntom[1],(size_p)samples); printf("Errors in getting first sample again: %"SIZE_P"\n", first_sample_errs); printf("\n"); if(ret == 0) { if(first_sample_errs == 0 && errs[0] == 0 && errs[1] == 0 && errs_ntom[0] == 0 && errs_ntom[1] == 0) { printf("Congratulations, all seeks were accurate!\n"); printf("But be warned: Not _all_ sample offsets have been tested. This result just means that the basic mechanism of sample-accurate seeking seems to work.\n"); } else { printf("There have been some errors. For layer 3 files, this may be due to too low MPG123_PREFRAMES.\n"); ret = -1; } } else fprintf(stderr, "Some bad failure during checking!\n"); mpg123_delete(m); mpg123_exit(); return ret; }
static void S_MP3_CodecShutdown (void) { if (mp3_codec.initialized) { mp3_codec.initialized = false; mpg123_exit(); } }
/***************************************************************************** * ExitMPG123 : close down the mpg123 library (reentrant) *****************************************************************************/ static void ExitMPG123( void ) { vlc_mutex_lock( &mpg123_mutex ); mpg123_refcount--; if( mpg123_refcount == 0 ) mpg123_exit(); vlc_mutex_unlock( &mpg123_mutex ); }
static uint8_t * ReadMP3(Sound_t * Sound, const uint8_t * InData, size_t FileSize){ mpg123_handle *mh; if(mpg123_init() != MPG123_OK || (mh = mpg123_new(NULL, NULL)) == NULL){ mpg123_exit(); return NULL; } long rate; int channels, encoding; unsigned samples; size_t OutSize; uint8_t * OutData; if(mpg123_format_none(mh) != MPG123_OK || mpg123_format(mh, 44100, MPG123_MONO | MPG123_STEREO, MPG123_ENC_SIGNED_16) != MPG123_OK || mpg123_open_feed(mh) != MPG123_OK || mpg123_feed(mh, InData, FileSize) != MPG123_OK || mpg123_set_filesize(mh, FileSize) != MPG123_OK || mpg123_getformat(mh, &rate, &channels, &encoding) != MPG123_OK || (samples = mpg123_length(mh)) == 0 || (OutData = (uint8_t*) malloc(OutSize = samples * channels * 2)) == NULL ){ mpg123_close(mh); mpg123_delete(mh); mpg123_exit(); return NULL; } size_t decoded; mpg123_read(mh, OutData, OutSize, &decoded); mpg123_close(mh); mpg123_delete(mh); mpg123_exit(); if(decoded != OutSize){ free(OutData); return NULL; } Sound->Channels = channels; Sound->SamplingRate = rate; Sound->BitDepth = 16; Sound->Duration = samples; Sound->Data = OutData; return OutData; }
static void uninit(struct dec_audio *da) { struct ad_mpg123_context *con = da->priv; mpg123_close(con->handle); mpg123_delete(con->handle); mpg123_exit(); }
void mpgplayer::run() { if(mpg123_init() != MPG123_OK) qDebug("Error initilizing mpg123"); const char **test = mpg123_supported_decoders(); int error; mpg123_handle *mh = mpg123_new(test[0],&error); if(!mpg123_feature(MPG123_FEATURE_DECODE_LAYER3)) { qDebug("You do not seem to have mp3 decoding support"); return; } mpg123_format_none(mh); if(mpg123_format(mh,samplerate,MPG123_STEREO,MPG123_ENC_SIGNED_16)!=MPG123_OK) qDebug("Error in initilizing format decoder"); qDebug(test[0]); mpg123_open(mh,"/home/eli/Projects/groove-evan/Animal.mp3"); net = TData; pa_simple *s; pa_sample_spec ss; ss.format = PA_SAMPLE_S16NE; ss.rate = samplerate; ss.channels = 2; s =pa_simple_new(NULL,"Groove",PA_STREAM_PLAYBACK ,NULL,"Music",&ss,NULL,NULL,NULL); unsigned char bytes[1024]; size_t bsize = 1024; size_t done = 0; bool stop = false; playing=true; while(!stop) { switch(net) { case TWait: usleep(100); break; case TData: if(mpg123_read(mh,bytes,bsize,&done)==MPG123_DONE) { net=TFinish; } pa_simple_write(s,bytes,done,&error); break; case TAbort: stop = true; break; case TFinish: pa_simple_drain(s,&error); stop = true; break; default: break; } } qDebug("Finsihed playback"); pa_simple_free(s); mpg123_exit(); }
UMP3Decoder::~UMP3Decoder() { if (Handle) { mpg123_close(Handle); mpg123_delete(Handle); mpg123_exit(); } }
void cleanup() { mpg123_close(mh); mpg123_delete(mh); mpg123_exit(); ao_close(dev); ao_shutdown(); }
void close_sound(void) { free(buffer); ao_close(dev); mpg123_close(mh); mpg123_delete(mh); mpg123_exit(); ao_shutdown(); }
/* @name Pulizia Mp3 * Questa funzione si occupa di liberare le variabili per riprodurre l'Mp3 */ void freeMp3() { free(buffer); buffer=NULL; mpg123_close(mh); mpg123_delete(mh); mpg123_exit(); freeAudioDev(); mh=NULL; //endResample(); // -ONLY TESTING- Check header }
//--------------------------------------- void ofOpenALSoundPlayer::close(){ if(alDevice){ alcCloseDevice(alDevice); alDevice = NULL; alcDestroyContext(alContext); alContext = 0; #ifdef OF_USING_MPG123 mpg123_exit(); #endif } }
int in_mp3_destroy(plugin_obj *obj) { mpg123_delete(obj->data); mpg123_exit(); free(obj); obj = NULL; return REPLAY_OK; }
MusicPlayer::~MusicPlayer() { #ifdef USE_OGG stb_vorbis_close(v); #endif #ifdef USE_MP3 mpg123_close(mh); mpg123_delete(mh); mpg123_exit(); #endif }
void nuiAudioDecoderPrivate::Clear() { // delete decoder handle mpg123_delete(mpHandle); mpHandle = NULL; sMpg123Counter--; if (sMpg123Counter == 0) { // close mpg123 library mpg123_exit(); } }
Mp3::~Mp3() { stop(); if (myBuffer) { delete [] myBuffer; myBuffer = NULL; } mpg123_close(myHandle); mpg123_delete(myHandle); mpg123_exit(); }
int main(int argc, char **argv) { int err; int ret = 0; mpg123_handle *mh; mpg123_id3v2 *id3; if(argc < 2) { printf("Gimme a MPEG file name...\n"); return 0; } mpg123_init(); mh = mpg123_new(NULL, &err); if(err != MPG123_OK) goto badend; mpg123_param(mh, MPG123_ADD_FLAGS, MPG123_PLAIN_ID3TEXT, 0.); err = mpg123_open(mh, argv[1]); if(err != MPG123_OK) goto badend; err = mpg123_scan(mh); if(err != MPG123_OK) goto badend; err = mpg123_id3(mh, NULL, &id3); if(err != MPG123_OK) goto badend; if(id3 == NULL) { error("No ID3 data found."); goto badend; } print_field("artist", id3->artist); print_field("title", id3->title); print_field("album", id3->album); print_field("comment", id3->comment); goto end; badend: ret = -1; end: mpg123_delete(mh); mpg123_exit(); return ret; }
int Waveform::GetLengthOfMusicFileInMS(const wxString &filename) { mpg123_handle *mh; int err; int channels, encoding; long rate; mpg123_init(); mh = mpg123_new(NULL, &err); /* open the file and get the decoding format */ mpg123_open(mh, filename.c_str()); mpg123_getformat(mh, &rate, &channels, &encoding); int bits = mpg123_encsize(encoding); /* Get Track Size */ int trackSize = GetTrackSize(mh,bits,channels); mpg123_close(mh); mpg123_delete(mh); mpg123_exit(); float seconds = (float)trackSize * ((float)1/(float)rate); return (int)(seconds * (float)1000); }
void closePlug(bool x,bool z) { mustReset = false; if ( !x && !z ) { fs.setParent(NULL); fs.close(); return; } if (x) savPos(); Save.zapiszopcje(); BS = true; stop(); if (fo->isVisible()) fo->close(); if ( timref.isActive() ) timref.stop(); mpg123_exit(); }
audioBuffer loadMp3File(const char* filename) { audioBuffer encBuffer; mpg123_handle *mh; unsigned char *buffer; size_t buffer_size; size_t done; int err; int channels, encoding; long rate; //inizialize mpg123 and its handler mpg123_init(); mh = mpg123_new(NULL, &err); buffer_size = mpg123_outblock(mh); buffer = (unsigned char*) malloc(buffer_size * sizeof(unsigned char)); mpg123_open(mh, filename); mpg123_getformat(mh, &rate, &channels, &encoding); int m_bits = mpg123_encsize(encoding); int m_rate = rate; int m_channels = channels; //loads decoded file in memory for (int totalBtyes = 0 ; mpg123_read(mh, buffer, buffer_size, &done) == MPG123_OK ; ) { totalBtyes += done; } encBuffer.bufPointer = buffer; //deallocates mpg123 memory mpg123_close(mh); mpg123_delete(mh); mpg123_exit(); return encBuffer; }
void SYS_ShutdownSound() { SYS_StopAllSounds(); #ifdef SYS_SOUNDDEBUG fprintf( soundLog, "SYS_ShutdownSound(), %d loaded, %d free\n", soundsLoaded, soundsFree ); #endif int i; for (i = 0; i < SIZEOFSOURCEPOOL; ++i) { if (sourcePool[i]) { alDeleteSources(1, &sourcePool[i]); CheckForErrors(); } } while ( usedList ) { SYS_ReleaseSound( (SYS_SOUNDHANDLE)usedList ); } #ifdef SYS_SOUNDDEBUG fprintf( soundLog, "Cleaned up used sounds, %d loaded, %d free\n", soundsLoaded, soundsFree ); fclose( soundLog ); #endif mpg123_exit(); ALCcontext* context = alcGetCurrentContext(); CheckForErrors(); ALCdevice* device = alcGetContextsDevice(context); CheckForErrors(); alcMakeContextCurrent(0); alcDestroyContext(context); alcCloseDevice(device); }
void cleanup( mpg123_handle *handle ) { mpg123_close(handle); mpg123_delete(handle); mpg123_exit(); }
Mp3Decoder::~Mp3Decoder() { // It's to late for error checks here mpg123_close(m_mh); mpg123_delete(m_mh); mpg123_exit(); }
void Mpg123Decoder::quit() { if (inited) mpg123_exit(); }