Skip to content

Commit

Permalink
Reverted to commit 3f297aa, which means the "latest-upstream" branch …
Browse files Browse the repository at this point in the history
…now points to the CodePlex version and master is the one used in FEZ v1.09.

Merge branch 'upstream/master'

Conflicts:
	NVorbis/ACache.cs
	NVorbis/NVorbis.csproj (reverted from commit 3f297aa)
  • Loading branch information
renaudbedard committed Sep 7, 2013
1 parent 600c3dd commit 66e42f1
Show file tree
Hide file tree
Showing 35 changed files with 1,750 additions and 2,540 deletions.
4 changes: 2 additions & 2 deletions NAudioSupport/Properties/AssemblyInfo.cs
Expand Up @@ -12,5 +12,5 @@

[assembly: ComVisible(false)]

[assembly: AssemblyVersion("0.5.6.0")]
[assembly: AssemblyFileVersion("0.5.6.0")]
[assembly: AssemblyVersion("0.5.5.0")]
[assembly: AssemblyFileVersion("0.5.5.0")]
2 changes: 1 addition & 1 deletion NAudioSupport/VorbisWaveReader.cs
Expand Up @@ -58,7 +58,7 @@ public override long Position
{
get
{
return (long)(_reader.DecodedTime.TotalSeconds * _reader.SampleRate * _reader.Channels * sizeof(float));
return (long)(_reader.DecodedTime.TotalMilliseconds * _reader.SampleRate * _reader.Channels * sizeof(float));
}
set
{
Expand Down
7 changes: 4 additions & 3 deletions NVorbis.NAudioSupport.nuspec
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>NVorbis.NAudioSupport</id>
<version>0.5.6</version>
<version>0.5.5</version>
<title />
<authors>Andrew Ward</authors>
<owners />
Expand All @@ -11,12 +11,13 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>NAudio support for NVorbis</description>
<summary>NAudio support for NVorbis</summary>
<releaseNotes>- Bugfix: Position getter was using milliseconds instead of seconds</releaseNotes>
<releaseNotes>- Added new constructor for Stream
- Cleanup and Optimizations</releaseNotes>
<language>en-US</language>
<tags>audio c# .NET sound vorbis</tags>
<dependencies>
<dependency id="NAudio" version="1.5" />
<dependency id="NVorbis" version="0.6.0" />
<dependency id="NVorbis" version="0.5.5" />
</dependencies>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System" />
Expand Down
7 changes: 3 additions & 4 deletions NVorbis.OpenTKSupport.nuspec
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>NVorbis.OpenTKSupport</id>
<version>1.1.0</version>
<version>1.0.0</version>
<title />
<authors>Renaud Bedard</authors>
<owners />
Expand All @@ -11,13 +11,12 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>OpenTK support for NVorbis</description>
<summary>OpenTK support for NVorbis</summary>
<releaseNotes>- Make Ready and CastBuffer public. Allow the user to take charge of calling EnsureBuffersFilled().
- Provide a callback to notify when OggStream is finished</releaseNotes>
<releaseNotes>Initial Release</releaseNotes>
<language>en-US</language>
<tags>audio c# .NET sound vorbis OpenTK OpenAL</tags>
<dependencies>
<dependency id="opentk_unoffical" version="1.1.788.3121" />
<dependency id="NVorbis" version="0.7.2" />
<dependency id="NVorbis" version="0.5.4" />
</dependencies>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System" />
Expand Down
6 changes: 4 additions & 2 deletions NVorbis.nuspec
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>NVorbis</id>
<version>0.7.3</version>
<version>0.5.5</version>
<title />
<authors>Andrew Ward</authors>
<owners />
Expand All @@ -11,7 +11,9 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A fully managed implementation of a Xiph.org Foundation Ogg Vorbis decoder.</description>
<summary>A managed Xiph.org Foundation Ogg Vorbis decoder</summary>
<releaseNotes>- Bugfix: Fixed residue 1</releaseNotes>
<releaseNotes>- Make Ogg container code thread-safe
- Cleanup and Optimizations
- Change seek to use page's GranulePosition on every page instead of continuing previous count (this is only an issue in broken files)</releaseNotes>
<language>en-US</language>
<tags>ogg vorbis xiph audio c# sound .NET</tags>
<frameworkAssemblies>
Expand Down
158 changes: 158 additions & 0 deletions NVorbis/ACache.cs
@@ -0,0 +1,158 @@
/****************************************************************************
* NVorbis *
* Copyright (C) 2012, Andrew Ward <afward@gmail.com> *
* *
* See COPYING for license terms (Ms-PL). *
* *
***************************************************************************/
using System;
using System.Collections.Generic;

namespace NVorbis
{
static class Hashing
{
static unsafe void Hash(byte* d, int len, ref uint h)
{
for (int i = 0; i < len; i++)
{
h += d[i];
h += (h << 10);
h ^= (h >> 6);
}
}
unsafe static void Hash(ref uint h, int data)
{
byte* d = (byte*)&data;
Hash(d, sizeof(int), ref h);
}

unsafe static int Avalanche(uint h)
{
h += (h << 3);
h ^= (h >> 11);
h += (h << 15);
return *((int*)(void*)&h);
}

public static int CombineHashCodes(int first, int second)
{
uint h = 0;
Hash(ref h, first);
Hash(ref h, second);
return Avalanche(h);
}
}

static class ACache
{
static readonly Dictionary<BufferDescriptor, Stack<IBufferStorage>> buffers = new Dictionary<BufferDescriptor, Stack<IBufferStorage>>();

struct BufferDescriptor : IEquatable<BufferDescriptor>
{
readonly Type Type;
readonly int Elements;

public BufferDescriptor(Type type, int elements)
{
Type = type;
Elements = elements;
}

public override int GetHashCode()
{
return Hashing.CombineHashCodes(Type.GetHashCode(), Elements.GetHashCode());
}
public bool Equals(BufferDescriptor other)
{
return other.Type == Type && other.Elements == Elements;
}
public override bool Equals(object other)
{
return other is BufferDescriptor && ((BufferDescriptor) other).Equals(this);
}
}

interface IBufferStorage { }
struct BufferStorage<T> : IBufferStorage
{
public readonly T[] Buffer;

public BufferStorage(T[] buffer)
{
Buffer = buffer;
}
}

internal static T[] Get<T>(int elements)
{
return Get<T>(elements, true);
}

internal static T[] Get<T>(int elements, bool clearFirst)
{
var descriptor = new BufferDescriptor(typeof(T), elements);

Stack<IBufferStorage> stack;
if (!buffers.TryGetValue(descriptor, out stack))
buffers.Add(descriptor, stack = new Stack<IBufferStorage>());

T[] buffer;
if (stack.Count == 0) buffer = new T[elements];
else buffer = ((BufferStorage<T>) stack.Pop()).Buffer;

if (clearFirst)
for (int i = 0; i < elements; i++)
buffer[i] = default(T);

return buffer;
}

internal static T[][] Get<T>(int firstRankSize, int secondRankSize)
{
var temp = Get<T[]>(firstRankSize, false);
for (int i = 0; i < firstRankSize; i++)
{
temp[i] = Get<T>(secondRankSize, true);
}
return temp;
}

internal static T[][][] Get<T>(int firstRankSize, int secondRankSize, int thirdRankSize)
{
var temp = Get<T[][]>(firstRankSize, false);
for (int i = 0; i < firstRankSize; i++)
{
temp[i] = Get<T>(secondRankSize, thirdRankSize);
}
return temp;
}

internal static void Return<T>(ref T[] buffer)
{
var descriptor = new BufferDescriptor(typeof(T), buffer.Length);
Stack<IBufferStorage> stack;
if (!buffers.TryGetValue(descriptor, out stack))
throw new InvalidOperationException("Returning a buffer that's never been taken!");
stack.Push(new BufferStorage<T>(buffer));
}

internal static void Return<T>(ref T[][] buffer)
{
for (int i = 0; i < buffer.Length; i++)
{
if (buffer[i] != null) Return(ref buffer[i]);
}
Return<T[]>(ref buffer);
}

internal static void Return<T>(ref T[][][] buffer)
{
for (int i = 0; i < buffer.Length; i++)
{
if (buffer[i] != null) Return(ref buffer[i]);
}
Return<T[][]>(ref buffer);
}
}
}

0 comments on commit 66e42f1

Please sign in to comment.