Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[src] Added manual binding to prevent issue of AVAudioPlayer FromData() and FromUrl() throwing exceptions. #17073

Merged
Merged
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9659ccb
Added try catches to the methods in AVAudioPlayer to prevent Initiali…
dustin-wojciechowski Dec 15, 2022
6008753
Merge branch 'main' into avaudioplayer-fix
dustin-wojciechowski Dec 15, 2022
8d98a51
Auto-format source code
Dec 15, 2022
2caef79
Addressed PR comments. Removed bindings from avfoundation and directl…
dustin-wojciechowski Dec 20, 2022
afcd369
Added tests for AudioPlayer.
dustin-wojciechowski Dec 20, 2022
2aa364f
Auto-format source code
Dec 20, 2022
fdca982
Changed last argument in objc_msgSend to a pointer
dustin-wojciechowski Dec 20, 2022
160ed23
Fixed compilation issue with AVAudioPlayerTest
dustin-wojciechowski Dec 21, 2022
b8acdd5
Merge branch 'main' into avaudioplayer-fix
dustin-wojciechowski Dec 21, 2022
cac48e4
Auto-format source code
Dec 21, 2022
8a2f421
Merge branch 'main' into avaudioplayer-fix
dustin-wojciechowski Jan 4, 2023
8dc762e
Merge branch 'main' into avaudioplayer-fix
dustin-wojciechowski Jan 5, 2023
87cc605
Merge branch 'main' into avaudioplayer-fix
dustin-wojciechowski Jan 12, 2023
969cf22
Added Xtro errors for this issue to AVFoundation.ignore files
dustin-wojciechowski Jan 18, 2023
faa084b
Merge branch 'main' into avaudioplayer-fix
dustin-wojciechowski Jan 18, 2023
155a556
Fixed two tests
dustin-wojciechowski Jan 19, 2023
cb41958
Merge branch 'main' into avaudioplayer-fix
dustin-wojciechowski Jan 19, 2023
37c3e7f
Modified comment in .ignore files to indicate binding was done manually
dustin-wojciechowski Jan 20, 2023
f8a490c
Merge branch 'main' into avaudioplayer-fix
dustin-wojciechowski Jan 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 38 additions & 18 deletions src/AVFoundation/AVAudioPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,34 @@ public partial class AVAudioPlayer {
IntPtr errhandle;
IntPtr ptrtohandle = (IntPtr) (&errhandle);

var ap = new AVAudioPlayer (url, ptrtohandle);
dustin-wojciechowski marked this conversation as resolved.
Show resolved Hide resolved
if (ap.Handle == IntPtr.Zero) {
try {
var ap = new AVAudioPlayer (url, ptrtohandle);
if (ap.Handle == IntPtr.Zero) {
error = Runtime.GetNSObject<NSError> (errhandle);
return null;
} else
error = null;

return ap;
} catch {
error = Runtime.GetNSObject<NSError> (errhandle);
return null;
} else
error = null;
return ap;
}
}
}

public static AVAudioPlayer? FromUrl (NSUrl url)
{
unsafe {
dustin-wojciechowski marked this conversation as resolved.
Show resolved Hide resolved
var ap = new AVAudioPlayer (url, IntPtr.Zero);
if (ap.Handle == IntPtr.Zero)
return null;
try {
var ap = new AVAudioPlayer (url, IntPtr.Zero);
if (ap.Handle == IntPtr.Zero)
return null;

return ap;
return ap;
} catch {
return null;
}
}
}

Expand All @@ -65,24 +75,34 @@ public partial class AVAudioPlayer {
IntPtr errhandle;
IntPtr ptrtohandle = (IntPtr) (&errhandle);

var ap = new AVAudioPlayer (data, ptrtohandle);
dustin-wojciechowski marked this conversation as resolved.
Show resolved Hide resolved
if (ap.Handle == IntPtr.Zero) {
try {
var ap = new AVAudioPlayer (data, ptrtohandle);
if (ap.Handle == IntPtr.Zero) {
error = Runtime.GetNSObject<NSError> (errhandle);
return null;
} else
error = null;

return ap;
} catch {
error = Runtime.GetNSObject<NSError> (errhandle);
return null;
} else
error = null;
return ap;
}
}
}

public static AVAudioPlayer? FromData (NSData data)
{
unsafe {
dustin-wojciechowski marked this conversation as resolved.
Show resolved Hide resolved
var ap = new AVAudioPlayer (data, IntPtr.Zero);
if (ap.Handle == IntPtr.Zero)
return null;
try {
var ap = new AVAudioPlayer (data, IntPtr.Zero);
if (ap.Handle == IntPtr.Zero)
return null;

return ap;
return ap;
} catch {
return null;
}
}
}
}
Expand Down