changeset 78:096db10ce25f trunk

[svn] - a few concurrency fixes
author nenolod
date Mon, 02 Oct 2006 19:55:45 -0700
parents c2981235af26
children 722fd456ae1a
files ChangeLog src/alac/demux.c src/alac/demux.h src/alac/plugin.c
diffstat 4 files changed, 46 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Oct 02 18:14:15 2006 -0700
+++ b/ChangeLog	Mon Oct 02 19:55:45 2006 -0700
@@ -1,3 +1,13 @@
+2006-10-03 01:14:15 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [154]
+  - thread safety
+  
+  trunk/src/alac/demux.c  |    3 +--
+  trunk/src/alac/demux.h  |    4 ++++
+  trunk/src/alac/plugin.c |   20 +++++++++-----------
+  3 files changed, 14 insertions(+), 13 deletions(-)
+
+
 2006-10-02 22:52:47 +0000  William Pitcock <nenolod@nenolod.net>
   revision [152]
   - too much was reverted here, only the if (!ext) return TRUE; was wrong.
--- a/src/alac/demux.c	Mon Oct 02 18:14:15 2006 -0700
+++ b/src/alac/demux.c	Mon Oct 02 19:55:45 2006 -0700
@@ -35,6 +35,8 @@
 #include <stdint.h>
 #include <stdlib.h>
 
+#include <glib.h>
+
 #include "stream.h"
 #include "demux.h"
 
@@ -480,6 +482,32 @@
     size_t size_remaining = chunk_len - 8; /* FIXME WRONG */
 
     stream_skip(qtmovie->stream, size_remaining);
+#if 0
+    while (size_remaining)
+    {
+        size_t sub_chunk_len;
+        fourcc_t sub_chunk_id;
+
+        sub_chunk_len = stream_read_uint32(qtmovie->stream);
+        if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
+            return;
+
+        sub_chunk_id = stream_read_uint32(qtmovie->stream);
+
+        switch (sub_chunk_id)
+        {
+        case MAKEFOURCC('m','e','t','a'):
+            stream_skip(qtmovie->stream, sub_chunk_len);
+            break;
+        default:
+            fprintf(stderr, "read_chunk_udta(%p, %lu): unknown chunk: %c%c%c%c\n",
+	            qtmovie, chunk_len, SPLITFOURCC(sub_chunk_id));
+	    return;
+        }
+
+        size_remaining -= sub_chunk_len;
+    }
+#endif
 }
 
 /* 'moov' movie atom - contains other atoms */
@@ -557,7 +585,7 @@
     qtmovie = (qtmovie_t*)malloc(sizeof(qtmovie_t));
 
     /* construct the stream */
-    demux_res->stream = qtmovie->stream = file;
+    qtmovie->stream = file;
     qtmovie->res = demux_res;
 
     memset(demux_res, 0, sizeof(demux_res_t));
--- a/src/alac/demux.h	Mon Oct 02 18:14:15 2006 -0700
+++ b/src/alac/demux.h	Mon Oct 02 19:55:45 2006 -0700
@@ -9,6 +9,9 @@
 
 typedef struct
 {
+    stream_t *stream;
+    alac_file *alac;
+
     uint16_t num_channels;
     uint16_t sample_size;
     uint32_t sample_rate;
@@ -31,9 +34,6 @@
 #if 0
     void *mdat;
 #endif
-
-    stream_t *stream;
-    alac_file *alac;
 } demux_res_t;
 
 int qtmovie_read(stream_t *stream, demux_res_t *demux_res);
--- a/src/alac/plugin.c	Mon Oct 02 18:14:15 2006 -0700
+++ b/src/alac/plugin.c	Mon Oct 02 19:55:45 2006 -0700
@@ -232,10 +232,6 @@
     free(pDestBuffer);
 }
 
-static void init_sound_converter(demux_res_t *demux_res)
-{
-}
-
 gpointer decode_thread(void *args)
 {
     demux_res_t demux_res;
@@ -245,6 +241,8 @@
     VFSFile *input_file;
     stream_t *input_stream;
 
+    memset(&demux_res, '\0', sizeof(demux_res_t));
+
     set_endian();
 
     input_file = vfs_fopen((char *) args, "rb");
@@ -258,6 +256,8 @@
     if (!qtmovie_read(input_stream, &demux_res))
         return 0;
 
+    demux_res.stream = input_stream;
+
     /* initialise the sound converter */
     demux_res.alac = create_alac(demux_res.sample_size, demux_res.num_channels);
     alac_set_info(demux_res.alac, demux_res.codecdata);