Skip to content

Commit

Permalink
Experimenting parallel processing
Browse files Browse the repository at this point in the history
  • Loading branch information
VioletXF committed Aug 19, 2023
1 parent d19119c commit 8866457
Show file tree
Hide file tree
Showing 20 changed files with 341 additions and 205 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Plugins/System.Buffers.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Plugins/System.Data.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Plugins/System.Memory.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Plugins/System.Numerics.Vectors.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions Assets/Scripts/BGAPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public void Load(int id, string path)
var ext = path.Substring(path.LastIndexOf('.') + 1);
if (Array.IndexOf(extensions, ext) == -1)
{
Debug.Log("Unsupported BGA file extension: " + ext);
Logger.Log("Unsupported BGA file extension: " + ext);
return;
}
var player = Camera.main.gameObject.AddComponent<VideoPlayer>();

Debug.Log("Loading BGA player " + id + " from " + path);
Debug.Log(player);
Logger.Log("Loading BGA player " + id + " from " + path);
Logger.Log(player);
try
{
player.playOnAwake = false;
Expand All @@ -67,7 +67,7 @@ public void Load(int id, string path)
player.errorReceived += (source, message) =>
{
player.Stop();
Debug.Log("BGA player " + id + " error: " + message);
Logger.Log("BGA player " + id + " error: " + message);
players.Remove(id);
OnPrepareCompleted(player);
};
Expand All @@ -76,8 +76,8 @@ public void Load(int id, string path)
TotalPlayers++;
} catch (Exception e)
{
Debug.Log("Failed to load BGA player " + id + " from " + path);
Debug.Log(e);
Logger.Log("Failed to load BGA player " + id + " from " + path);
Logger.Log(e);
OnPrepareCompleted(player);
}
}
Expand All @@ -93,7 +93,7 @@ private void OnPrepareCompleted(VideoPlayer source)
player.skipOnDrop = true;
}

Debug.Log("All BGA players are prepared");
Logger.Log("All BGA players are prepared");
OnAllPlayersLoaded?.Invoke(this, EventArgs.Empty);
}
}
Expand All @@ -105,7 +105,7 @@ public void Update(long timeMicro)
foreach (var id in ids)
{
if (!players.ContainsKey(id)) continue;
// Debug.Log("updating " + id + " at " + timeMicro);
// Logger.Log("updating " + id + " at " + timeMicro);
if (timeMicro >= time)
{
players[id].skipOnDrop = true;
Expand Down Expand Up @@ -146,7 +146,7 @@ public void PauseAll()
public void Schedule(int id, long time)
{
if(!players.ContainsKey(id)) return;
Debug.Log("Scheduling " + id + " at " + time);
Logger.Log("Scheduling " + id + " at " + time);
if (!state.Schedules.ContainsKey(time))
state.Schedules.Add(time, new List<int>());

Expand Down
18 changes: 9 additions & 9 deletions Assets/Scripts/BMPLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ public BMPImage LoadBMP(BinaryReader aReader)
BMPImage bmp = new BMPImage();
if (!ReadFileHeader(aReader, ref bmp.header))
{
Debug.LogError("Not a BMP file");
Logger.LogError("Not a BMP file");
return null;
}
if (!ReadInfoHeader(aReader, ref bmp.info))
{
Debug.LogError("Unsupported header format");
Logger.LogError("Unsupported header format");
return null;
}
if (bmp.info.compressionMethod != BMPComressionMode.BI_RGB
Expand All @@ -203,7 +203,7 @@ public BMPImage LoadBMP(BinaryReader aReader)
&& bmp.info.compressionMethod != BMPComressionMode.BI_RLE8
)
{
Debug.LogError("Unsupported image format: " + bmp.info.compressionMethod);
Logger.LogError("Unsupported image format: " + bmp.info.compressionMethod);
return null;
}
long offset = 14 + bmp.info.size;
Expand Down Expand Up @@ -249,7 +249,7 @@ public BMPImage LoadBMP(BinaryReader aReader)
ReadIndexedImage(aReader, bmp);
else
{
Debug.LogError("Unsupported file format: " + bmp.info.compressionMethod + " BPP: " + bmp.info.nBitsPerPixel);
Logger.LogError("Unsupported file format: " + bmp.info.compressionMethod + " BPP: " + bmp.info.nBitsPerPixel);
return null;
}
return bmp;
Expand All @@ -263,7 +263,7 @@ private static void Read32BitImage(BinaryReader aReader, BMPImage bmp)
Color32[] data = bmp.imageData = new Color32[w * h];
if (aReader.BaseStream.Position + w * h * 4 > aReader.BaseStream.Length)
{
Debug.LogError("Unexpected end of file.");
Logger.LogError("Unexpected end of file.");
return;
}
int shiftR = GetShiftCount(bmp.rMask);
Expand Down Expand Up @@ -294,7 +294,7 @@ private static void Read24BitImage(BinaryReader aReader, BMPImage bmp)
Color32[] data = bmp.imageData = new Color32[w * h];
if (aReader.BaseStream.Position + count > aReader.BaseStream.Length)
{
Debug.LogError("Unexpected end of file. (Have " + (aReader.BaseStream.Position + count) + " bytes, expected " + aReader.BaseStream.Length + " bytes)");
Logger.LogError("Unexpected end of file. (Have " + (aReader.BaseStream.Position + count) + " bytes, expected " + aReader.BaseStream.Length + " bytes)");
return;
}
int shiftR = GetShiftCount(bmp.rMask);
Expand Down Expand Up @@ -325,7 +325,7 @@ private static void Read16BitImage(BinaryReader aReader, BMPImage bmp)
Color32[] data = bmp.imageData = new Color32[w * h];
if (aReader.BaseStream.Position + count > aReader.BaseStream.Length)
{
Debug.LogError("Unexpected end of file. (Have " + (aReader.BaseStream.Position + count) + " bytes, expected " + aReader.BaseStream.Length + " bytes)");
Logger.LogError("Unexpected end of file. (Have " + (aReader.BaseStream.Position + count) + " bytes, expected " + aReader.BaseStream.Length + " bytes)");
return;
}
int shiftR = GetShiftCount(bmp.rMask);
Expand Down Expand Up @@ -361,7 +361,7 @@ private static void ReadIndexedImage(BinaryReader aReader, BMPImage bmp)
Color32[] data = bmp.imageData = new Color32[w * h];
if (aReader.BaseStream.Position + count > aReader.BaseStream.Length)
{
Debug.LogError("Unexpected end of file. (Have " + (aReader.BaseStream.Position + count) + " bytes, expected " + aReader.BaseStream.Length + " bytes)");
Logger.LogError("Unexpected end of file. (Have " + (aReader.BaseStream.Position + count) + " bytes, expected " + aReader.BaseStream.Length + " bytes)");
return;
}
BitStreamReader bitReader = new BitStreamReader(aReader);
Expand All @@ -372,7 +372,7 @@ private static void ReadIndexedImage(BinaryReader aReader, BMPImage bmp)
int v = (int)bitReader.ReadBits(bitCount);
if (v >= bmp.palette.Count)
{
Debug.LogError("Indexed bitmap has indices greater than it's color palette");
Logger.LogError("Indexed bitmap has indices greater than it's color palette");
return;
}
data[x + y * w] = bmp.palette[v];
Expand Down
Loading

0 comments on commit 8866457

Please sign in to comment.