Mercurial > audlegacy-plugins
changeset 1401:263d72004333
- Introduce a mutex for test_info and lock appropriately
author | Ralf Ertzinger <ralf@skytale.net> |
---|---|
date | Sat, 04 Aug 2007 16:30:43 +0200 |
parents | 58ce3497879a |
children | ce121ac96279 |
files | src/flacng/flacng.h src/flacng/plugin.c src/flacng/tools.c src/flacng/tools.h |
diffstat | 4 files changed, 32 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/flacng/flacng.h Fri Aug 03 20:39:05 2007 +0200 +++ b/src/flacng/flacng.h Sat Aug 04 16:30:43 2007 +0200 @@ -79,6 +79,7 @@ typedef struct callback_info { + GMutex* mutex; gint32* output_buffer; gint32* write_pointer; guint buffer_free;
--- a/src/flacng/plugin.c Fri Aug 03 20:39:05 2007 +0200 +++ b/src/flacng/plugin.c Sat Aug 04 16:30:43 2007 +0200 @@ -180,8 +180,11 @@ _DEBUG("Testing fd for file: %s", filename); + INFO_LOCK(test_info); + if (FALSE == read_metadata(fd, test_decoder, test_info)) { _DEBUG("File not handled by this plugin!"); + INFO_UNLOCK(test_info); _LEAVE FALSE; } @@ -190,6 +193,7 @@ */ if (FALSE == test_info->metadata_changed) { _DEBUG("No metadata found in stream"); + INFO_UNLOCK(test_info); _LEAVE FALSE; } @@ -207,6 +211,7 @@ if (MAX_SUPPORTED_CHANNELS < test_info->stream.channels) { _ERROR("This number of channels (%d) is currently not supported, stream not handled by this plugin", test_info->stream.channels); + INFO_UNLOCK(test_info); _LEAVE FALSE; } @@ -215,6 +220,7 @@ (8 != test_info->stream.bits_per_sample)) { _ERROR("This number of bits (%d) is currently not supported, stream not handled by this plugin", test_info->stream.bits_per_sample); + INFO_UNLOCK(test_info); _LEAVE FALSE; } @@ -225,6 +231,7 @@ _DEBUG("Accepting file %s", filename); reset_info(test_info, FALSE); + INFO_UNLOCK(test_info); _LEAVE TRUE; } @@ -647,11 +654,14 @@ _LEAVE; } + INFO_LOCK(test_info); + if (FALSE == read_metadata(fd, test_decoder, test_info)) { _ERROR("Could not read file info!"); *length = -1; *title = g_strdup(""); reset_info(test_info, TRUE); + INFO_UNLOCK(test_info); _LEAVE; } @@ -670,6 +680,7 @@ *title = get_title(filename, test_info); reset_info(test_info, TRUE); + INFO_UNLOCK(test_info); _LEAVE; } @@ -692,15 +703,19 @@ _LEAVE NULL; } + INFO_LOCK(test_info); + if (FALSE == read_metadata(fd, test_decoder, test_info)) { _ERROR("Could not read metadata tuple for file <%s>", filename); reset_info(test_info, TRUE); + INFO_UNLOCK(test_info); _LEAVE NULL; } tuple = get_tuple(filename, test_info); reset_info(test_info, TRUE); + INFO_UNLOCK(test_info); _LEAVE tuple; }
--- a/src/flacng/tools.c Fri Aug 03 20:39:05 2007 +0200 +++ b/src/flacng/tools.c Sat Aug 04 16:30:43 2007 +0200 @@ -66,6 +66,8 @@ info->replaygain.album_peak = NULL; reset_info(info, FALSE); + info->mutex = g_mutex_new(); + _DEBUG("Playback buffer allocated for %d samples, %d bytes", BUFFER_SIZE_SAMP, BUFFER_SIZE_BYTE); _LEAVE info;
--- a/src/flacng/tools.h Fri Aug 03 20:39:05 2007 +0200 +++ b/src/flacng/tools.h Sat Aug 04 16:30:43 2007 +0200 @@ -24,6 +24,20 @@ #include "flacng.h" #include "flac_compat.h" +#define INFO_LOCK(__info) \ + do { + _DEBUG("Trying to lock info %s", (__info)->name); \ + g_mutex_lock((__info)->mutex); \ + _DEBUG("Locked info %s", (__info)->name); \ + } while(0) + +#define INFO_UNLOCK(__info) \ + do { + _DEBUG("Unlocking info %s", (__info)->name); \ + g_mutex_unlock((__info)->mutex); \ + _DEBUG("Unlocked info %s", (__info)->name); \ + } while(0) + callback_info* init_callback_info(gchar* name); void reset_info(callback_info* info, gboolean close_fd); gchar* get_title(const gchar* filename, callback_info* info);