diff options
author | Nick Kallen <nickkallen@me.com> | 2017-02-03 14:46:39 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-03-07 13:37:07 +0200 |
commit | 46bbc60d24c1914380b4145fa8595aa2e958c7dc (patch) | |
tree | 85c98124552b6638d63b554a950c352c4003c573 /tests | |
parent | 201e71c3aacd4c61771fd6ac20dc39e43e42bb0c (diff) | |
download | gstreamer-plugins-bad-46bbc60d24c1914380b4145fa8595aa2e958c7dc.tar.gz |
applemedia/gl: Update code to use ARC
All code interacting with Objective-C objects should now use Automated
Reference Counting rather than manual memory management or Garbage
Collection. Because ARC prohibits C-structs from containing
references to Objective-C objects, all such fields are now typed
'gpointer'. Setting and gettings Objective-C fields on such a
struct now uses explicit __bridge_* calls to tell ARC about
object lifetimes.
https://bugzilla.gnome.org/show_bug.cgi?id=777847
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/examples/gl/cocoa/Makefile.am | 1 | ||||
-rwxr-xr-x | tests/examples/gl/cocoa/cocoa-videooverlay.m | 21 |
2 files changed, 7 insertions, 15 deletions
diff --git a/tests/examples/gl/cocoa/Makefile.am b/tests/examples/gl/cocoa/Makefile.am index 36905469f..9148f8a4a 100755 --- a/tests/examples/gl/cocoa/Makefile.am +++ b/tests/examples/gl/cocoa/Makefile.am @@ -5,6 +5,7 @@ noinst_PROGRAMS = cocoa-videooverlay cocoa_videooverlay_SOURCES = cocoa-videooverlay.m cocoa_videooverlay_OBJCFLAGS=-Wno-error=unused-command-line-argument \ + -fobjc-arc \ -I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \ $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \ $(GL_CFLAGS) $(GL_OBJCFLAGS) diff --git a/tests/examples/gl/cocoa/cocoa-videooverlay.m b/tests/examples/gl/cocoa/cocoa-videooverlay.m index a783c5672..cc209d83d 100755 --- a/tests/examples/gl/cocoa/cocoa-videooverlay.m +++ b/tests/examples/gl/cocoa/cocoa-videooverlay.m @@ -121,8 +121,6 @@ static GstBusSyncReply create_window (GstBus* bus, GstMessage* message, MainWind static void end_stream_cb(GstBus* bus, GstMessage* message, MainWindow* window) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - g_print ("end of stream\n"); gst_element_set_state ([window pipeline], GST_STATE_NULL); @@ -130,8 +128,6 @@ static void end_stream_cb(GstBus* bus, GstMessage* message, MainWindow* window) g_main_loop_quit ([window loop]); [window performSelectorOnMainThread:@selector(customClose) withObject:nil waitUntilDone:YES]; - - [pool release]; } static gpointer thread_func (MainWindow* window) @@ -162,11 +158,9 @@ int main(int argc, char **argv) gboolean ok=FALSE; GstBus *bus=NULL; GThread *loop_thread=NULL; - NSAutoreleasePool *pool=nil; NSRect rect; MainWindow *window=nil; - pool = [[NSAutoreleasePool alloc] init]; [NSApplication sharedApplication]; g_print("app created\n"); @@ -202,14 +196,15 @@ int main(int argc, char **argv) bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_bus_add_signal_watch (bus); - g_signal_connect(bus, "message::error", G_CALLBACK(end_stream_cb), window); - g_signal_connect(bus, "message::warning", G_CALLBACK(end_stream_cb), window); - g_signal_connect(bus, "message::eos", G_CALLBACK(end_stream_cb), window); - gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, window, NULL); + /* NOTE: window is not bridge_retained because its lifetime is just this function */ + g_signal_connect(bus, "message::error", G_CALLBACK(end_stream_cb), (__bridge gpointer)window); + g_signal_connect(bus, "message::warning", G_CALLBACK(end_stream_cb), (__bridge gpointer)window); + g_signal_connect(bus, "message::eos", G_CALLBACK(end_stream_cb), (__bridge gpointer)window); + gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, (__bridge gpointer)window, NULL); gst_object_unref (bus); loop_thread = g_thread_new (NULL, - (GThreadFunc) thread_func, window); + (GThreadFunc) thread_func, (__bridge gpointer)window); gst_element_set_state (pipeline, GST_STATE_PLAYING); @@ -225,9 +220,5 @@ int main(int argc, char **argv) g_thread_join (loop_thread); - [window release]; - - [pool release]; - return 0; } |