[svn r352] - Fixed memory leak on gmyth_vlc.c (command send) trunk
authormorphbr
Sat Feb 10 21:53:40 2007 +0000 (2007-02-10)
branchtrunk
changeset 350ff82d527d26a
parent 349 7005e696052c
child 351 c331f4639111
[svn r352] - Fixed memory leak on gmyth_vlc.c (command send)
gmyth/src/gmyth_vlc.c
gmyth/src/gmyth_vlc.h
gmyth/tests/gmyth_test_vlc.c
     1.1 --- a/gmyth/src/gmyth_vlc.c	Sat Feb 10 20:01:54 2007 +0000
     1.2 +++ b/gmyth/src/gmyth_vlc.c	Sat Feb 10 21:53:40 2007 +0000
     1.3 @@ -45,9 +45,9 @@
     1.4   */
     1.5  int socket_send(int socket, gchar* msg)
     1.6  {  
     1.7 -    size_t size = strlen(msg) + 1;
     1.8 +  size_t size = strlen(msg) + 2; // (\n + \0)
     1.9      gchar* final = (gchar *)g_malloc0(sizeof(gchar) * size);
    1.10 -    g_snprintf(final, size+1, "%s\n", msg);
    1.11 +    g_snprintf(final, size, "%s\n", msg);
    1.12  
    1.13      if (send(socket, final, strlen(final), 0) == -1)
    1.14        perror("GMyth_VLC: send error");
    1.15 @@ -163,7 +163,7 @@
    1.16   * @return 0 if success
    1.17   */
    1.18  int gmyth_vlc_create_channel(GMythVlc *vlc, gchar* type,\
    1.19 -                             int port)
    1.20 +                             int port, int vcodec)
    1.21  {
    1.22      int ret;
    1.23      size_t size = 40;
    1.24 @@ -182,16 +182,26 @@
    1.25        size = 256;
    1.26        msg = (gchar *)g_malloc0(sizeof(gchar) * size);
    1.27  
    1.28 -      // Best transcode option for N800
    1.29 -      g_snprintf(msg, size, "#transcode{vcodec=mp1v,vb=384,"
    1.30 -                            "fps=25.0,scale=0.5,acodec=mpga,"
    1.31 -                            "ab=64,channels=1}:duplicate{dst="
    1.32 -                            "std{access=http,mux=mpeg1,dst="
    1.33 -                            ":%d}}", port);
    1.34 +      if ( vcodec == MPEG1 )
    1.35 +
    1.36 +        // Best transcode option for N800 (MP1V)
    1.37 +        g_snprintf(msg, size, "#transcode{vcodec=mp1v,vb=384,"
    1.38 +                              "fps=25.0,scale=1,acodec=mpga,"
    1.39 +                              "ab=64,channels=1}:duplicate{dst="
    1.40 +                              "std{access=http,mux=mpeg1,dst="
    1.41 +                              ":%d}}", port);
    1.42 +      else
    1.43 +
    1.44 +        // Best transcode option for N800 (THEORA)
    1.45 +        g_snprintf(msg, size, "#transcode{vcodec=theo,vb=384,"
    1.46 +                              "fps=25.0,scale=1,acodec=vorb,"
    1.47 +                              "ab=64,channels=1}:duplicate{dst="
    1.48 +                              "std{access=http,mux=ogg,dst="
    1.49 +                              ":%d}}", port);
    1.50  
    1.51        ret = gmyth_vlc_setup_output(vlc, vlc->n_outputs, "output", \
    1.52                                     msg);
    1.53 -
    1.54 +      
    1.55        vlc->n_outputs++;
    1.56      }
    1.57  
     2.1 --- a/gmyth/src/gmyth_vlc.h	Sat Feb 10 20:01:54 2007 +0000
     2.2 +++ b/gmyth/src/gmyth_vlc.h	Sat Feb 10 21:53:40 2007 +0000
     2.3 @@ -50,6 +50,10 @@
     2.4  #define VLC_TELNET_PORT 4212
     2.5  #define BUFFER 512
     2.6  
     2.7 +#define MPEG1 0
     2.8 +#define THEORA 1
     2.9 +
    2.10 +
    2.11  typedef struct _GMythVlc GMythVlc;
    2.12  
    2.13  struct _GMythVlc
    2.14 @@ -85,7 +89,7 @@
    2.15                             gchar* file);
    2.16  
    2.17  int gmyth_vlc_create_channel(GMythVlc *vlc, gchar* type,\
    2.18 -                             int port);
    2.19 +                             int port, int vcodec);
    2.20  
    2.21  int gmyth_vlc_connect(GMythVlc *vlc, GMythBackendInfo *backend_info,\
    2.22                        gchar* passwd, int port);
     3.1 --- a/gmyth/tests/gmyth_test_vlc.c	Sat Feb 10 20:01:54 2007 +0000
     3.2 +++ b/gmyth/tests/gmyth_test_vlc.c	Sat Feb 10 21:53:40 2007 +0000
     3.3 @@ -22,7 +22,7 @@
     3.4      
     3.5      if ( res >= 0 )
     3.6      {
     3.7 -    	gmyth_vlc_create_channel(&vlc, "broadcast", 8080);
     3.8 +    	gmyth_vlc_create_channel(&vlc, "broadcast", 8080, THEORA);
     3.9          gmyth_vlc_create_input(&vlc, 0, "/tmp/grande.nuv");
    3.10          gmyth_vlc_control_input(&vlc, 0, "play");
    3.11          gmyth_vlc_disconnect(&vlc);