summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNick Kallen <nickkallen@me.com>2017-02-03 14:46:39 +0100
committerTim-Philipp Müller <tim@centricular.com>2017-12-09 19:32:27 +0000
commit7b42f26b80acdef7f28bded92e55b1d070286583 (patch)
treedc6fe64145170be7410ffb2afe77c46e0092cc2c /tests
parentee49afed974620b15b6886b73dff13e1a947a63a (diff)
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-xtests/examples/gl/cocoa/Makefile.am1
-rwxr-xr-xtests/examples/gl/cocoa/cocoa-videooverlay.m21
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;
}