]> git.sesse.net Git - vlc/blobdiff - test/libvlc/meta.c
macosx: Fix a memleak.
[vlc] / test / libvlc / meta.c
index bf972ba06f60bfe5a5e6db1dceccaf34e5365baa..f2e5963d9291a18eaac06ebd64d4a0f098227bd7 100644 (file)
@@ -6,6 +6,7 @@
 
 /**********************************************************************
  *  Copyright (C) 2007 RĂ©mi Denis-Courmont.                           *
+ *  Copyright (C) 2008 Pierre d'Herbemont.                            *
  *  This program is free software; you can redistribute and/or modify *
  *  it under the terms of the GNU General Public License as published *
  *  by the Free Software Foundation; version 2 of the license, or (at *
@@ -35,23 +36,37 @@ static void test_meta (const char ** argv, int argc)
     vlc = libvlc_new (argc, argv, &ex);
     catch ();
 
-    media = libvlc_media_new ( vlc, "samples/meta.sample", &ex);
+    media = libvlc_media_new (vlc, "samples/meta.sample", &ex);
+    catch ();
 
-    /* Tell that we are interested in this precise meta data */
-    artist = libvlc_media_get_meta( media, libvlc_meta_Artist, &ex );
+    /* Tell that we are interested in this precise meta data
+     * This is needed to trigger meta data reading
+     * (the first calls return NULL) */
+    artist = libvlc_media_get_meta (media, libvlc_meta_Artist, &ex);
     catch ();
 
     free (artist);
 
     /* Wait for the meta */
-    while (!libvlc_media_is_preparsed(media, &ex)) { catch (); msleep (10000); }
+    while (!libvlc_media_is_preparsed (media, &ex))
+    {
+        catch ();
+        msleep (10000);
+    }
 
-    artist = libvlc_media_get_meta( media, libvlc_meta_Artist, &ex );
+    artist = libvlc_media_get_meta (media, libvlc_meta_Artist, &ex);
     catch ();
 
+    const char *expected_artist = "mike";
+
     assert (artist);
+    log ("+ got '%s' as Artist, expecting %s\n", artist, expected_artist);
+
+    int string_compare = strcmp (artist, expected_artist);
+    assert (!string_compare);
 
     free (artist);
+    libvlc_media_release (media);
     libvlc_release (vlc);
 }