[xiph-commits] r2880 - liboggplay/trunk/plugin

laser13 at svn.annodex.net laser13 at svn.annodex.net
Fri Jun 8 01:31:05 PDT 2007


Author: laser13
Date: 2007-06-08 01:31:05 -0700 (Fri, 08 Jun 2007)
New Revision: 2880

Added:
   liboggplay/trunk/plugin/plugin_playlist.c
   liboggplay/trunk/plugin/plugin_playlist.h
Log:
Add playlist files with changed names according to the plugin naming conventions.

Added: liboggplay/trunk/plugin/plugin_playlist.c
===================================================================
--- liboggplay/trunk/plugin/plugin_playlist.c	                        (rev 0)
+++ liboggplay/trunk/plugin/plugin_playlist.c	2007-06-08 08:31:05 UTC (rev 2880)
@@ -0,0 +1,154 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * CSIRO
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Marcin Lubonski
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */    
+
+
+#include "playlist.h"
+
+
+/**
+ * Private functions for management of list elements 
+ */
+void 
+shift_up(PluginPlaylist *playlist, unsigned int start_pos, unsigned int end_pos) {
+  unsigned int i, j;  
+  if (playlist->data == NULL) 
+    return;    
+  
+  if ((start_pos < 1) || (end_pos > playlist->length))
+    return;
+
+  for (j = 0, i = end_pos - 1; j < end_pos - start_pos; i--, j++) {       
+      playlist->data[i] = playlist->data[i - 1];        
+  } 
+}
+
+void 
+shift_down(PluginPlaylist *playlist, unsigned int start_pos, unsigned int end_pos) {
+  unsigned int i, j;
+  if (playlist->data == NULL) 
+    return;    
+  
+  if ((start_pos < 1) || (end_pos > playlist->length))
+    return;
+
+  for (j = 0, i = start_pos - 1; j <  end_pos - start_pos; j++, i++) {       
+      playlist->data[i] = playlist->data[i + 1];    
+  }
+}
+
+/**
+ * Playlist public interface
+ */
+void 
+init(PluginPlaylist *playlist) {
+  playlist->data = NULL;
+  playlist->length = 0;
+}
+
+/*
+ * \brief - Append new element at the end of the list
+ */
+void 
+append(PluginPlaylist * playlist, void * elem) {  
+  
+  if (playlist->data == NULL) {
+    playlist->data = (void**)malloc(sizeof(void*));
+    playlist->length = 1;
+  } 
+  else 
+  {    
+    playlist->data = realloc(playlist->data, (playlist->length + 1) * sizeof(void *));   
+    playlist->length += 1;
+  }
+  
+  playlist->data[playlist->length-1] = elem;
+  return;
+}
+/*
+ * \brief - Add new element at position list_pos
+ */
+void 
+insert_at(PluginPlaylist*  playlist, void * elem, unsigned int list_pos) {    
+
+    if (playlist->data == NULL) {
+        if (list_pos > 1) 
+                return;
+        playlist->data = (void **)malloc(sizeof(void *));
+        playlist->length = 1;        
+    } else {
+        if (list_pos > playlist->length + 1)
+                return;        
+        playlist->data = realloc(playlist->data, (playlist->length + 1) * sizeof(void *));
+        playlist->length += 1;
+    }
+    
+    if (playlist->length > 1) {      
+      // if the existing element require shifting up
+      if (list_pos < playlist->length) {                
+        shift_up(playlist, list_pos, playlist->length);        
+      }
+    }
+    playlist->data[list_pos-1] = elem;
+    return;
+}
+
+/*
+ * \brief Removes element of the playlist
+ */
+void 
+remove_at(PluginPlaylist*  playlist, unsigned int list_pos) {  
+
+  if (playlist->data == NULL)
+    return;
+
+  if ((list_pos <= 0) || (list_pos > playlist->length))
+    return;
+    
+  shift_down(playlist, list_pos, playlist->length);  
+  playlist->data = realloc(playlist->data, (playlist->length - 1) * sizeof(void *));
+  playlist->length -= 1;
+  
+  return;
+}
+
+void 
+show(PluginPlaylist* playlist) {
+  unsigned int i;
+  if (playlist != NULL) {
+   for (i = 0; i < playlist->length; i++) {
+     printf("Playlist entry [%d] is : %s\n", i + 1, playlist->data[i]);
+   }
+  }
+  return;
+}

Added: liboggplay/trunk/plugin/plugin_playlist.h
===================================================================
--- liboggplay/trunk/plugin/plugin_playlist.h	                        (rev 0)
+++ liboggplay/trunk/plugin/plugin_playlist.h	2007-06-08 08:31:05 UTC (rev 2880)
@@ -0,0 +1,63 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * CSIRO
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Shane Stephens, Michael Martin
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */  
+
+#ifndef __PLUGIN_PLAYLIST__
+#define __PLUGIN_PLAYLIST__
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define PLAYLIST_ELEM_TYPE char*
+
+typedef struct {
+  void ** data;
+  unsigned int length;
+} PluginPlaylist;
+
+void
+init(PluginPlaylist * playlist);
+
+void 
+append(PluginPlaylist * playlist, void * elem);
+
+void 
+insert_at(PluginPlaylist*  playlist, void * elem, unsigned int list_pos);
+
+void 
+remove_at(PluginPlaylist*  playlist, unsigned int list_pos);
+
+void 
+show(PluginPlaylist* playlist);
+
+#endif //__PLUGIN_PLAYLIST__
\ No newline at end of file



More information about the commits mailing list