Skip to content

Commit e4c8455

Browse files
committed
Merge 25.09
2 parents 93c31da + ed62a28 commit e4c8455

26 files changed

Lines changed: 703 additions & 19 deletions

FNA.Core.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,24 @@
307307
<Compile Include="src\LaunchParameters.cs" />
308308
<Compile Include="src\MathHelper.cs" />
309309
<Compile Include="src\Matrix.cs" />
310+
<Compile Include="src\Media\Album.cs" />
311+
<Compile Include="src\Media\AlbumCollection.cs" />
312+
<Compile Include="src\Media\Artist.cs" />
313+
<Compile Include="src\Media\ArtistCollection.cs" />
314+
<Compile Include="src\Media\Genre.cs" />
315+
<Compile Include="src\Media\GenreCollection.cs" />
316+
<Compile Include="src\Media\MediaLibrary.cs" />
310317
<Compile Include="src\Media\MediaPlayer.cs" />
311318
<Compile Include="src\Media\MediaQueue.cs" />
319+
<Compile Include="src\Media\MediaSource.cs" />
320+
<Compile Include="src\Media\MediaSourceType.cs" />
312321
<Compile Include="src\Media\MediaState.cs" />
322+
<Compile Include="src\Media\Picture.cs" />
323+
<Compile Include="src\Media\PictureAlbum.cs" />
324+
<Compile Include="src\Media\PictureAlbumCollection.cs" />
325+
<Compile Include="src\Media\PictureCollection.cs" />
326+
<Compile Include="src\Media\Playlist.cs" />
327+
<Compile Include="src\Media\PlaylistCollection.cs" />
313328
<Compile Include="src\Media\Song.cs" />
314329
<Compile Include="src\Media\SongCollection.cs" />
315330
<Compile Include="src\Media\VideoSoundtrackType.cs" />

FNA.NetFramework.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,24 @@
306306
<Compile Include="src\LaunchParameters.cs" />
307307
<Compile Include="src\MathHelper.cs" />
308308
<Compile Include="src\Matrix.cs" />
309+
<Compile Include="src\Media\Album.cs" />
310+
<Compile Include="src\Media\AlbumCollection.cs" />
311+
<Compile Include="src\Media\Artist.cs" />
312+
<Compile Include="src\Media\ArtistCollection.cs" />
313+
<Compile Include="src\Media\Genre.cs" />
314+
<Compile Include="src\Media\GenreCollection.cs" />
315+
<Compile Include="src\Media\MediaLibrary.cs" />
309316
<Compile Include="src\Media\MediaPlayer.cs" />
310317
<Compile Include="src\Media\MediaQueue.cs" />
318+
<Compile Include="src\Media\MediaSource.cs" />
319+
<Compile Include="src\Media\MediaSourceType.cs" />
311320
<Compile Include="src\Media\MediaState.cs" />
321+
<Compile Include="src\Media\Picture.cs" />
322+
<Compile Include="src\Media\PictureAlbum.cs" />
323+
<Compile Include="src\Media\PictureAlbumCollection.cs" />
324+
<Compile Include="src\Media\PictureCollection.cs" />
325+
<Compile Include="src\Media\Playlist.cs" />
326+
<Compile Include="src\Media\PlaylistCollection.cs" />
312327
<Compile Include="src\Media\Song.cs" />
313328
<Compile Include="src\Media\SongCollection.cs" />
314329
<Compile Include="src\Media\VideoSoundtrackType.cs" />

FNA.NetStandard.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,24 @@
304304
<Compile Include="src\LaunchParameters.cs" />
305305
<Compile Include="src\MathHelper.cs" />
306306
<Compile Include="src\Matrix.cs" />
307+
<Compile Include="src\Media\Album.cs" />
308+
<Compile Include="src\Media\AlbumCollection.cs" />
309+
<Compile Include="src\Media\Artist.cs" />
310+
<Compile Include="src\Media\ArtistCollection.cs" />
311+
<Compile Include="src\Media\Genre.cs" />
312+
<Compile Include="src\Media\GenreCollection.cs" />
313+
<Compile Include="src\Media\MediaLibrary.cs" />
307314
<Compile Include="src\Media\MediaPlayer.cs" />
308315
<Compile Include="src\Media\MediaQueue.cs" />
316+
<Compile Include="src\Media\MediaSource.cs" />
317+
<Compile Include="src\Media\MediaSourceType.cs" />
309318
<Compile Include="src\Media\MediaState.cs" />
319+
<Compile Include="src\Media\Picture.cs" />
320+
<Compile Include="src\Media\PictureAlbum.cs" />
321+
<Compile Include="src\Media\PictureAlbumCollection.cs" />
322+
<Compile Include="src\Media\PictureCollection.cs" />
323+
<Compile Include="src\Media\Playlist.cs" />
324+
<Compile Include="src\Media\PlaylistCollection.cs" />
310325
<Compile Include="src\Media\Song.cs" />
311326
<Compile Include="src\Media\SongCollection.cs" />
312327
<Compile Include="src\Media\VideoSoundtrackType.cs" />

FNA.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,24 @@
377377
<Compile Include="src\LaunchParameters.cs" />
378378
<Compile Include="src\MathHelper.cs" />
379379
<Compile Include="src\Matrix.cs" />
380+
<Compile Include="src\Media\Album.cs" />
381+
<Compile Include="src\Media\AlbumCollection.cs" />
382+
<Compile Include="src\Media\Artist.cs" />
383+
<Compile Include="src\Media\ArtistCollection.cs" />
384+
<Compile Include="src\Media\Genre.cs" />
385+
<Compile Include="src\Media\GenreCollection.cs" />
386+
<Compile Include="src\Media\MediaLibrary.cs" />
380387
<Compile Include="src\Media\MediaPlayer.cs" />
381388
<Compile Include="src\Media\MediaQueue.cs" />
389+
<Compile Include="src\Media\MediaSource.cs" />
390+
<Compile Include="src\Media\MediaSourceType.cs" />
382391
<Compile Include="src\Media\MediaState.cs" />
392+
<Compile Include="src\Media\Picture.cs" />
393+
<Compile Include="src\Media\PictureAlbum.cs" />
394+
<Compile Include="src\Media\PictureAlbumCollection.cs" />
395+
<Compile Include="src\Media\PictureCollection.cs" />
396+
<Compile Include="src\Media\Playlist.cs" />
397+
<Compile Include="src\Media\PlaylistCollection.cs" />
383398
<Compile Include="src\Media\Song.cs" />
384399
<Compile Include="src\Media\SongCollection.cs" />
385400
<Compile Include="src\Media\VideoSoundtrackType.cs" />

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,24 @@ SRC = \
289289
src/LaunchParameters.cs \
290290
src/MathHelper.cs \
291291
src/Matrix.cs \
292+
src/Media/Album.cs \
293+
src/Media/AlbumCollection.cs \
294+
src/Media/Artist.cs \
295+
src/Media/ArtistCollection.cs \
296+
src/Media/Genre.cs \
297+
src/Media/GenreCollection.cs \
298+
src/Media/MediaLibrary.cs \
292299
src/Media/MediaPlayer.cs \
293300
src/Media/MediaQueue.cs \
301+
src/Media/MediaSource.cs \
302+
src/Media/MediaSourceType.cs \
294303
src/Media/MediaState.cs \
304+
src/Media/Picture.cs \
305+
src/Media/PictureAlbum.cs \
306+
src/Media/PictureAlbumCollection.cs \
307+
src/Media/PictureCollection.cs \
308+
src/Media/Playlist.cs \
309+
src/Media/PlaylistCollection.cs \
295310
src/Media/Song.cs \
296311
src/Media/SongCollection.cs \
297312
src/Media/VideoSoundtrackType.cs \

abi/Microsoft.Xna.Framework.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Content.ContentTypeReader))]
1616
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Content.ContentTypeReader<int>))]
1717
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.FrameworkDispatcher))]
18-
#if TODO_MEDIASTUB
1918
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.MediaLibrary))]
2019
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.MediaSourceType))]
2120
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.MediaSource))]
22-
#endif
2321
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.VisualizationData))]
2422
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.TitleContainer))]
2523
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Audio.MicrophoneState))]
@@ -29,24 +27,20 @@
2927
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Audio.SoundState))]
3028
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Audio.SoundEffectInstance))]
3129
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Audio.DynamicSoundEffectInstance))]
32-
#if TODO_MEDIASTUB
3330
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.Album))]
3431
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.AlbumCollection))]
3532
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.Artist))]
3633
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.ArtistCollection))]
3734
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.Genre))]
3835
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.GenreCollection))]
39-
#endif
4036
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.MediaPlayer))]
4137
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.MediaQueue))]
42-
#if TODO_MEDIASTUB
4338
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.Picture))]
4439
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.PictureAlbum))]
4540
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.PictureAlbumCollection))]
4641
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.PictureCollection))]
4742
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.Playlist))]
4843
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.PlaylistCollection))]
49-
#endif
5044
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.Song))]
5145
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Media.SongCollection))]
5246
[assembly: TypeForwardedToAttribute(typeof(Microsoft.Xna.Framework.Content.ContentReader))]

src/Graphics/GraphicsDevice.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ protected virtual void Dispose(bool disposing)
505505
{
506506
if (!IsDisposed)
507507
{
508+
IsDisposed = true;
509+
508510
if (disposing)
509511
{
510512
// We're about to dispose, notify the application.
@@ -518,15 +520,22 @@ protected virtual void Dispose(bool disposing)
518520
*/
519521
lock (resourcesLock)
520522
{
521-
foreach (GCHandle resource in resources.ToArray())
523+
/* NOTE: It is very important to make a copy of the resource handles and then clear
524+
* the array. This enables RemoveResourceReference to identify whether the handle
525+
* has already been disposed or not, to prevent us from freeing a given handle twice.
526+
* Freeing a GCHandle twice is very bad, and GCHandle.IsAllocated is not accurate once
527+
* you make a copy of the handle.
528+
*/
529+
GCHandle[] resourceArray = resources.ToArray();
530+
resources.Clear();
531+
foreach (GCHandle resource in resourceArray)
522532
{
523533
object target = resource.Target;
524534
if (target != null)
525535
{
526536
(target as IDisposable).Dispose();
527537
}
528538
}
529-
resources.Clear();
530539
}
531540

532541
if (userVertexBuffer != IntPtr.Zero)
@@ -549,8 +558,6 @@ protected virtual void Dispose(bool disposing)
549558
// Dispose of the GL Device/Context
550559
FNA3D.FNA3D_DestroyDevice(GLDevice);
551560
}
552-
553-
IsDisposed = true;
554561
}
555562
}
556563

@@ -566,7 +573,9 @@ internal void AddResourceReference(GCHandle resourceReference)
566573
}
567574
}
568575

569-
internal void RemoveResourceReference(GCHandle resourceReference)
576+
/// <param name="resourceReference">The GCHandle for your resource</param>
577+
/// <returns>true if you should Free your GCHandle</returns>
578+
internal bool RemoveResourceReference(GCHandle resourceReference)
570579
{
571580
lock (resourcesLock)
572581
{
@@ -579,9 +588,12 @@ internal void RemoveResourceReference(GCHandle resourceReference)
579588
// Perform an unordered removal, the order of items in this list does not matter
580589
resources[i] = resources[resources.Count - 1];
581590
resources.RemoveAt(resources.Count - 1);
582-
return;
591+
return true;
583592
}
584593
}
594+
595+
// The GCHandle was already freed, most likely by GraphicsDevice.Dispose
596+
return false;
585597
}
586598

587599
#endregion

src/Graphics/GraphicsResource.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ internal set
3939
*/
4040
if (graphicsDevice != null && selfReference.IsAllocated)
4141
{
42-
graphicsDevice.RemoveResourceReference(selfReference);
43-
selfReference.Free();
42+
if (graphicsDevice.RemoveResourceReference(selfReference))
43+
{
44+
selfReference.Free();
45+
}
4446
}
4547

4648
graphicsDevice = value;
@@ -191,8 +193,10 @@ protected virtual void Dispose(bool disposing)
191193
// Remove from the list of graphics resources
192194
if (graphicsDevice != null && selfReference.IsAllocated)
193195
{
194-
graphicsDevice.RemoveResourceReference(selfReference);
195-
selfReference.Free();
196+
if (graphicsDevice.RemoveResourceReference(selfReference))
197+
{
198+
selfReference.Free();
199+
}
196200
}
197201

198202
IsDisposed = true;

0 commit comments

Comments
 (0)