Ejemplo n.º 1
0
        public void Run()
        {
            xmlReader.MoveToContent();
            while (xmlReader.Read())
            {
                if (!xmlReader.IsStartElement())
                {
                    continue;
                }

                outputEntries.Add(RawEntry.Read(xmlReader.ReadSubtree()));
            }
            outputEntries.CompleteAdding();
            Console.WriteLine("*** Reader done ***");
        }
Ejemplo n.º 2
0
        private void Run()
        {
            while (!inputEntries.IsCompleted)
            {
                RawEntry entry = null;
                try
                {
                    entry = inputEntries.Take();
                    var parts = entry.AudioFile.Split('|');

                    byte[] hash;
                    Stream str = null;
                    try
                    {
                        str = File.OpenRead(@"..\DATA\AUDIO\" + parts[0]);

                        // If it was a UTF file, grab the entry from it
                        if (parts.Length > 1)
                        {
                            str = UTFReader.ReadEntry(str, parts[1]);
                        }

                        hash = AudioHasher.Hash(str, entry.Hack);

                        Console.WriteLine($"Convert: {entry.AudioFile} -> {hash.DebugSubtitleKey()}");
                    }
                    finally
                    {
                        str?.Dispose();
                    }

                    outputEntries.Add(new HashedEntry(entry, hash));
                }
                catch (FileSanityException e)
                {
                    e.FileName = entry?.AudioFile;
                    throw;
                }
                catch (InvalidOperationException)
                {
                    //inputEntries got completed during Take()
                    break;
                }
            }
        }