Mercurial > hg > xmms-sid
diff src/xmms-sid.c @ 241:291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 21 Dec 2004 15:05:03 +0000 |
parents | d04191d1ea64 |
children | 0cd0c02ed6c4 |
line wrap: on
line diff
--- a/src/xmms-sid.c Tue Dec 21 15:04:04 2004 +0000 +++ b/src/xmms-sid.c Tue Dec 21 15:05:03 2004 +0000 @@ -254,7 +254,11 @@ gboolean audioOpen = FALSE, doPlay = FALSE; guint audioGot; gint songLength; - gchar audioBuffer[XS_BUFSIZE]; +#ifdef XS_BUF_DYNAMIC + gchar *audioBuffer = NULL; +#else + gchar audioBuffer[XS_AUDIOBUF_SIZE]; +#endif /* Initialize */ XSDEBUG("entering player thread\n"); @@ -263,6 +267,16 @@ myTune = xs_status.tuneInfo; XS_MUTEX_UNLOCK(xs_status); + /* Allocate audio buffer */ +#ifdef XS_BUF_DYNAMIC + audioBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE); + if (audioBuffer == NULL) + { + XSERR("Couldn't allocate memory for audio data buffer!\n"); + goto xs_err_exit; + } +#endif + /* * Main player loop: while not stopped, loop here - play subtunes */ @@ -328,7 +342,7 @@ while (xs_status.isPlaying && myStatus.isPlaying && (xs_status.currSong == myStatus.currSong)) { /* Render audio data */ - audioGot = myStatus.sidPlayer->plrFillBuffer(&myStatus, audioBuffer, XS_BUFSIZE); + audioGot = myStatus.sidPlayer->plrFillBuffer(&myStatus, audioBuffer, XS_AUDIOBUF_SIZE); /* I <3 visualice/haujobb */ xs_plugin_ip.add_vis_pcm( @@ -389,6 +403,10 @@ xs_plugin_ip.output->close_audio(); } +#ifdef XS_BUF_DYNAMIC + g_free(audioBuffer); +#endif + /* Exit the playing thread */ XSDEBUG("exiting thread, bye.\n"); @@ -458,7 +476,6 @@ XSDEBUG("STOP_REQ\n"); xs_subctrl_close(); - xs_fileinfo_update(); XS_MUTEX_LOCK(xs_status); if (xs_status.isPlaying) @@ -472,6 +489,8 @@ XS_MUTEX_UNLOCK(xs_status); } + xs_fileinfo_update(); + /* Free tune information */ xs_status.sidPlayer->plrDeleteSID(&xs_status); xs_tuneinfo_free(xs_status.tuneInfo);