Author: gkovacs
Date: Tue Aug 25 10:23:19 2009
New Revision: 5269

Log:
change av_playlist_from_filelist to av_playlist_add_filelist and allocate 
AVPlaylistContext externally

Modified:
   concat/libavformat/avplaylist.c
   concat/libavformat/avplaylist.h
   concat/libavformat/m3u.c
   concat/libavformat/pls.c
   concat/libavformat/xspf.c

Modified: concat/libavformat/avplaylist.c
==============================================================================
--- concat/libavformat/avplaylist.c     Tue Aug 25 09:56:58 2009        (r5268)
+++ concat/libavformat/avplaylist.c     Tue Aug 25 10:23:19 2009        (r5269)
@@ -126,13 +126,13 @@ AVPlaylistContext *av_playlist_get_conte
 
 AVFormatContext *av_playlist_formatcontext_from_filelist(const char **flist, 
int len)
 {
-    AVPlaylistContext *ctx;
     AVFormatContext *ic;
-    ctx = av_playlist_from_filelist(flist, len);
+    AVPlaylistContext *ctx = av_mallocz(sizeof(*ctx));
     if (!ctx) {
-        av_log(NULL, AV_LOG_ERROR, "failed to create AVPlaylistContext in 
av_playlist_formatcontext_from_filelist\n");
+        av_log(NULL, AV_LOG_ERROR, "failed to allocate AVPlaylistContext in 
av_playlist_formatcontext_from_filelist\n");
         return NULL;
     }
+    av_playlist_add_filelist(ctx, flist, len);
     ic = avformat_alloc_context();
     ic->iformat = ff_concat_alloc_demuxer();
     ic->priv_data = ctx;
@@ -190,18 +190,15 @@ int av_playlist_split_encodedstring(cons
     av_free(sepidx);
 }
 
-AVPlaylistContext *av_playlist_from_filelist(const char **flist, int len)
+int av_playlist_add_filelist(AVPlaylistContext *ctx, const char **flist, int 
len)
 {
-    int i;
-    AVPlaylistContext *ctx;
-    ctx = av_mallocz(sizeof(*ctx));
-    if (!ctx) {
-        av_log(NULL, AV_LOG_ERROR, "av_mallocz error in 
av_playlist_from_filelist\n");
-        return NULL;
+    int i, err;
+    for (i = 0; i < len; ++i) {
+        err = av_playlist_add_path(ctx, flist[i]);
+        if (err)
+            return err;
     }
-    for (i = 0; i < len; ++i)
-        av_playlist_add_path(ctx, flist[i]);
-    return ctx;
+    return 0;
 }
 
 int av_playlist_add_path(AVPlaylistContext *ctx, const char *itempath)

Modified: concat/libavformat/avplaylist.h
==============================================================================
--- concat/libavformat/avplaylist.h     Tue Aug 25 09:56:58 2009        (r5268)
+++ concat/libavformat/avplaylist.h     Tue Aug 25 10:23:19 2009        (r5269)
@@ -101,12 +101,13 @@ int av_playlist_split_encodedstring(cons
                                     char ***flist_ptr,
                                     int *len_ptr);
 
-/** @brief Allocates and returns a AVPlaylistContext with playlist elements 
specified by a file list.
+/** @brief Adds playlist elements specified by a file list to a 
AVPlaylistContext.
+ *  @param ctx Pre-allocated AVPlaylistContext to add elements to.
  *  @param flist List of filenames from which to construct the playlist.
  *  @param len Length of filename list.
- *  @return Returns the allocated AVPlaylistContext.
+ *  @return Returns 0 upon success, or negative upon failure.
  */
-AVPlaylistContext *av_playlist_from_filelist(const char **flist, int len);
+int av_playlist_add_filelist(AVPlaylistContext *ctx, const char **flist, int 
len);
 
 /** @brief Creates and adds AVFormatContext for item located at specified path 
to a AVPlaylistContext.
  *  @param ctx Pre-allocated AVPlaylistContext to add elements to.

Modified: concat/libavformat/m3u.c
==============================================================================
--- concat/libavformat/m3u.c    Tue Aug 25 09:56:58 2009        (r5268)
+++ concat/libavformat/m3u.c    Tue Aug 25 10:23:19 2009        (r5269)
@@ -92,7 +92,12 @@ static int m3u_read_header(AVFormatConte
         return AVERROR_EOF;
     }
     av_playlist_relative_paths(flist, flist_len, dirname(s->filename));
-    ctx = av_playlist_from_filelist(flist, flist_len);
+    ctx = av_mallocz(sizeof(*ctx));
+    if (!ctx) {
+        av_log(NULL, AV_LOG_ERROR, "failed to allocate AVPlaylistContext in 
m3u_read_header\n");
+        return AVERROR_NOMEM;
+    }
+    av_playlist_add_filelist(ctx, flist, flist_len);
     av_free(flist);
     s->priv_data = ctx;
     av_playlist_populate_context(ctx, ctx->pe_curidx);

Modified: concat/libavformat/pls.c
==============================================================================
--- concat/libavformat/pls.c    Tue Aug 25 09:56:58 2009        (r5268)
+++ concat/libavformat/pls.c    Tue Aug 25 10:23:19 2009        (r5269)
@@ -111,7 +111,12 @@ static int pls_read_header(AVFormatConte
         return AVERROR_EOF;
     }
     av_playlist_relative_paths(flist, flist_len, dirname(s->filename));
-    ctx = av_playlist_from_filelist(flist, flist_len);
+    ctx = av_mallocz(sizeof(*ctx));
+    if (!ctx) {
+        av_log(NULL, AV_LOG_ERROR, "failed to allocate AVPlaylistContext in 
pls_read_header\n");
+        return AVERROR_NOMEM;
+    }
+    av_playlist_add_filelist(ctx, flist, flist_len);
     av_free(flist);
     s->priv_data = ctx;
     av_playlist_populate_context(ctx, ctx->pe_curidx);

Modified: concat/libavformat/xspf.c
==============================================================================
--- concat/libavformat/xspf.c   Tue Aug 25 09:56:58 2009        (r5268)
+++ concat/libavformat/xspf.c   Tue Aug 25 10:23:19 2009        (r5269)
@@ -134,7 +134,12 @@ static int xspf_read_header(AVFormatCont
         return AVERROR_EOF;
     }
     av_playlist_relative_paths(flist, flist_len, dirname(s->filename));
-    ctx = av_playlist_from_filelist(flist, flist_len);
+    ctx = av_mallocz(sizeof(*ctx));
+    if (!ctx) {
+        av_log(NULL, AV_LOG_ERROR, "failed to allocate AVPlaylistContext in 
xspf_read_header\n");
+        return AVERROR_NOMEM;
+    }
+    av_playlist_add_filelist(ctx, flist, flist_len);
     av_free(flist);
     s->priv_data = ctx;
     av_playlist_populate_context(ctx, ctx->pe_curidx);
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc

Reply via email to