Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

tvtime-1.0.2-full2.patch

By: a guest on May 29th, 2011  |  syntax: C  |  size: 69.14 KB  |  views: 152  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff -Nur tvtime-1.0.2/configure.ac tvtime-1.0.2-custom/configure.ac
  2. --- tvtime-1.0.2/configure.ac   2005-09-14 23:40:44.000000000 +0200
  3. +++ tvtime-1.0.2-custom/configure.ac    2011-05-29 18:44:24.911109352 +0200
  4. @@ -10,12 +10,7 @@
  5.  
  6.  # Check for compilers.
  7.  AC_PROG_CC
  8. -AC_CHECK_PROG(found_cc, "$CC", yes, no)
  9. -test "x$found_cc" = "xyes" || exit 1
  10. -
  11.  AC_PROG_CXX
  12. -AC_CHECK_PROG(found_cxx, "$CXX", yes, no)
  13. -test "x$found_cxx" = "xyes" || exit 1
  14.  
  15.  # Check for libtool.
  16.  AC_PROG_LIBTOOL
  17. @@ -74,18 +69,26 @@
  18.  dnl libxml2
  19.  dnl ---------------------------------------------
  20.  dnl Test for libxml2
  21. -
  22.  AC_PATH_PROG(LIBXML2_CONFIG,xml2-config,no)
  23.  if test "$LIBXML2_CONFIG" = "no" ; then
  24.         AC_MSG_ERROR(libxml2 needed and xml2-config not found)
  25.  else
  26.         XML2_LIBS="`$LIBXML2_CONFIG --libs`"
  27.         XML2_FLAG="`$LIBXML2_CONFIG --cflags`"
  28. -       AC_DEFINE(HAVE_LIBXML2,,[LIBXML2 support])     
  29. +       AC_DEFINE(HAVE_LIBXML2,,[LIBXML2 support])
  30.  fi
  31.  AC_SUBST(XML2_LIBS)
  32.  AC_SUBST(XML2_FLAG)
  33.  
  34. +dnl ---------------------------------------------
  35. +dnl libasound2
  36. +dnl ---------------------------------------------
  37. +dnl Test for ALSA
  38. +AM_PATH_ALSA(1.0.9,
  39. +       [ AC_DEFINE(HAVE_ALSA,1,[Define this if you have Alsa (libasound) installed]) ],
  40. +       AC_MSG_RESULT(libasound needed and not found))
  41. +AM_CONDITIONAL(HAVE_ALSA, test x"$no_alsa" != "yes")
  42. +
  43.  
  44.  dnl ---------------------------------------------
  45.  dnl check for gtk+-2.0
  46. @@ -99,6 +102,8 @@
  47.  dnl check for X11, Xv and XF86VidModeExtension
  48.  dnl ---------------------------------------------
  49.  AC_PATH_XTRA
  50. +AC_ARG_WITH([xinerama],
  51. +    [AS_HELP_STRING([--without-xinerama], [Disable Xinerama extension support (default: check)])])
  52.  if test x"$no_x" != x"yes"; then
  53.      dnl check for Xshm
  54.      AC_CHECK_LIB([Xext],[XShmCreateImage],
  55. @@ -112,16 +117,18 @@
  56.             X11_LIBS="$X11_LIBS -lXv"],,
  57.             [$X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS -lXext])
  58.  
  59. -       dnl check for Xinerama
  60. -       AC_CHECK_LIB([Xinerama],[XineramaQueryScreens],
  61. -           [AC_DEFINE([HAVE_XINERAMA],,[Xinerama support])
  62. -           X11_LIBS="$X11_LIBS -lXinerama"],,
  63. -           [$X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS -lXext])
  64. -
  65. -       dnl check for XTest
  66. -        AC_CHECK_LIB([Xtst],[XTestFakeKeyEvent],
  67. -            [AC_DEFINE([HAVE_XTESTEXTENSION],,[XTest support])
  68. -            X11_LIBS="$X11_LIBS -lXtst"],,
  69. +       if test "x$with_xinerama" != "xno"; then
  70. +               dnl check for Xinerama
  71. +               AC_CHECK_LIB([Xinerama],[XineramaQueryScreens],
  72. +                   [AC_DEFINE([HAVE_XINERAMA],,[Xinerama support])
  73. +                   X11_LIBS="$X11_LIBS -lXinerama"],,
  74. +                   [$X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS -lXext])
  75. +       fi
  76. +
  77. +       dnl check for XSs
  78. +        AC_CHECK_LIB([Xss],[XScreenSaverSuspend],
  79. +            [AC_DEFINE([HAVE_XSSEXTENSION],,[XSs support])
  80. +            X11_LIBS="$X11_LIBS -lXss"],,
  81.             [$X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS -lXext])
  82.  
  83.         dnl check for Xvidmode
  84. diff -Nur tvtime-1.0.2/docs/html/default.tvtime.xml tvtime-1.0.2-custom/docs/html/default.tvtime.xml
  85. --- tvtime-1.0.2/docs/html/default.tvtime.xml   2005-09-08 06:06:57.000000000 +0200
  86. +++ tvtime-1.0.2-custom/docs/html/default.tvtime.xml    2011-05-29 18:44:24.914442692 +0200
  87. @@ -116,13 +116,15 @@
  88.    <option name="VBIDevice" value="/dev/vbi0"/>
  89.  
  90.    <!--
  91. -    This sets the mixer device and channel to use.  The format is device
  92. -    name:channel name.  Valid channels are:
  93. +    This sets the mixer device and channel to use.  The format for OSS
  94. +    is device name:channel name.  Valid OSS channels are:
  95.        vol, bass, treble, synth, pcm, speaker, line, mic, cd, mix, pcm2,
  96.        rec, igain, ogain, line1, line2, line3, dig1, dig2, dig3, phin,
  97.        phout, video, radio, monitor
  98. +    The format for ALSA mixer is device/channel (e.g., "default/Line"
  99. +    or "hw:0/CD")
  100.     -->
  101. -  <option name="MixerDevice" value="/dev/mixer:line"/>
  102. +   <option name="MixerDevice" value="default/Line"/>
  103.  
  104.    <!--
  105.      This option enables 16:9 aspect ratio mode by default on startup.
  106. diff -Nur tvtime-1.0.2/docs/man/en/tvtime.xml.5 tvtime-1.0.2-custom/docs/man/en/tvtime.xml.5
  107. --- tvtime-1.0.2/docs/man/en/tvtime.xml.5       2005-09-08 06:05:35.000000000 +0200
  108. +++ tvtime-1.0.2-custom/docs/man/en/tvtime.xml.5        2011-05-29 18:44:24.914442692 +0200
  109. @@ -234,7 +234,10 @@
  110.  .TP
  111.  <option name="MixerDevice" value="/dev/mixer:line"/>
  112.  This sets the mixer device and channel to use.  The format is device
  113. -name:channel name.  Valid channels are:
  114. +name:channel name for OSS mixer (e.g., "/dev/mixer:Line") or device/channel
  115. +for ALSA (e.g., "hw:0/CD").
  116. +
  117. +Valid OSS channels are:
  118.  
  119.  .nh
  120.  .IR vol ", " bass ", " treble ", " synth ", " pcm ", " speaker ", "
  121. diff -Nur tvtime-1.0.2/plugins/greedyh.asm tvtime-1.0.2-custom/plugins/greedyh.asm
  122. --- tvtime-1.0.2/plugins/greedyh.asm    2005-08-14 18:16:43.000000000 +0200
  123. +++ tvtime-1.0.2-custom/plugins/greedyh.asm     2011-05-29 18:44:24.914442692 +0200
  124. @@ -18,7 +18,7 @@
  125.  
  126.  #include "x86-64_macros.inc"
  127.  
  128. -void DScalerFilterGreedyH::FUNCT_NAME(TDeinterlaceInfo* pInfo)
  129. +void FUNCT_NAME(TDeinterlaceInfo* pInfo)
  130.  {
  131.      int64_t i;
  132.      bool InfoIsOdd = (pInfo->PictureHistory[0]->Flags & PICTURE_INTERLACED_ODD) ? 1 : 0;
  133. diff -Nur tvtime-1.0.2/plugins/tomsmocomp/TomsMoCompAll2.inc tvtime-1.0.2-custom/plugins/tomsmocomp/TomsMoCompAll2.inc
  134. --- tvtime-1.0.2/plugins/tomsmocomp/TomsMoCompAll2.inc  2004-10-20 17:31:05.000000000 +0200
  135. +++ tvtime-1.0.2-custom/plugins/tomsmocomp/TomsMoCompAll2.inc   2011-05-29 18:44:24.917776032 +0200
  136. @@ -5,9 +5,9 @@
  137.  #endif
  138.  
  139.  #ifdef USE_STRANGE_BOB
  140. -#define SEARCH_EFFORT_FUNC(n) DScalerFilterTomsMoComp::SEFUNC(n##_SB)
  141. +#define SEARCH_EFFORT_FUNC(n) SEFUNC(n##_SB)
  142.  #else
  143. -#define SEARCH_EFFORT_FUNC(n) DScalerFilterTomsMoComp::SEFUNC(n)
  144. +#define SEARCH_EFFORT_FUNC(n) SEFUNC(n)
  145.  #endif
  146.  
  147.  int SEARCH_EFFORT_FUNC(0)              // we don't try at all ;-)
  148. diff -Nur tvtime-1.0.2/plugins/tomsmocomp.cpp tvtime-1.0.2-custom/plugins/tomsmocomp.cpp
  149. --- tvtime-1.0.2/plugins/tomsmocomp.cpp 2004-10-20 19:38:04.000000000 +0200
  150. +++ tvtime-1.0.2-custom/plugins/tomsmocomp.cpp  2011-05-29 18:44:24.917776032 +0200
  151. @@ -31,7 +31,7 @@
  152.  
  153.  #define IS_MMX
  154.  #define SSE_TYPE MMX
  155. -#define FUNCT_NAME DScalerFilterTomsMoComp::filterDScaler_MMX
  156. +#define FUNCT_NAME filterDScaler_MMX
  157.  #include "tomsmocomp/TomsMoCompAll.inc"
  158.  #undef  IS_MMX
  159.  #undef  SSE_TYPE
  160. @@ -39,7 +39,7 @@
  161.  
  162.  #define IS_3DNOW
  163.  #define SSE_TYPE 3DNOW
  164. -#define FUNCT_NAME DScalerFilterTomsMoComp::filterDScaler_3DNOW
  165. +#define FUNCT_NAME filterDScaler_3DNOW
  166.  #include "tomsmocomp/TomsMoCompAll.inc"
  167.  #undef  IS_3DNOW
  168.  #undef  SSE_TYPE
  169. @@ -47,7 +47,7 @@
  170.  
  171.  #define IS_SSE
  172.  #define SSE_TYPE SSE
  173. -#define FUNCT_NAME DScalerFilterTomsMoComp::filterDScaler_SSE
  174. +#define FUNCT_NAME filterDScaler_SSE
  175.  #include "tomsmocomp/TomsMoCompAll.inc"
  176.  #undef  IS_SSE
  177.  #undef  SSE_TYPE
  178. diff -Nur tvtime-1.0.2/src/commands.c tvtime-1.0.2-custom/src/commands.c
  179. --- tvtime-1.0.2/src/commands.c 2005-11-10 03:39:05.000000000 +0100
  180. +++ tvtime-1.0.2-custom/src/commands.c  2011-05-29 18:44:24.921109372 +0200
  181. @@ -128,6 +128,7 @@
  182.      int togglepulldowndetection;
  183.      int togglematte;
  184.      int togglequiet;
  185. +    int changedoverscan;
  186.      int framerate;
  187.      int scan_channels;
  188.      int pause;
  189. @@ -2900,7 +2901,7 @@
  190.      case TVTIME_OVERSCAN_DOWN:
  191.          cmd->overscan = cmd->overscan + ( (tvtime_cmd == TVTIME_OVERSCAN_UP) ? 0.0025 : -0.0025 );
  192.          if( cmd->overscan > 0.4 ) cmd->overscan = 0.4; if( cmd->overscan < 0.0 ) cmd->overscan = 0.0;
  193. -
  194. +        cmd->changedoverscan = 1;
  195.          if( cmd->osd ) {
  196.              char message[ 200 ];
  197.              snprintf( message, sizeof( message ), _("Overscan: %.1f%%"),
  198. @@ -3056,10 +3057,10 @@
  199.          break;
  200.  
  201.      case TVTIME_MIXER_TOGGLE_MUTE:
  202. -        mixer_mute( !mixer_ismute() );
  203. +        mixer->mute( !mixer->ismute() );
  204.  
  205.          if( cmd->osd ) {
  206. -            tvtime_osd_show_data_bar( cmd->osd, _("Volume"), (mixer_get_volume()) & 0xff );
  207. +            tvtime_osd_show_data_bar( cmd->osd, _("Volume"), (mixer->get_volume()) & 0xff );
  208.          }
  209.          break;
  210.  
  211. @@ -3073,9 +3074,9 @@
  212.          /* Check to see if an argument was passed, if so, use it. */
  213.          if (atoi(arg) > 0) {
  214.              int perc = atoi(arg);
  215. -            volume = mixer_set_volume( ( (tvtime_cmd == TVTIME_MIXER_UP) ? perc : -perc ) );
  216. +            volume = mixer->set_volume( ( (tvtime_cmd == TVTIME_MIXER_UP) ? perc : -perc ) );
  217.          } else {
  218. -            volume = mixer_set_volume( ( (tvtime_cmd == TVTIME_MIXER_UP) ? 1 : -1 ) );
  219. +            volume = mixer->set_volume( ( (tvtime_cmd == TVTIME_MIXER_UP) ? 1 : -1 ) );
  220.          }
  221.  
  222.          if( cmd->osd ) {
  223. @@ -3492,6 +3493,7 @@
  224.      cmd->togglepulldowndetection = 0;
  225.      cmd->togglematte = 0;
  226.      cmd->togglequiet = 0;
  227. +    cmd->changedoverscan = 0;
  228.      cmd->resizewindow = 0;
  229.      cmd->setdeinterlacer = 0;
  230.      cmd->setfreqtable = 0;
  231. @@ -3539,6 +3541,11 @@
  232.      return cmd->toggleaspect;
  233.  }
  234.  
  235. +int commands_get_changed_overscan( commands_t *cmd )
  236. +{
  237. +    return cmd->changedoverscan;
  238. +}
  239. +
  240.  int commands_toggle_alwaysontop( commands_t *cmd )
  241.  {
  242.      return cmd->togglealwaysontop;
  243. diff -Nur tvtime-1.0.2/src/commands.h tvtime-1.0.2-custom/src/commands.h
  244. --- tvtime-1.0.2/src/commands.h 2004-10-28 02:50:24.000000000 +0200
  245. +++ tvtime-1.0.2-custom/src/commands.h  2011-05-29 18:44:24.934442732 +0200
  246. @@ -64,6 +64,7 @@
  247.  int commands_quit( commands_t *cmd );
  248.  int commands_toggle_fullscreen( commands_t *cmd );
  249.  int commands_toggle_aspect( commands_t *cmd );
  250. +int commands_get_changed_overscan( commands_t *cmd );
  251.  int commands_toggle_deinterlacer( commands_t *cmd );
  252.  int commands_toggle_pulldown_detection( commands_t *cmd );
  253.  int commands_toggle_matte( commands_t *cmd );
  254. diff -Nur tvtime-1.0.2/src/cpu_accel.c tvtime-1.0.2-custom/src/cpu_accel.c
  255. --- tvtime-1.0.2/src/cpu_accel.c        2004-04-04 18:48:37.000000000 +0200
  256. +++ tvtime-1.0.2-custom/src/cpu_accel.c 2011-05-29 18:44:24.944442752 +0200
  257. @@ -35,7 +35,7 @@
  258.      int AMD;
  259.      uint32_t caps;
  260.  
  261. -#ifndef PIC
  262. +#if !defined(__PIC__) || defined(__x86_64__)
  263.  #define cpuid(op,eax,ebx,ecx,edx)      \
  264.      __asm__ ("cpuid"                   \
  265.              : "=a" (eax),              \
  266. diff -Nur tvtime-1.0.2/src/Makefile.am tvtime-1.0.2-custom/src/Makefile.am
  267. --- tvtime-1.0.2/src/Makefile.am        2005-02-08 06:00:16.000000000 +0100
  268. +++ tvtime-1.0.2-custom/src/Makefile.am 2011-05-29 18:44:24.944442752 +0200
  269. @@ -29,6 +29,11 @@
  270.         -DCONFDIR="\"$(pkgsysconfdir)\"" -DFIFODIR="\"$(tmpdir)\"" \
  271.         -D_LARGEFILE64_SOURCE -DLOCALEDIR="\"$(localedir)\""
  272.  
  273. +if HAVE_ALSA
  274. +ALSA_SRCS =    mixer-alsa.c
  275. +else
  276. +ALSA_SRCS =
  277. +endif
  278.  COMMON_SRCS = mixer.c videoinput.c rtctimer.c leetft.c osdtools.c tvtimeconf.c \
  279.         pngoutput.c tvtimeosd.c input.c cpu_accel.c speedy.c pnginput.c \
  280.         deinterlace.c videotools.c attributes.h deinterlace.h leetft.h \
  281. @@ -40,7 +45,7 @@
  282.         utils.h utils.c pulldown.h pulldown.c hashtable.h hashtable.c \
  283.         cpuinfo.h cpuinfo.c videodev.h videodev2.h menu.c menu.h \
  284.         outputfilter.h outputfilter.c xmltv.h xmltv.c gettext.h tvtimeglyphs.h \
  285. -       copyfunctions.h copyfunctions.c
  286. +       copyfunctions.h copyfunctions.c mixer-oss.c $(ALSA_SRCS)
  287.  
  288.  if ARCH_X86
  289.  DSCALER_SRCS = $(top_srcdir)/plugins/dscalerapi.h \
  290. @@ -74,10 +79,10 @@
  291.  
  292.  tvtime_SOURCES = $(COMMON_SRCS) $(OUTPUT_SRCS) $(PLUGIN_SRCS) tvtime.c
  293.  tvtime_CFLAGS = $(TTF_CFLAGS) $(PNG_CFLAGS) $(OPT_CFLAGS) \
  294. -       $(PLUGIN_CFLAGS) $(X11_CFLAGS) $(XML2_FLAG) \
  295. +       $(PLUGIN_CFLAGS) $(X11_CFLAGS) $(XML2_FLAG) $(ALSA_CFLAGS) \
  296.         $(FONT_CFLAGS) $(AM_CFLAGS)
  297.  tvtime_LDFLAGS  = $(TTF_LIBS) $(ZLIB_LIBS) $(PNG_LIBS) \
  298. -       $(X11_LIBS) $(XML2_LIBS) -lm -lstdc++
  299. +       $(X11_LIBS) $(XML2_LIBS) $(ALSA_LIBS) -lm -lsupc++
  300.  
  301.  tvtime_command_SOURCES = utils.h utils.c tvtimeconf.h tvtimeconf.c \
  302.         tvtime-command.c
  303. @@ -90,6 +95,6 @@
  304.  tvtime_scanner_SOURCES = utils.h utils.c videoinput.h videoinput.c \
  305.         tvtimeconf.h tvtimeconf.c station.h station.c tvtime-scanner.c \
  306.         mixer.h mixer.c
  307. -tvtime_scanner_CFLAGS = $(OPT_CFLAGS) $(XML2_FLAG) $(AM_CFLAGS)
  308. -tvtime_scanner_LDFLAGS  = $(ZLIB_LIBS) $(XML2_LIBS)
  309. +tvtime_scanner_CFLAGS = $(OPT_CFLAGS) $(XML2_FLAG) $(ALSA_CFLAGS) $(AM_CFLAGS)
  310. +tvtime_scanner_LDFLAGS  = $(ZLIB_LIBS) $(XML2_LIBS) $(ALSA_LIBS)
  311.  
  312. diff -Nur tvtime-1.0.2/src/mixer-alsa.c tvtime-1.0.2-custom/src/mixer-alsa.c
  313. --- tvtime-1.0.2/src/mixer-alsa.c       1970-01-01 01:00:00.000000000 +0100
  314. +++ tvtime-1.0.2-custom/src/mixer-alsa.c        2011-05-29 18:44:24.944442752 +0200
  315. @@ -0,0 +1,240 @@
  316. +/**
  317. + * Copyright (C) 2006 Philipp Hahn <pmhahn@users.sourceforge.net>
  318. + *
  319. + * This program is free software; you can redistribute it and/or modify
  320. + * it under the terms of the GNU General Public License as published by
  321. + * the Free Software Foundation; either version 2, or (at your option)
  322. + * any later version.
  323. + *
  324. + * This program is distributed in the hope that it will be useful,
  325. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  326. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  327. + * GNU General Public License for more details.
  328. + *
  329. + * You should have received a copy of the GNU General Public License
  330. + * along with this program; if not, write to the Free Software Foundation,
  331. + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  332. + */
  333. +
  334. +#include <stdio.h>
  335. +#include <sys/types.h>
  336. +#include <string.h>
  337. +#include <math.h>
  338. +#include <alsa/asoundlib.h>
  339. +#include "utils.h"
  340. +#include "mixer.h"
  341. +
  342. +static const char alsa_core_devnames[] = "default";
  343. +static char *card, *channel;
  344. +static int muted = 0;
  345. +static int mutecount = 0;
  346. +static snd_mixer_t *handle = NULL;
  347. +static snd_mixer_elem_t *elem = NULL;
  348. +
  349. +static long alsa_min, alsa_max, alsa_vol;
  350. +
  351. +static void alsa_open_mixer( void )
  352. +{
  353. +    int err;
  354. +    static snd_mixer_selem_id_t *sid = NULL;
  355. +    if ((err = snd_mixer_open (&handle, 0)) < 0) {
  356. +        fprintf(stderr, "mixer: open error: %s\n", snd_strerror(err));
  357. +        return;
  358. +    }
  359. +    if ((err = snd_mixer_attach (handle, card)) < 0) {
  360. +        fprintf(stderr, "mixer: attach error: %s\n", snd_strerror(err));
  361. +        goto error;
  362. +    }
  363. +    if ((err = snd_mixer_selem_register (handle, NULL, NULL)) < 0) {
  364. +        fprintf(stderr, "mixer: register error: %s\n", snd_strerror(err));
  365. +        goto error;
  366. +    }
  367. +    if ((err = snd_mixer_load (handle)) < 0) {
  368. +        fprintf(stderr, "mixer: load error: %s\n", snd_strerror(err));
  369. +        goto error;
  370. +    }
  371. +    snd_mixer_selem_id_malloc(&sid);
  372. +    if (sid == NULL)
  373. +        goto error;
  374. +    snd_mixer_selem_id_set_name(sid, channel);
  375. +    if (!(elem = snd_mixer_find_selem(handle, sid))) {
  376. +        fprintf(stderr, "mixer: find error: %s\n", snd_strerror(err));
  377. +        goto error;
  378. +    }
  379. +    if (!snd_mixer_selem_has_playback_volume(elem)) {
  380. +        fprintf(stderr, "mixer: no playback\n");
  381. +        goto error;
  382. +    }
  383. +    snd_mixer_selem_get_playback_volume_range(elem, &alsa_min, &alsa_max);
  384. +    if ((alsa_max - alsa_min) <= 0) {
  385. +        fprintf(stderr, "mixer: no valid playback range\n");
  386. +        goto error;
  387. +    }
  388. +    snd_mixer_selem_id_free(sid);
  389. +    return;
  390. +
  391. +error:
  392. +    if (sid)
  393. +        snd_mixer_selem_id_free(sid);
  394. +    if (handle) {
  395. +        snd_mixer_close(handle);
  396. +        handle = NULL;
  397. +    }
  398. +    return;
  399. +}
  400. +
  401. +/* Volume saved to file */
  402. +static int alsa_get_unmute_volume( void )
  403. +{
  404. +    long val;
  405. +    assert (elem);
  406. +
  407. +    if (snd_mixer_selem_is_playback_mono(elem)) {
  408. +        snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_MONO, &val);
  409. +        return val;
  410. +    } else {
  411. +        int c, n = 0;
  412. +        long sum = 0;
  413. +        for (c = 0; c <= SND_MIXER_SCHN_LAST; c++) {
  414. +            if (snd_mixer_selem_has_playback_channel(elem, c)) {
  415. +                snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, &val);
  416. +                sum += val;
  417. +                n++;
  418. +            }
  419. +        }
  420. +        if (! n) {
  421. +            return 0;
  422. +        }
  423. +
  424. +        val = sum / n;
  425. +        sum = (long)((double)(alsa_vol * (alsa_max - alsa_min)) / 100. + 0.5);
  426. +
  427. +        if (sum != val) {
  428. +           alsa_vol = (long)(((val * 100.) / (alsa_max - alsa_min)) + 0.5);
  429. +        }
  430. +        return alsa_vol;
  431. +    }
  432. +}
  433. +
  434. +static int alsa_get_volume( void )
  435. +{
  436. +    if (muted)
  437. +        return 0;
  438. +    else
  439. +        return alsa_get_unmute_volume();
  440. +}
  441. +
  442. +static int alsa_set_volume( int percentdiff )
  443. +{
  444. +    long volume;
  445. +
  446. +    alsa_get_volume();
  447. +
  448. +    alsa_vol += percentdiff;
  449. +    if( alsa_vol > 100 ) alsa_vol = 100;
  450. +    if( alsa_vol < 0 ) alsa_vol = 0;
  451. +
  452. +    volume = (long)((alsa_vol * (alsa_max - alsa_min) / 100.) + 0.5);
  453. +
  454. +    snd_mixer_selem_set_playback_volume_all(elem, volume + alsa_min);
  455. +    snd_mixer_selem_set_playback_switch_all(elem, 1);
  456. +    muted = 0;
  457. +    mutecount = 0;
  458. +
  459. +    return alsa_vol;
  460. +}
  461. +
  462. +static void alsa_mute( int mute )
  463. +{
  464. +    /**
  465. +     * Make sure that if multiple users mute the card,
  466. +     * we only honour the last one.
  467. +     */
  468. +    if( !mute && mutecount ) mutecount--;
  469. +    if( mutecount ) return;
  470. +
  471. +    if( mute ) {
  472. +        mutecount++;
  473. +        muted = 1;
  474. +        if (snd_mixer_selem_has_playback_switch(elem))
  475. +            snd_mixer_selem_set_playback_switch_all(elem, 0);
  476. +        else
  477. +            fprintf(stderr, "mixer: mute not implemented\n");
  478. +    } else {
  479. +        muted = 0;
  480. +        if (snd_mixer_selem_has_playback_switch(elem))
  481. +            snd_mixer_selem_set_playback_switch_all(elem, 1);
  482. +        else
  483. +            fprintf(stderr, "mixer: mute not implemented\n");
  484. +    }
  485. +}
  486. +
  487. +static int alsa_ismute( void )
  488. +{
  489. +    return muted;
  490. +}
  491. +
  492. +static int alsa_set_device( const char *devname )
  493. +{
  494. +    int i;
  495. +
  496. +    if (card) free(card);
  497. +    card = strdup( devname );
  498. +    if( !card ) return -1;
  499. +
  500. +    i = strcspn( card, "/" );
  501. +    if( i == strlen( card ) ) {
  502. +        channel = "Line";
  503. +    } else {
  504. +        card[i] = 0;
  505. +        channel = card + i + 1;
  506. +    }
  507. +    alsa_open_mixer();
  508. +    if (!handle) {
  509. +        fprintf( stderr, "mixer: Can't open mixer %s, "
  510. +                 "mixer volume and mute unavailable.\n", card );
  511. +        return -1;
  512. +    }
  513. +    return 0;
  514. +}
  515. +
  516. +static void alsa_set_state( int ismuted, int unmute_volume )
  517. +{
  518. +    /**
  519. +     * 1. we come back unmuted: Don't touch anything
  520. +     * 2. we don't have a saved volume: Don't touch anything
  521. +     * 3. we come back muted and we have a saved volume:
  522. +     *    - if tvtime muted it, unmute to old volume
  523. +     *    - if user did it, remember that we're muted and old volume
  524. +     */
  525. +    if( alsa_get_volume() == 0 && unmute_volume > 0 ) {
  526. +        snd_mixer_selem_set_playback_volume_all(elem, unmute_volume);
  527. +        muted = 1;
  528. +
  529. +        if( !ismuted ) {
  530. +            alsa_mute( 0 );
  531. +        }
  532. +    }
  533. +}
  534. +
  535. +static void alsa_close_device( void )
  536. +{
  537. +    elem = NULL;
  538. +    if (handle)
  539. +        snd_mixer_close(handle);
  540. +    handle = NULL;
  541. +    muted = 0;
  542. +    mutecount = 0;
  543. +}
  544. +
  545. +struct mixer alsa_mixer = {
  546. +    .set_device = alsa_set_device,
  547. +    .set_state = alsa_set_state,
  548. +    .get_volume = alsa_get_volume,
  549. +    .get_unmute_volume = alsa_get_unmute_volume,
  550. +    .set_volume = alsa_set_volume,
  551. +    .mute = alsa_mute,
  552. +    .ismute = alsa_ismute,
  553. +    .close_device = alsa_close_device,
  554. +};
  555. +// vim: ts=4 sw=4 et foldmethod=marker
  556. diff -Nur tvtime-1.0.2/src/mixer.c tvtime-1.0.2-custom/src/mixer.c
  557. --- tvtime-1.0.2/src/mixer.c    2004-10-29 04:15:23.000000000 +0200
  558. +++ tvtime-1.0.2-custom/src/mixer.c     2011-05-29 18:44:24.944442752 +0200
  559. @@ -19,230 +19,104 @@
  560.   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  561.   */
  562.  
  563. -#include <stdio.h>
  564. -#include <fcntl.h>
  565. -#include <unistd.h>
  566. -#include <sys/types.h>
  567. -#include <sys/stat.h>
  568. -#include <sys/ioctl.h>
  569. -#include <sys/soundcard.h>
  570. -#include <sys/mman.h>
  571. -#include <string.h>
  572. -#include "utils.h"
  573.  #include "mixer.h"
  574.  
  575. -static char *mixer_device = "/dev/mixer";
  576. -static int saved_volume = (50 << 8 & 0xFF00) | (50 & 0x00FF);
  577. -static int mixer_channel = SOUND_MIXER_LINE;
  578. -static int mixer_dev_mask = 1 << SOUND_MIXER_LINE;
  579. -static int muted = 0;
  580. -static int mutecount = 0;
  581. -static int fd = -1;
  582. -
  583. -int mixer_get_volume( void )
  584. -{
  585. -    int v, cmd, devs;
  586. -    int curvol = 0;
  587. -
  588. -    if( fd < 0 ) fd = open( mixer_device, O_RDONLY );
  589. -    if( fd != -1 ) {
  590. -
  591. -        ioctl( fd, SOUND_MIXER_READ_DEVMASK, &devs );
  592. -        if( devs & mixer_dev_mask ) {
  593. -            cmd = MIXER_READ( mixer_channel );
  594. -        } else {
  595. -            return curvol;
  596. -        }
  597. -
  598. -        ioctl( fd, cmd, &v );
  599. -        curvol = ( v & 0xFF00 ) >> 8;
  600. -    }
  601. -
  602. -    return curvol;
  603. +/**
  604. + * Sets the mixer device and channel.
  605. + */
  606. +static int null_set_device( const char *devname )
  607. +{
  608. +    return 0;
  609.  }
  610.  
  611. -int mixer_get_unmute_volume( void )
  612. +/**
  613. + * Sets the initial state of the mixer device.
  614. + */
  615. +static void null_set_state( int ismuted, int unmute_volume )
  616.  {
  617. -    if( muted ) {
  618. -        return saved_volume;
  619. -    } else {
  620. -        int v, cmd, devs;
  621. -
  622. -        if( fd < 0 ) fd = open( mixer_device, O_RDONLY );
  623. -        if( fd != -1 ) {
  624. -
  625. -            ioctl( fd, SOUND_MIXER_READ_DEVMASK, &devs );
  626. -            if( devs & mixer_dev_mask ) {
  627. -                cmd = MIXER_READ( mixer_channel );
  628. -            } else {
  629. -                return -1;
  630. -            }
  631. -
  632. -            ioctl( fd, cmd, &v );
  633. -            return v;
  634. -        }
  635. -    }
  636. -
  637. -    return -1;
  638.  }
  639.  
  640. -int mixer_set_volume( int percentdiff )
  641. +/**
  642. + * Returns the current volume setting.
  643. + */
  644. +static int null_get_volume( void )
  645.  {
  646. -    int v, cmd, devs, levelpercentage;
  647. -
  648. -    levelpercentage = mixer_get_volume();
  649. -
  650. -    levelpercentage += percentdiff;
  651. -    if( levelpercentage > 100 ) levelpercentage = 100;
  652. -    if( levelpercentage < 0 ) levelpercentage = 0;
  653. -
  654. -    if( fd < 0 ) fd = open( mixer_device, O_RDONLY );
  655. -    if( fd != -1 ) {
  656. -        ioctl( fd, SOUND_MIXER_READ_DEVMASK, &devs );
  657. -        if( devs & mixer_dev_mask ) {
  658. -            cmd = MIXER_WRITE( mixer_channel );
  659. -        } else {
  660. -            return 0;
  661. -        }
  662. -
  663. -        v = ( levelpercentage << 8 ) | levelpercentage;
  664. -        ioctl( fd, cmd, &v );
  665. -        muted = 0;
  666. -        mutecount = 0;
  667. -        return v;
  668. -    }
  669. -
  670.      return 0;
  671.  }
  672.  
  673. -void mixer_mute( int mute )
  674. +/**
  675. + * Returns the volume that would be used to restore the unmute state.
  676. + */
  677. +static int null_get_unmute_volume( void )
  678.  {
  679. -    int v, cmd, devs;
  680. -
  681. -    /**
  682. -     * Make sure that if multiple users mute the card,
  683. -     * we only honour the last one.
  684. -     */
  685. -    if( !mute && mutecount ) mutecount--;
  686. -    if( mutecount ) return;
  687. -
  688. -    if( fd < 0 ) fd = open( mixer_device, O_RDONLY );
  689. -
  690. -    if( mute ) {
  691. -        mutecount++;
  692. -        if( fd != -1 ) {
  693. -
  694. -            /* Save volume */
  695. -            ioctl( fd, SOUND_MIXER_READ_DEVMASK, &devs );
  696. -            if( devs & mixer_dev_mask ) {
  697. -                cmd = MIXER_READ( mixer_channel );
  698. -            } else {
  699. -                return;
  700. -            }
  701. -
  702. -            ioctl( fd,cmd,&v );
  703. -            saved_volume = v;
  704. -
  705. -            /* Now set volume to 0 */
  706. -            ioctl( fd, SOUND_MIXER_READ_DEVMASK, &devs );
  707. -            if( devs & mixer_dev_mask ) {
  708. -                cmd = MIXER_WRITE( mixer_channel );
  709. -            } else {
  710. -                return;
  711. -            }
  712. -
  713. -            v = 0;
  714. -            ioctl( fd, cmd, &v );
  715. -
  716. -            muted = 1;
  717. -            return;
  718. -        }
  719. -    } else {
  720. -        if( fd != -1 ) {
  721. -            ioctl( fd, SOUND_MIXER_READ_DEVMASK, &devs );
  722. -            if( devs & mixer_dev_mask ) {
  723. -                cmd = MIXER_WRITE( mixer_channel );
  724. -            } else {
  725. -                return;
  726. -            }
  727. -
  728. -            v = saved_volume;
  729. -            ioctl( fd, cmd, &v );
  730. -            muted = 0;
  731. -            return;
  732. -        }
  733. -    }
  734. +    return 0;
  735.  }
  736.  
  737. -int mixer_ismute( void )
  738. +/**
  739. + * Tunes the relative volume.
  740. + */
  741. +static int null_set_volume( int percentdiff )
  742.  {
  743. -    return muted;
  744. +    return 0;
  745.  }
  746.  
  747. -static char *oss_core_devnames[] = SOUND_DEVICE_NAMES;
  748. -
  749. -void mixer_set_device( const char *devname )
  750. +/**
  751. + * Sets the mute state.
  752. + */
  753. +static void null_mute( int mute )
  754.  {
  755. -    const char *channame;
  756. -    int found = 0;
  757. -    int i;
  758. -
  759. -    mixer_device = strdup( devname );
  760. -    if( !mixer_device ) return;
  761. -
  762. -    i = strcspn( mixer_device, ":" );
  763. -    if( i == strlen( mixer_device ) ) {
  764. -        channame = "line";
  765. -    } else {
  766. -        mixer_device[ i ] = 0;
  767. -        channame = mixer_device + i + 1;
  768. -    }
  769. -    if( !file_is_openable_for_read( mixer_device ) ) {
  770. -        fprintf( stderr, "mixer: Can't open device %s, "
  771. -                 "mixer volume and mute unavailable.\n", mixer_device );
  772. -    }
  773. -
  774. -    mixer_channel = SOUND_MIXER_LINE;
  775. -    for( i = 0; i < SOUND_MIXER_NRDEVICES; i++ ) {
  776. -        if( !strcasecmp( channame, oss_core_devnames[ i ] ) ) {
  777. -            mixer_channel = i;
  778. -            found = 1;
  779. -            break;
  780. -        }
  781. -    }
  782. -    if( !found ) {
  783. -        fprintf( stderr, "mixer: No such mixer channel '%s', using channel 'line'.\n", channame );
  784. -    }
  785. -    mixer_dev_mask = 1 << mixer_channel;
  786.  }
  787.  
  788. -void mixer_set_state( int ismuted, int unmute_volume )
  789. +/**
  790. + * Returns true if the mixer is muted.
  791. + */
  792. +static int null_ismute( void )
  793.  {
  794. -    /**
  795. -     * 1. we come back unmuted: Don't touch anything
  796. -     * 2. we don't have a saved volume: Don't touch anything
  797. -     * 3. we come back muted and we have a saved volume:
  798. -     *    - if tvtime muted it, unmute to old volume
  799. -     *    - if user did it, remember that we're muted and old volume
  800. -     */
  801. -    if( mixer_get_volume() == 0 && unmute_volume > 0 ) {
  802. -        saved_volume = unmute_volume;
  803. -        muted = 1;
  804. -
  805. -        if( !ismuted ) {
  806. -            mixer_mute( 0 );
  807. -        }
  808. -    }
  809. +    return 0;
  810.  }
  811.  
  812. -void mixer_close_device( void )
  813. +/**
  814. + * Closes the mixer device if it is open.
  815. + */
  816. +static void null_close_device( void )
  817.  {
  818. -    if( fd >= 0 ) close( fd );
  819. -    saved_volume = (50 << 8 & 0xFF00) | (50 & 0x00FF);
  820. -    mixer_channel = SOUND_MIXER_LINE;
  821. -    mixer_dev_mask = 1 << SOUND_MIXER_LINE;
  822. -    muted = 0;
  823. -    mutecount = 0;
  824. -    fd = -1;
  825.  }
  826.  
  827. +/* The null device, which always works. */
  828. +static struct mixer null_mixer = {
  829. +    .set_device = null_set_device,
  830. +    .set_state = null_set_state,
  831. +    .get_volume = null_get_volume,
  832. +    .get_unmute_volume = null_get_unmute_volume,
  833. +    .set_volume = null_set_volume,
  834. +    .mute = null_mute,
  835. +    .ismute = null_ismute,
  836. +    .close_device = null_close_device,
  837. +};
  838. +
  839. +/* List of all available access methods.
  840. + * Uses weak symbols: NULL is not linked in. */
  841. +static struct mixer *mixers[] = {
  842. +    &alsa_mixer,
  843. +    &oss_mixer,
  844. +    &null_mixer /* LAST */
  845. +};
  846. +/* The actual access method. */
  847. +struct mixer *mixer = &null_mixer;
  848. +
  849. +/**
  850. + * Sets the mixer device and channel.
  851. + * Try each access method until one succeeds.
  852. + */
  853. +void mixer_set_device( const char *devname )
  854. +{
  855. +    int i;
  856. +    mixer->close_device();
  857. +    for (i = 0; i < sizeof(mixers)/sizeof(mixers[0]); i++) {
  858. +        mixer = mixers[i];
  859. +        if (!mixer)
  860. +            continue;
  861. +        if (mixer->set_device(devname) == 0)
  862. +            break;
  863. +    }
  864. +}
  865. diff -Nur tvtime-1.0.2/src/mixer.h tvtime-1.0.2-custom/src/mixer.h
  866. --- tvtime-1.0.2/src/mixer.h    2004-08-27 03:18:49.000000000 +0200
  867. +++ tvtime-1.0.2-custom/src/mixer.h     2011-05-29 18:44:24.947776092 +0200
  868. @@ -27,45 +27,58 @@
  869.  #endif
  870.  
  871.  /**
  872. - * Sets the mixer device and channel.  The device name is of the form
  873. - * devicename:channelname.  The default is /dev/mixer:line.
  874. + * Sets the mixer device and channel.
  875. + * All interfaces are scanned until one succeeds.
  876.   */
  877.  void mixer_set_device( const char *devname );
  878.  
  879. +struct mixer {
  880. +/**
  881. + * Sets the mixer device and channel.
  882. + */
  883. +int (* set_device)( const char *devname );
  884. +
  885.  /**
  886.   * Sets the initial state of the mixer device.
  887.   */
  888. -void mixer_set_state( int ismuted, int unmute_volume );
  889. +void (* set_state)( int ismuted, int unmute_volume );
  890.  
  891.  /**
  892.   * Returns the current volume setting.
  893.   */
  894. -int mixer_get_volume( void );
  895. +int (* get_volume)( void );
  896.  
  897.  /**
  898.   * Returns the volume that would be used to restore the unmute state.
  899.   */
  900. -int mixer_get_unmute_volume( void );
  901. +int (* get_unmute_volume)( void );
  902.  
  903.  /**
  904.   * Tunes the relative volume.
  905.   */
  906. -int mixer_set_volume( int percentdiff );
  907. +int (* set_volume)( int percentdiff );
  908.  
  909.  /**
  910.   * Sets the mute state.
  911.   */
  912. -void mixer_mute( int mute );
  913. +void (* mute)( int mute );
  914.  
  915.  /**
  916.   * Returns true if the mixer is muted.
  917.   */
  918. -int mixer_ismute( void );
  919. +int (* ismute)( void );
  920.  
  921.  /**
  922.   * Closes the mixer device if it is open.
  923.   */
  924. -void mixer_close_device( void );
  925. +void (* close_device)( void );
  926. +};
  927. +
  928. +#pragma weak alsa_mixer
  929. +extern struct mixer alsa_mixer;
  930. +#pragma weak oss_mixer
  931. +extern struct mixer oss_mixer;
  932. +extern struct mixer *mixer;
  933.  
  934.  #ifdef __cplusplus
  935.  };
  936. diff -Nur tvtime-1.0.2/src/mixer-oss.c tvtime-1.0.2-custom/src/mixer-oss.c
  937. --- tvtime-1.0.2/src/mixer-oss.c        1970-01-01 01:00:00.000000000 +0100
  938. +++ tvtime-1.0.2-custom/src/mixer-oss.c 2011-05-29 18:44:24.954442772 +0200
  939. @@ -0,0 +1,261 @@
  940. +/**
  941. + * Copyright (C) 2002, 2003 Doug Bell <drbell@users.sourceforge.net>
  942. + *
  943. + * Some mixer routines from mplayer, http://mplayer.sourceforge.net.
  944. + * Copyright (C) 2000-2002. by A'rpi/ESP-team & others
  945. + *
  946. + * This program is free software; you can redistribute it and/or modify
  947. + * it under the terms of the GNU General Public License as published by
  948. + * the Free Software Foundation; either version 2, or (at your option)
  949. + * any later version.
  950. + *
  951. + * This program is distributed in the hope that it will be useful,
  952. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  953. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  954. + * GNU General Public License for more details.
  955. + *
  956. + * You should have received a copy of the GNU General Public License
  957. + * along with this program; if not, write to the Free Software Foundation,
  958. + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  959. + */
  960. +
  961. +#include <stdio.h>
  962. +#include <fcntl.h>
  963. +#include <unistd.h>
  964. +#include <sys/types.h>
  965. +#include <sys/stat.h>
  966. +#include <sys/ioctl.h>
  967. +#include <sys/soundcard.h>
  968. +#include <sys/mman.h>
  969. +#include <string.h>
  970. +#include "utils.h"
  971. +#include "mixer.h"
  972. +
  973. +static char *mixer_device = "/dev/mixer";
  974. +static int saved_volume = (50 << 8 & 0xFF00) | (50 & 0x00FF);
  975. +static int mixer_channel = SOUND_MIXER_LINE;
  976. +static int mixer_dev_mask = 1 << SOUND_MIXER_LINE;
  977. +static int muted = 0;
  978. +static int mutecount = 0;
  979. +static int fd = -1;
  980. +
  981. +static int oss_get_volume( void )
  982. +{
  983. +    int v, cmd, devs;
  984. +    int curvol = 0;
  985. +
  986. +    if( fd < 0 ) fd = open( mixer_device, O_RDONLY );
  987. +    if( fd != -1 ) {
  988. +
  989. +        ioctl( fd, SOUND_MIXER_READ_DEVMASK, &devs );
  990. +        if( devs & mixer_dev_mask ) {
  991. +            cmd = MIXER_READ( mixer_channel );
  992. +        } else {
  993. +            return curvol;
  994. +        }
  995. +
  996. +        ioctl( fd, cmd, &v );
  997. +        curvol = ( v & 0xFF00 ) >> 8;
  998. +    }
  999. +
  1000. +    return curvol;
  1001. +}
  1002. +
  1003. +static int oss_get_unmute_volume( void )
  1004. +{
  1005. +    if( muted ) {
  1006. +        return saved_volume;
  1007. +    } else {
  1008. +        int v, cmd, devs;
  1009. +
  1010. +        if( fd < 0 ) fd = open( mixer_device, O_RDONLY );
  1011. +        if( fd != -1 ) {
  1012. +
  1013. +            ioctl( fd, SOUND_MIXER_READ_DEVMASK, &devs );
  1014. +            if( devs & mixer_dev_mask ) {
  1015. +                cmd = MIXER_READ( mixer_channel );
  1016. +            } else {
  1017. +                return -1;
  1018. +            }
  1019. +
  1020. +            ioctl( fd, cmd, &v );
  1021. +            return v;
  1022. +        }
  1023. +    }
  1024. +
  1025. +    return -1;
  1026. +}
  1027. +
  1028. +static int oss_set_volume( int percentdiff )
  1029. +{
  1030. +    int v, cmd, devs, levelpercentage;
  1031. +
  1032. +    levelpercentage = oss_get_volume();
  1033. +
  1034. +    levelpercentage += percentdiff;
  1035. +    if( levelpercentage > 100 ) levelpercentage = 100;
  1036. +    if( levelpercentage < 0 ) levelpercentage = 0;
  1037. +
  1038. +    if( fd < 0 ) fd = open( mixer_device, O_RDONLY );
  1039. +    if( fd != -1 ) {
  1040. +        ioctl( fd, SOUND_MIXER_READ_DEVMASK, &devs );
  1041. +        if( devs & mixer_dev_mask ) {
  1042. +            cmd = MIXER_WRITE( mixer_channel );
  1043. +        } else {
  1044. +            return 0;
  1045. +        }
  1046. +
  1047. +        v = ( levelpercentage << 8 ) | levelpercentage;
  1048. +        ioctl( fd, cmd, &v );
  1049. +        muted = 0;
  1050. +        mutecount = 0;
  1051. +        return v;
  1052. +    }
  1053. +
  1054. +    return 0;
  1055. +}
  1056. +
  1057. +static void oss_mute( int mute )
  1058. +{
  1059. +    int v, cmd, devs;
  1060. +
  1061. +    /**
  1062. +     * Make sure that if multiple users mute the card,
  1063. +     * we only honour the last one.
  1064. +     */
  1065. +    if( !mute && mutecount ) mutecount--;
  1066. +    if( mutecount ) return;
  1067. +
  1068. +    if( fd < 0 ) fd = open( mixer_device, O_RDONLY );
  1069. +
  1070. +    if( mute ) {
  1071. +        mutecount++;
  1072. +        if( fd != -1 ) {
  1073. +
  1074. +            /* Save volume */
  1075. +            ioctl( fd, SOUND_MIXER_READ_DEVMASK, &devs );
  1076. +            if( devs & mixer_dev_mask ) {
  1077. +                cmd = MIXER_READ( mixer_channel );
  1078. +            } else {
  1079. +                return;
  1080. +            }
  1081. +
  1082. +            ioctl( fd,cmd,&v );
  1083. +            saved_volume = v;
  1084. +
  1085. +            /* Now set volume to 0 */
  1086. +            ioctl( fd, SOUND_MIXER_READ_DEVMASK, &devs );
  1087. +            if( devs & mixer_dev_mask ) {
  1088. +                cmd = MIXER_WRITE( mixer_channel );
  1089. +            } else {
  1090. +                return;
  1091. +            }
  1092. +
  1093. +            v = 0;
  1094. +            ioctl( fd, cmd, &v );
  1095. +
  1096. +            muted = 1;
  1097. +            return;
  1098. +        }
  1099. +    } else {
  1100. +        if( fd != -1 ) {
  1101. +            ioctl( fd, SOUND_MIXER_READ_DEVMASK, &devs );
  1102. +            if( devs & mixer_dev_mask ) {
  1103. +                cmd = MIXER_WRITE( mixer_channel );
  1104. +            } else {
  1105. +                return;
  1106. +            }
  1107. +
  1108. +            v = saved_volume;
  1109. +            ioctl( fd, cmd, &v );
  1110. +            muted = 0;
  1111. +            return;
  1112. +        }
  1113. +    }
  1114. +}
  1115. +
  1116. +static int oss_ismute( void )
  1117. +{
  1118. +    return muted;
  1119. +}
  1120. +
  1121. +static char *oss_core_devnames[] = SOUND_DEVICE_NAMES;
  1122. +
  1123. +static int oss_set_device( const char *devname )
  1124. +{
  1125. +    const char *channame;
  1126. +    int found = 0;
  1127. +    int i;
  1128. +
  1129. +    mixer_device = strdup( devname );
  1130. +    if( !mixer_device ) return -1;
  1131. +
  1132. +    i = strcspn( mixer_device, ":" );
  1133. +    if( i == strlen( mixer_device ) ) {
  1134. +        channame = "line";
  1135. +    } else {
  1136. +        mixer_device[ i ] = 0;
  1137. +        channame = mixer_device + i + 1;
  1138. +    }
  1139. +    if( !file_is_openable_for_read( mixer_device ) ) {
  1140. +        fprintf( stderr, "mixer: Can't open device %s, "
  1141. +                 "mixer volume and mute unavailable.\n", mixer_device );
  1142. +        return -1;
  1143. +    }
  1144. +
  1145. +    mixer_channel = SOUND_MIXER_LINE;
  1146. +    for( i = 0; i < SOUND_MIXER_NRDEVICES; i++ ) {
  1147. +        if( !strcasecmp( channame, oss_core_devnames[ i ] ) ) {
  1148. +            mixer_channel = i;
  1149. +            found = 1;
  1150. +            break;
  1151. +        }
  1152. +    }
  1153. +    if( !found ) {
  1154. +        fprintf( stderr, "mixer: No such mixer channel '%s', using channel 'line'.\n", channame );
  1155. +        return -1;
  1156. +    }
  1157. +    mixer_dev_mask = 1 << mixer_channel;
  1158. +    return 0;
  1159. +}
  1160. +
  1161. +static void oss_set_state( int ismuted, int unmute_volume )
  1162. +{
  1163. +    /**
  1164. +     * 1. we come back unmuted: Don't touch anything
  1165. +     * 2. we don't have a saved volume: Don't touch anything
  1166. +     * 3. we come back muted and we have a saved volume:
  1167. +     *    - if tvtime muted it, unmute to old volume
  1168. +     *    - if user did it, remember that we're muted and old volume
  1169. +     */
  1170. +    if( oss_get_volume() == 0 && unmute_volume > 0 ) {
  1171. +        saved_volume = unmute_volume;
  1172. +        muted = 1;
  1173. +
  1174. +        if( !ismuted ) {
  1175. +            oss_mute( 0 );
  1176. +        }
  1177. +    }
  1178. +}
  1179. +
  1180. +static void oss_close_device( void )
  1181. +{
  1182. +    if( fd >= 0 ) close( fd );
  1183. +    saved_volume = (50 << 8 & 0xFF00) | (50 & 0x00FF);
  1184. +    mixer_channel = SOUND_MIXER_LINE;
  1185. +    mixer_dev_mask = 1 << SOUND_MIXER_LINE;
  1186. +    muted = 0;
  1187. +    mutecount = 0;
  1188. +    fd = -1;
  1189. +}
  1190. +
  1191. +struct mixer oss_mixer = {
  1192. +    .set_device = oss_set_device,
  1193. +    .set_state = oss_set_state,
  1194. +    .get_volume = oss_get_volume,
  1195. +    .get_unmute_volume = oss_get_unmute_volume,
  1196. +    .set_volume = oss_set_volume,
  1197. +    .mute = oss_mute,
  1198. +    .ismute = oss_ismute,
  1199. +    .close_device = oss_close_device,
  1200. +};
  1201. diff -Nur tvtime-1.0.2/src/tvtime.c tvtime-1.0.2-custom/src/tvtime.c
  1202. --- tvtime-1.0.2/src/tvtime.c   2005-09-08 04:55:54.000000000 +0200
  1203. +++ tvtime-1.0.2-custom/src/tvtime.c    2011-05-29 18:44:24.957776112 +0200
  1204. @@ -1062,84 +1062,55 @@
  1205.      char string[ 128 ];
  1206.  
  1207.      menu_set_back_command( menu, TVTIME_SHOW_MENU, "output" );
  1208. -    if( sixteennine ) {
  1209. -        snprintf( string, sizeof( string ), (mode == 0) ?
  1210. -                  TVTIME_ICON_RADIOON "  %s" : TVTIME_ICON_RADIOOFF "  %s",
  1211. -                  _("16:9 + Overscan") );
  1212. -        menu_set_text( menu, 1, string );
  1213. -        menu_set_enter_command( menu, 1, TVTIME_SET_MATTE, "16:9" );
  1214. -        snprintf( string, sizeof( string ), (mode == 1) ?
  1215. -                  TVTIME_ICON_RADIOON "  %s" : TVTIME_ICON_RADIOOFF "  %s",
  1216. -                  _("1.85:1") );
  1217. -        menu_set_text( menu, 2, string );
  1218. -        menu_set_enter_command( menu, 2, TVTIME_SET_MATTE, "1.85:1" );
  1219. -        snprintf( string, sizeof( string ), (mode == 2) ?
  1220. -                  TVTIME_ICON_RADIOON "  %s" : TVTIME_ICON_RADIOOFF "  %s",
  1221. -                  _("2.35:1") );
  1222. -        menu_set_text( menu, 3, string );
  1223. -        menu_set_enter_command( menu, 3, TVTIME_SET_MATTE, "2.35:1" );
  1224. -        snprintf( string, sizeof( string ), (mode == 3) ?
  1225. -                  TVTIME_ICON_RADIOON "  %s" : TVTIME_ICON_RADIOOFF "  %s",
  1226. -                  _("4:3 centre") );
  1227. -        menu_set_text( menu, 4, string );
  1228. -        menu_set_enter_command( menu, 4, TVTIME_SET_MATTE, "4:3" );
  1229. -        snprintf( string, sizeof( string ), (mode == 4) ?
  1230. -                  TVTIME_ICON_RADIOON "  %s" : TVTIME_ICON_RADIOOFF "  %s",
  1231. -                  _("16:10") );
  1232. -        menu_set_text( menu, 5, string );
  1233. -        menu_set_enter_command( menu, 5, TVTIME_SET_MATTE, "16:10" );
  1234. -    } else {
  1235. -        snprintf( string, sizeof( string ), (mode == 0) ?
  1236. -                  TVTIME_ICON_RADIOON "  %s" : TVTIME_ICON_RADIOOFF "  %s",
  1237. -                  _("4:3 + Overscan") );
  1238. -        menu_set_text( menu, 1, string );
  1239. -        menu_set_enter_command( menu, 1, TVTIME_SET_MATTE, "4:3" );
  1240. -        snprintf( string, sizeof( string ), (mode == 1) ?
  1241. -                  TVTIME_ICON_RADIOON "  %s" : TVTIME_ICON_RADIOOFF "  %s",
  1242. -                  _("16:9") );
  1243. -        menu_set_text( menu, 2, string );
  1244. -        menu_set_enter_command( menu, 2, TVTIME_SET_MATTE, "16:9" );
  1245. -        snprintf( string, sizeof( string ), (mode == 2) ?
  1246. -                  TVTIME_ICON_RADIOON "  %s" : TVTIME_ICON_RADIOOFF "  %s",
  1247. -                  _("16:10") );
  1248. -        menu_set_text( menu, 3, string );
  1249. -        menu_set_enter_command( menu, 3, TVTIME_SET_MATTE, "16:10" );
  1250. -        snprintf( string, sizeof( string ), (mode == 3) ?
  1251. -                  TVTIME_ICON_RADIOON "  %s" : TVTIME_ICON_RADIOOFF "  %s",
  1252. -                  _("1.85:1") );
  1253. -        menu_set_text( menu, 4, string );
  1254. -        menu_set_enter_command( menu, 4, TVTIME_SET_MATTE, "1.85:1" );
  1255. -        snprintf( string, sizeof( string ), (mode == 4) ?
  1256. -                  TVTIME_ICON_RADIOON "  %s" : TVTIME_ICON_RADIOOFF "  %s",
  1257. -                  _("2.35:1") );
  1258. -        menu_set_text( menu, 5, string );
  1259. -        menu_set_enter_command( menu, 5, TVTIME_SET_MATTE, "2.35:1" );
  1260. -    }
  1261. +
  1262. +    snprintf( string, sizeof( string ), (mode == 0) ?
  1263. +              TVTIME_ICON_RADIOON "  %s" : TVTIME_ICON_RADIOOFF "  %s",
  1264. +              _("4:3") );
  1265. +    menu_set_text( menu, 1, string );
  1266. +    menu_set_enter_command( menu, 1, TVTIME_SET_MATTE, "4:3" );
  1267. +    snprintf( string, sizeof( string ), (mode == 1) ?
  1268. +              TVTIME_ICON_RADIOON "  %s" : TVTIME_ICON_RADIOOFF "  %s",
  1269. +              _("16:10") );
  1270. +    menu_set_text( menu, 2, string );
  1271. +    menu_set_enter_command( menu, 2, TVTIME_SET_MATTE, "16:10" );
  1272. +    snprintf( string, sizeof( string ), (mode == 2) ?
  1273. +              TVTIME_ICON_RADIOON "  %s" : TVTIME_ICON_RADIOOFF "  %s",
  1274. +              _("16:9") );
  1275. +    menu_set_text( menu, 3, string );
  1276. +    menu_set_enter_command( menu, 3, TVTIME_SET_MATTE, "16:9" );      
  1277. +    snprintf( string, sizeof( string ), (mode == 3) ?
  1278. +              TVTIME_ICON_RADIOON "  %s" : TVTIME_ICON_RADIOOFF "  %s",
  1279. +              _("1.85:1") );
  1280. +    menu_set_text( menu, 4, string );
  1281. +    menu_set_enter_command( menu, 4, TVTIME_SET_MATTE, "1.85:1" );
  1282. +    snprintf( string, sizeof( string ), (mode == 4) ?
  1283. +              TVTIME_ICON_RADIOON "  %s" : TVTIME_ICON_RADIOOFF "  %s",
  1284. +              _("2.35:1") );
  1285. +    menu_set_text( menu, 5, string );
  1286. +    menu_set_enter_command( menu, 5, TVTIME_SET_MATTE, "2.35:1" );
  1287. +
  1288.  
  1289.      snprintf( string, sizeof( string ), TVTIME_ICON_PLAINLEFTARROW "  %s",
  1290.                _("Back") );
  1291.      menu_set_text( menu, 6, string );
  1292.      menu_set_enter_command( menu, 6, TVTIME_SHOW_MENU, "output" );
  1293.  }
  1294. -
  1295. +
  1296.  static void osd_list_matte( tvtime_osd_t *osd, int mode, int sixteennine )
  1297.  {
  1298.      tvtime_osd_list_set_lines( osd, 6 );
  1299.      if( sixteennine ) {
  1300.          tvtime_osd_list_set_text( osd, 0, _("Matte setting (Anamorphic input)") );
  1301. -        tvtime_osd_list_set_text( osd, 1, _("16:9 + Overscan") );
  1302. -        tvtime_osd_list_set_text( osd, 2, "1.85:1" );
  1303. -        tvtime_osd_list_set_text( osd, 3, "2.35:1" );
  1304. -        tvtime_osd_list_set_text( osd, 4, _("4:3 centre") );
  1305. -        tvtime_osd_list_set_text( osd, 5, "16:10" );
  1306. +
  1307.      } else {
  1308.          tvtime_osd_list_set_text( osd, 0, _("Matte setting (4:3 input)") );
  1309. -        tvtime_osd_list_set_text( osd, 1, _("4:3 + Overscan") );
  1310. -        tvtime_osd_list_set_text( osd, 2, "16:9" );
  1311. -        tvtime_osd_list_set_text( osd, 3, "16:10" );
  1312. -        tvtime_osd_list_set_text( osd, 4, "1.85:1" );
  1313. -        tvtime_osd_list_set_text( osd, 5, "2.35:1" );
  1314.      }
  1315. +    tvtime_osd_list_set_text( osd, 1, "4:3" );
  1316. +    tvtime_osd_list_set_text( osd, 2, "16:10" );
  1317. +    tvtime_osd_list_set_text( osd, 3, "16:9" );
  1318. +    tvtime_osd_list_set_text( osd, 4, "1.85:1" );
  1319. +    tvtime_osd_list_set_text( osd, 5, "2.35:1" );
  1320. +
  1321.      tvtime_osd_list_set_hilight( osd, mode + 1 );
  1322.      tvtime_osd_show_list( osd, 1, 0 );
  1323.  }
  1324. @@ -1204,6 +1175,7 @@
  1325.      int matte_y = 0;
  1326.      int matte_h = 0;
  1327.      int matte_mode = 0;
  1328. +    int matte_changed = 0;
  1329.      int restarttvtime = 0;
  1330.      int return_value = 0;
  1331.      int last_current_id = -1;
  1332. @@ -1241,6 +1213,7 @@
  1333.      output = get_xv_output();
  1334.  
  1335.      sixteennine = config_get_aspect( ct );
  1336. +    matte_mode = config_get_matte( ct );
  1337.  
  1338.      if( !output || !output->init( config_get_geometry( ct ),
  1339.                                    sixteennine, config_get_square_pixels( ct ),
  1340. @@ -1441,7 +1414,7 @@
  1341.  
  1342.      /* Set the mixer device. */
  1343.      mixer_set_device( config_get_mixer_device( ct ) );
  1344. -    mixer_set_state( config_get_muted( ct ), config_get_unmute_volume( ct ) );
  1345. +    mixer->set_state( config_get_muted( ct ), config_get_unmute_volume( ct ) );
  1346.  
  1347.      /* Setup OSD stuff. */
  1348.      pixel_aspect = ( (double) width ) /
  1349. @@ -1594,6 +1567,15 @@
  1350.      build_fspos_menu( commands_get_menu( commands, "fspos" ),
  1351.                        config_get_fullscreen_position( ct ) );
  1352.  
  1353. +    matte_changed = 1;
  1354. +    double matte = 4.0/3.0;
  1355. +    
  1356. +    /* initialize with safe values until matte is calculated later in the loop. */        
  1357. +    matte_x = 0;
  1358. +    matte_y = 0;
  1359. +    matte_w = width;
  1360. +    matte_h = height;
  1361. +
  1362.      /* Initialize our timestamps. */
  1363.      for(;;) {
  1364.          const char *fifo_args = 0;
  1365. @@ -1607,31 +1589,19 @@
  1366.          int exposed = output->is_exposed();
  1367.          int current_id;
  1368.  
  1369. +
  1370.          if( vidin && videoinput_has_tuner( vidin ) ) {
  1371.              current_id = station_get_current_id( stationmgr );
  1372.          } else {
  1373.              current_id = 0;
  1374.          }
  1375. -
  1376. -        if( matte_mode ) {
  1377. +            /* Since the matte/overscan calculations changed these could probably
  1378. +               be the same variables, but we'll leave it like this for now. */
  1379.              output_x = matte_x;
  1380.              output_w = matte_w;
  1381.              output_y = matte_y;
  1382.              output_h = matte_h;
  1383. -        } else {
  1384. -            output_x = (int) ((((double) width) *
  1385. -                               commands_get_overscan( commands )) + 0.5);
  1386. -            output_w = (int) ((((double) width) -
  1387. -                               (((double) width) *
  1388. -                                commands_get_overscan( commands ) * 2.0)) +
  1389. -                              0.5);
  1390. -            output_y = (int) ((((double) height) *
  1391. -                               commands_get_overscan( commands )) + 0.5);
  1392. -            output_h = (int) ((((double) height) -
  1393. -                               (((double) height) *
  1394. -                                commands_get_overscan( commands ) * 2.0)) +
  1395. -                              0.5);
  1396. -        }
  1397. +        
  1398.  
  1399.          if( fifo ) {
  1400.              int cmd;
  1401. @@ -1766,11 +1736,14 @@
  1402.                                 quiet_screenshots );
  1403.              commands_refresh_menu( commands );
  1404.          }
  1405. +
  1406. +        
  1407.          if( commands_toggle_aspect( commands ) ) {
  1408. -            matte_mode = 0;
  1409. -            output->set_matte( 0, 0 );
  1410.              if( output->toggle_aspect() ) {
  1411.                  sixteennine = 1;
  1412. +                /* Matte is now always applied so we change it to 16:9 mode too so that
  1413. +                   nothing other than overscan is cropped. */
  1414. +                matte_mode = 2;
  1415.                  if( osd ) {
  1416.                      tvtime_osd_show_message( osd,
  1417.                            _("16:9 display mode active.") );
  1418. @@ -1780,6 +1753,7 @@
  1419.                      ( ( (double) height ) * (16.0 / 9.0) );
  1420.              } else {
  1421.                  sixteennine = 0;
  1422. +                matte_mode = 0;
  1423.                  if( osd ) {
  1424.                      tvtime_osd_show_message( osd,
  1425.                            _("4:3 display mode active.") );
  1426. @@ -1800,9 +1774,7 @@
  1427.                                 output->is_alwaysontop_supported(),
  1428.                                 output->is_overscan_supported(),
  1429.                                 quiet_screenshots );
  1430. -            build_matte_menu( commands_get_menu( commands, "matte" ),
  1431. -                              matte_mode, sixteennine );
  1432. -            commands_refresh_menu( commands );
  1433. +            matte_changed = 1;
  1434.          }
  1435.          if( commands_get_fs_pos( commands ) ) {
  1436.              const char *fspos = commands_get_fs_pos( commands );
  1437. @@ -1839,84 +1811,92 @@
  1438.              }
  1439.              commands_refresh_menu( commands );
  1440.          }
  1441. +
  1442. +        /* Overscan has been changed so it is calculated and applied with the matte.
  1443. +           So changing it now generated this event so that we can tell it to redo the matte. */
  1444. +       if( commands_get_changed_overscan( commands ) ) {
  1445. +            matte_changed = 1;
  1446. +        }
  1447.          if( commands_toggle_matte( commands ) ||
  1448.              commands_get_matte_mode( commands ) ) {
  1449. -            double matte = 4.0 / 3.0;
  1450. -            int sqwidth = sixteennine ?
  1451. -                ((height * 16) / 9) : ((height * 4) / 3);
  1452. -            int sqheight = sixteennine ?
  1453. -                ((width * 9) / 16) : ((width * 3) / 4);
  1454.  
  1455. -            matte_x = 0;
  1456. -            matte_w = width;
  1457.              if( commands_toggle_matte( commands ) ) {
  1458.                  matte_mode = (matte_mode + 1) % 5;
  1459.              } else {
  1460. -                if( !strcmp( commands_get_matte_mode( commands ), "16:9" ) ) {
  1461. -                    matte_mode = sixteennine ? 0 : 1;
  1462. -                } else if( !strcmp( commands_get_matte_mode( commands ),
  1463. -                                    "16:10" ) ) {
  1464. -                    matte_mode = sixteennine ? 4 : 2;
  1465. +                if( !strcmp( commands_get_matte_mode( commands ), "16:10" ) ) {
  1466. +                    matte_mode = 1;
  1467. +               } else if( !strcmp( commands_get_matte_mode( commands ),
  1468. +                                    "16:9" ) ) {
  1469. +                    matte_mode = 2;
  1470.                  } else if( !strcmp( commands_get_matte_mode( commands ),
  1471.                                      "1.85:1" ) ) {
  1472. -                    matte_mode = sixteennine ? 1 : 3;
  1473. +                    matte_mode = 3;
  1474.                  } else if( !strcmp( commands_get_matte_mode( commands ),
  1475.                                      "2.35:1" ) ) {
  1476. -                    matte_mode = sixteennine ? 2 : 4;
  1477. +                    matte_mode = 4;
  1478.                  } else {
  1479. -                    matte_mode = sixteennine ? 3 : 0;
  1480. +                    matte_mode = 0;
  1481.                  }
  1482.              }
  1483. -
  1484. -            if( sixteennine ) {
  1485. -                if( matte_mode == 0 ) {
  1486. -                    matte = 16.0 / 9.0;
  1487. -                } else if( matte_mode == 1 ) {
  1488. -                    matte = 1.85;
  1489. -                } else if( matte_mode == 2 ) {
  1490. -                    matte = 2.35;
  1491. -                } else if( matte_mode == 3 ) {
  1492. -                    matte = 4.0 / 3.0;
  1493. -                    matte_w = (int) (((double) sqheight * matte) + 0.5);
  1494. -                    matte_x = (width - matte_w) / 2;
  1495. -                    /* We're cropping the sides off so we add overscan to avoid mess
  1496. -                     * at the top of the screen. */
  1497. -                    matte_y = commands_get_overscan( commands ) * height / 2;
  1498. -                    matte_h = height - matte_y;
  1499. -                    output->set_matte( (matte_h * 4) / 3, matte_h );
  1500. -                } else if( matte_mode == 4 ) {
  1501. -                    matte = 1.6;
  1502. -                    matte_w = (int) (((double) sqheight * matte) + 0.5);
  1503. -                    matte_x = (width - matte_w) / 2;
  1504. -                    /* We're cropping the sides off so we add overscan to avoid mess
  1505. -                     * at the top of the screen. */
  1506. -                    matte_y = commands_get_overscan( commands ) * height / 2;
  1507. -                    matte_h = height - matte_y;
  1508. -                    output->set_matte( (matte_h * 16) / 10, matte_h );
  1509. -                }
  1510. -            } else {
  1511. -                if( matte_mode == 1 ) {
  1512. -                    matte = 16.0 / 9.0;
  1513. -                } else if( matte_mode == 2 ) {
  1514. -                    matte = 1.6;
  1515. -                } else if( matte_mode == 3 ) {
  1516. -                    matte = 1.85;
  1517. -                } else if( matte_mode == 4 ) {
  1518. -                    matte = 2.35;
  1519. -                }
  1520. -            }
  1521. -            if( !matte_x ) {
  1522. -                matte_h = (int) ((((double) sqwidth)/matte) + 0.5);
  1523. -                matte_y = (height - matte_h) / 2;
  1524. -                output->set_matte( sqwidth, matte_h );
  1525. -            }
  1526.              if( osd && !commands_menu_active( commands ) ) {
  1527.                  osd_list_matte( osd, matte_mode, sixteennine );
  1528.              }
  1529.              build_matte_menu( commands_get_menu( commands, "matte" ),
  1530.                                matte_mode, sixteennine );
  1531.              commands_refresh_menu( commands );
  1532. +            matte_changed = 1;
  1533.          }
  1534. +        if (matte_changed) {
  1535. +            matte_changed = 0;
  1536. +
  1537. +            /* start with overscan then apply matte */
  1538. +            matte_x = (int) ((((double) width) *
  1539. +                               commands_get_overscan( commands )) + 0.5);
  1540. +            matte_w = (int) ((((double) width) -
  1541. +                               (((double) width) *
  1542. +                                commands_get_overscan( commands ) * 2.0)) +
  1543. +                              0.5);
  1544. +            matte_y = (int) ((((double) height) *
  1545. +                               commands_get_overscan( commands )) + 0.5);
  1546. +            matte_h = (int) ((((double) height) -
  1547. +                               (((double) height) *
  1548. +                                commands_get_overscan( commands ) * 2.0)) +
  1549. +                              0.5);
  1550. +
  1551. +            int sqwidth = sixteennine ?
  1552. +                ((matte_h * 16) / 9) : ((matte_h * 4) / 3);
  1553. +            int sqheight = sixteennine ?
  1554. +                ((matte_w * 9) / 16) : ((matte_w * 3) / 4);
  1555. +
  1556. +            if( matte_mode == 0 ) {
  1557. +                matte = 4.0 / 3.0;
  1558. +                config_save( ct, "Matte", "4:3" );
  1559. +            } else if( matte_mode == 1 ) {
  1560. +                matte = 1.6;
  1561. +                config_save( ct, "Matte", "16:10" );
  1562. +            } else if( matte_mode == 2 ) {
  1563. +                matte = 16.0/9.0;
  1564. +                config_save( ct, "Matte", "16:9" );
  1565. +            } else if( matte_mode == 3 ) {
  1566. +                matte = 1.85;                    
  1567. +                config_save( ct, "Matte", "1.85:1" );
  1568. +            } else if( matte_mode == 4 ) {
  1569. +                matte = 2.35;
  1570. +                config_save( ct, "Matte", "2.35:1" );
  1571. +            }
  1572. +
  1573. +            if( sixteennine && matte < (16.0/9.0) )
  1574. +            {
  1575. +                matte_w = (int) (((double) sqheight * matte) + 0.5);
  1576. +                matte_x = (width - matte_w) / 2;                  
  1577. +                output->set_matte( matte_w, sqheight );
  1578. +            } else {
  1579. +                matte_h = (int) ((((double) sqwidth)/matte) + 0.5);
  1580. +                matte_y = (height - matte_h) / 2;
  1581. +                output->set_matte( sqwidth, matte_h );
  1582. +            }
  1583. +        }
  1584. +
  1585.          if( commands_toggle_pulldown_detection( commands ) ) {
  1586.              if( height == 480 ) {
  1587.                  tvtime->pulldown_alg =
  1588. @@ -2565,14 +2545,14 @@
  1589.      snprintf( number, 4, "%d", quiet_screenshots );
  1590.      config_save( ct, "QuietScreenshots", number );
  1591.  
  1592. -    snprintf( number, 6, "%d", mixer_get_unmute_volume() );
  1593. +    snprintf( number, 6, "%d", mixer->get_unmute_volume() );
  1594.      config_save( ct, "UnmuteVolume", number );
  1595.  
  1596. -    snprintf( number, 4, "%d", mixer_ismute() );
  1597. +    snprintf( number, 4, "%d", mixer->ismute() );
  1598.      config_save( ct, "Muted", number );
  1599.  
  1600.      if( config_get_mute_on_exit( ct ) ) {
  1601. -        mixer_mute( 1 );
  1602. +        mixer->mute( 1 );
  1603.      }
  1604.  
  1605.      if( vidin ) {
  1606. @@ -2619,7 +2599,7 @@
  1607.      if( osd ) {
  1608.          tvtime_osd_delete( osd );
  1609.      }
  1610. -    mixer_close_device();
  1611. +    mixer->close_device();
  1612.  
  1613.      /* Free temporary memory. */
  1614.      free( colourbars );
  1615. diff -Nur tvtime-1.0.2/src/tvtimeconf.c tvtime-1.0.2-custom/src/tvtimeconf.c
  1616. --- tvtime-1.0.2/src/tvtimeconf.c       2005-09-08 06:07:56.000000000 +0200
  1617. +++ tvtime-1.0.2-custom/src/tvtimeconf.c        2011-05-29 18:44:24.957776112 +0200
  1618. @@ -56,6 +56,7 @@
  1619.      char *geometry;
  1620.      int verbose;
  1621.      int aspect;
  1622. +    int matte;
  1623.      int squarepixels;
  1624.      int debug;
  1625.      int fullscreen;
  1626. @@ -290,6 +291,22 @@
  1627.              ct->aspect = atoi( curval );
  1628.          }
  1629.  
  1630. +        if( !xmlStrcasecmp( name, BAD_CAST "Matte" ) ) {            
  1631. +            if(!strcmp( curval, "4:3")) {
  1632. +                ct->matte = 0;
  1633. +            } else if(!strcmp( curval, "16:10")) {
  1634. +                ct->matte = 1;
  1635. +            } else if(!strcmp( curval, "16:9")) {
  1636. +                ct->matte = 2;
  1637. +            } else if(!strcmp( curval, "1.85:1")) {
  1638. +                ct->matte = 3;
  1639. +            } else if(!strcmp( curval, "2.35:1")) {
  1640. +                ct->matte = 4;
  1641. +            }
  1642. +            /* No valid matte if found ct->matte will be -1 and config_get_matte will choose
  1643. +               a default based on the aspect ratio. */
  1644. +        }
  1645. +
  1646.          if( !xmlStrcasecmp( name, BAD_CAST "DebugMode" ) ) {
  1647.              ct->debug = atoi( curval );
  1648.          }
  1649. @@ -629,9 +646,11 @@
  1650.      lfputs( _("  -l, --xmltvlanguage=LANG   Use XMLTV data in given language, if available.\n"), stderr );
  1651.      lfputs( _("  -v, --verbose              Print debugging messages to stderr.\n"), stderr );
  1652.      lfputs( _("  -X, --display=DISPLAY      Use the given X display to connect to.\n"), stderr );
  1653. -    lfputs( _("  -x, --mixer=DEVICE[:CH]    The mixer device and channel to control.\n"
  1654. -              "                             (defaults to /dev/mixer:line)\n\n"
  1655. -              "                             Valid channels are:\n"
  1656. +    lfputs( _("  -x, --mixer=<DEVICE[:CH]>|<DEVICE/CH>\n"
  1657. +              "                             The mixer device and channel to control. The first\n"
  1658. +              "                             variant sets the OSS mixer the second one ALSA.\n"
  1659. +              "                             (defaults to default/Line)\n\n"
  1660. +              "                             Valid channels for OSS are:\n"
  1661.                "                                 vol, bass, treble, synth, pcm, speaker, line,\n"
  1662.                "                                 mic, cd, mix, pcm2, rec, igain, ogain, line1,\n"
  1663.                "                                 line2, line3, dig1, dig2, dig3, phin, phout,\n"
  1664. @@ -677,9 +696,11 @@
  1665.      lfputs( _("  -R, --priority=PRI         Sets the process priority to run tvtime at.\n"), stderr );
  1666.      lfputs( _("  -t, --xmltv=FILE           Read XMLTV listings from the given file.\n"), stderr );
  1667.      lfputs( _("  -l, --xmltvlanguage=LANG   Use XMLTV data in given language, if available.\n"), stderr );
  1668. -    lfputs( _("  -x, --mixer=DEVICE[:CH]    The mixer device and channel to control.\n"
  1669. -              "                             (defaults to /dev/mixer:line)\n\n"
  1670. -              "                             Valid channels are:\n"
  1671. +    lfputs( _("  -x, --mixer=<DEVICE[:CH]>|<DEVICE/CH>\n"
  1672. +              "                             The mixer device and channel to control. The first\n"
  1673. +              "                             variant sets the OSS mixer the second one ALSA.\n"
  1674. +              "                             (defaults to default/Line)\n\n"
  1675. +              "                             Valid channels for OSS are:\n"
  1676.                "                                 vol, bass, treble, synth, pcm, speaker, line,\n"
  1677.                "                                 mic, cd, mix, pcm2, rec, igain, ogain, line1,\n"
  1678.                "                                 line2, line3, dig1, dig2, dig3, phin, phout,\n"
  1679. @@ -712,6 +733,7 @@
  1680.      ct->geometry = strdup( "0x576" );
  1681.      ct->verbose = 0;
  1682.      ct->aspect = 0;
  1683. +    ct->matte = -1;
  1684.      ct->squarepixels = 1;
  1685.      ct->debug = 0;
  1686.      ct->fullscreen = 0;
  1687. @@ -764,7 +786,7 @@
  1688.  
  1689.      ct->uid = getuid();
  1690.  
  1691. -    ct->mixerdev = strdup( "/dev/mixer:line" );
  1692. +    ct->mixerdev = strdup( "default/Line" );
  1693.  
  1694.      ct->deinterlace_method = strdup( "GreedyH" );
  1695.      ct->check_freq_present = 1;
  1696. @@ -807,6 +829,10 @@
  1697.      ct->keymap[ 'a' ] = TVTIME_TOGGLE_ASPECT;
  1698.      ct->keymap[ 'f' ] = TVTIME_TOGGLE_FULLSCREEN;
  1699.      ct->keymap[ 'i' ] = TVTIME_TOGGLE_INPUT;
  1700. +    ct->keymap[ 'a' ] = TVTIME_TOGGLE_ASPECT;
  1701. +    ct->keymap[ I_INSERT ] = TVTIME_TOGGLE_MATTE;
  1702. +    ct->keymap[ ',' ] = TVTIME_OVERSCAN_DOWN;
  1703. +    ct->keymap[ '.' ] = TVTIME_OVERSCAN_DOWN;
  1704.      ct->keymap[ 's' ] = TVTIME_SCREENSHOT;
  1705.      ct->keymap[ ',' ] = TVTIME_MIXER_TOGGLE_MUTE;
  1706.      ct->keymap[ 'e' ] = TVTIME_TOGGLE_AUDIO_MODE;
  1707. @@ -1451,6 +1477,13 @@
  1708.      return ct->aspect;
  1709.  }
  1710.  
  1711. +int config_get_matte( config_t *ct )
  1712. +{
  1713. +    /* If matte is not set then default to 0 for normal or 2 for widescreen. */
  1714. +    if (ct->matte == -1) return ct->aspect * 2;
  1715. +    return ct->matte;
  1716. +}
  1717. +
  1718.  int config_get_start_channel( config_t *ct )
  1719.  {
  1720.      return ct->start_channel;
  1721. diff -Nur tvtime-1.0.2/src/tvtimeconf.h tvtime-1.0.2-custom/src/tvtimeconf.h
  1722. --- tvtime-1.0.2/src/tvtimeconf.h       2005-08-14 19:00:11.000000000 +0200
  1723. +++ tvtime-1.0.2-custom/src/tvtimeconf.h        2011-05-29 18:44:24.967776132 +0200
  1724. @@ -151,6 +151,7 @@
  1725.  const char *config_get_geometry( config_t *ct );
  1726.  int config_get_inputwidth( config_t *ct );
  1727.  int config_get_aspect( config_t *ct );
  1728. +int config_get_matte( config_t *ct );
  1729.  int config_get_inputnum( config_t *ct );
  1730.  const char *config_get_v4l_device( config_t *ct );
  1731.  const char *config_get_v4l_norm( config_t *ct );
  1732. diff -Nur tvtime-1.0.2/src/videodev2.h tvtime-1.0.2-custom/src/videodev2.h
  1733. --- tvtime-1.0.2/src/videodev2.h        2005-01-17 03:36:40.000000000 +0100
  1734. +++ tvtime-1.0.2-custom/src/videodev2.h 2011-05-29 18:44:24.971109472 +0200
  1735. @@ -16,7 +16,6 @@
  1736.  #ifdef __KERNEL__
  1737.  #include <linux/time.h> /* need struct timeval */
  1738.  #endif
  1739. -#include <linux/compiler.h> /* need __user */
  1740.  
  1741.  /* for kernel versions 2.4.26 and below: */
  1742.  #ifndef __user
  1743. diff -Nur tvtime-1.0.2/src/videoinput.c tvtime-1.0.2-custom/src/videoinput.c
  1744. --- tvtime-1.0.2/src/videoinput.c       2005-09-08 05:13:37.000000000 +0200
  1745. +++ tvtime-1.0.2-custom/src/videoinput.c        2011-05-29 18:44:24.974442812 +0200
  1746. @@ -376,7 +376,9 @@
  1747.  
  1748.          wait_for_frame_v4l2( vidin );
  1749.  
  1750. +        videoinput_get_aspect( vidin );
  1751.          cur_buf.type = vidin->capbuffers[ 0 ].vidbuf.type;
  1752. +        cur_buf.memory = vidin->capbuffers[ 0 ].vidbuf.memory;
  1753.          if( ioctl( vidin->grab_fd, VIDIOC_DQBUF, &cur_buf ) < 0 ) {
  1754.              /* some drivers return EIO when there is no signal */
  1755.              if( errno != EIO ) {
  1756. @@ -1148,6 +1150,22 @@
  1757.      }
  1758.  }
  1759.  
  1760. +float videoinput_get_aspect( videoinput_t *vidin )
  1761. +{
  1762. +    float aspect = 1.0;
  1763. +
  1764. +    if( vidin->isv4l2 ) {
  1765. +        struct v4l2_cropcap cropcap;
  1766. +        /* on success 0 is returned */
  1767. +        if( !ioctl( vidin->grab_fd, VIDIOC_CROPCAP, &cropcap ) ) {
  1768. +            aspect = (float)cropcap.pixelaspect.numerator / (float)cropcap.pixelaspect.denominator;
  1769. +            fprintf( stderr, "videoinput: Aspect ratio: %f\n", aspect);        
  1770. +        }
  1771. +    }
  1772. +  
  1773. +    return aspect;
  1774. +}
  1775. +
  1776.  static void videoinput_do_mute( videoinput_t *vidin, int mute )
  1777.  {
  1778.      if( vidin->hasaudio && mute != vidin->hw_muted ) {
  1779. @@ -1269,7 +1287,7 @@
  1780.          }
  1781.  
  1782.          vidin->change_muted = 1;
  1783. -        mixer_mute( 1 );
  1784. +        mixer->mute( 1 );
  1785.          videoinput_do_mute( vidin, vidin->user_muted || vidin->change_muted );
  1786.          vidin->cur_tuner_state = TUNER_STATE_SIGNAL_DETECTED;
  1787.          vidin->signal_acquire_wait = SIGNAL_ACQUIRE_DELAY;
  1788. @@ -1620,7 +1638,7 @@
  1789.              if( vidin->change_muted ) {
  1790.                  vidin->change_muted = 0;
  1791.                  videoinput_do_mute( vidin, vidin->user_muted || vidin->change_muted );
  1792. -                mixer_mute( 0 );
  1793. +                mixer->mute( 0 );
  1794.              }
  1795.              break;
  1796.          }
  1797. @@ -1631,7 +1649,7 @@
  1798.              vidin->cur_tuner_state = TUNER_STATE_SIGNAL_LOST;
  1799.              vidin->signal_recover_wait = SIGNAL_RECOVER_DELAY;
  1800.              vidin->change_muted = 1;
  1801. -            mixer_mute( 1 );
  1802. +            mixer->mute( 1 );
  1803.              videoinput_do_mute( vidin, vidin->user_muted || vidin->change_muted );
  1804.          case TUNER_STATE_SIGNAL_LOST:
  1805.              if( vidin->signal_recover_wait ) {
  1806. diff -Nur tvtime-1.0.2/src/videoinput.h tvtime-1.0.2-custom/src/videoinput.h
  1807. --- tvtime-1.0.2/src/videoinput.h       2005-09-08 04:55:10.000000000 +0200
  1808. +++ tvtime-1.0.2-custom/src/videoinput.h        2011-05-29 18:44:24.981109492 +0200
  1809. @@ -71,6 +71,8 @@
  1810.  #define VIDEOINPUT_LANG1   4
  1811.  #define VIDEOINPUT_LANG2   8
  1812.  
  1813. +float videoinput_get_aspect( videoinput_t *vidin );
  1814. +
  1815.  /**
  1816.   * Possible PAL audio modes, for the cx88 driver that cannot autodetect.
  1817.   */
  1818. diff -Nur tvtime-1.0.2/src/xcommon.c tvtime-1.0.2-custom/src/xcommon.c
  1819. --- tvtime-1.0.2/src/xcommon.c  2005-08-14 19:36:52.000000000 +0200
  1820. +++ tvtime-1.0.2-custom/src/xcommon.c   2011-05-29 18:44:24.987776172 +0200
  1821. @@ -25,6 +25,7 @@
  1822.  #include <stdio.h>
  1823.  #include <stdlib.h>
  1824.  #include <string.h>
  1825. +#include <unistd.h>
  1826.  
  1827.  #if defined(__FreeBSD__)
  1828.  #include <machine/param.h>
  1829. @@ -45,8 +46,8 @@
  1830.  #include <X11/keysym.h>
  1831.  #include <X11/cursorfont.h>
  1832.  #include <X11/extensions/XShm.h>
  1833. -#ifdef HAVE_XTESTEXTENSION
  1834. -#include <X11/extensions/XTest.h>
  1835. +#ifdef HAVE_XSSEXTENSION
  1836. +#include <X11/extensions/scrnsaver.h>
  1837.  #endif
  1838.  
  1839.  #include "xfullscreen.h"
  1840. @@ -67,7 +68,7 @@
  1841.  static Window fs_window;
  1842.  static Window output_window;
  1843.  static GC gc;
  1844. -static int have_xtest;
  1845. +static int have_xss;
  1846.  static int output_width, output_height;
  1847.  static int output_aspect;
  1848.  static int output_on_root;
  1849. @@ -106,10 +107,7 @@
  1850.  static Atom wm_delete_window;
  1851.  static Atom xawtv_station;
  1852.  static Atom xawtv_remote;
  1853. -
  1854. -#ifdef HAVE_XTESTEXTENSION
  1855. -static KeyCode kc_shift_l; /* Fake key to send. */
  1856. -#endif
  1857. +static Atom net_wm_pid;
  1858.  
  1859.  static area_t video_area;
  1860.  static area_t window_area;
  1861. @@ -150,11 +148,12 @@
  1862.          "WM_PROTOCOLS",
  1863.          "WM_DELETE_WINDOW",
  1864.          "_XAWTV_STATION",
  1865. -        "_XAWTV_REMOTE"
  1866. +        "_XAWTV_REMOTE",
  1867. +        "_NET_WM_PID"
  1868.      };
  1869. -    Atom atoms_return[ 17 ];
  1870. +    Atom atoms_return[ 18 ];
  1871.  
  1872. -    XInternAtoms( display, atom_names, 17, False, atoms_return );
  1873. +    XInternAtoms( display, atom_names, 18, False, atoms_return );
  1874.      net_supporting_wm_check = atoms_return[ 0 ];
  1875.      net_supported = atoms_return[ 1 ];
  1876.      net_wm_name = atoms_return[ 2 ];
  1877. @@ -172,6 +171,7 @@
  1878.      wm_delete_window = atoms_return[ 14 ];
  1879.      xawtv_station = atoms_return[ 15 ];
  1880.      xawtv_remote = atoms_return[ 16 ];
  1881. +    net_wm_pid = atoms_return[ 17 ];
  1882.  }
  1883.  
  1884.  static uint32_t icon_colours[256];
  1885. @@ -248,12 +248,12 @@
  1886.      } while ( (event.type != MapNotify) || (event.xmap.event != win) );
  1887.  }
  1888.  
  1889. -static int have_xtestextention( void )
  1890. +static int have_xssextention( void )
  1891.  {  
  1892. -#ifdef HAVE_XTESTEXTENSION
  1893. -    int dummy1, dummy2, dummy3, dummy4;
  1894. +#ifdef HAVE_XSSEXTENSION
  1895. +    int dummy1, dummy2;
  1896.    
  1897. -    return (XTestQueryExtension( display, &dummy1, &dummy2, &dummy3, &dummy4 ) == True);
  1898. +    return (XScreenSaverQueryExtension( display, &dummy1, &dummy2 ) == True);
  1899.  #endif
  1900.      return 0;
  1901.  }
  1902. @@ -843,7 +843,7 @@
  1903.      output_aspect = aspect;
  1904.      output_height = 576;
  1905.  
  1906. -    have_xtest = 0;
  1907. +    have_xss = 0;
  1908.      output_on_root = 0;
  1909.      has_ewmh_state_fullscreen = 0;
  1910.      has_ewmh_state_above = 0;
  1911. @@ -927,13 +927,16 @@
  1912.          xfullscreen_print_summary( xf );
  1913.      }
  1914.  
  1915. -#ifdef HAVE_XTESTEXTENSION
  1916. -    kc_shift_l = XKeysymToKeycode( display, XK_Shift_L );
  1917. -#endif
  1918. -    have_xtest = have_xtestextention();
  1919. -    if( have_xtest && xcommon_verbose ) {
  1920. -        fprintf( stderr, "xcommon: Have XTest, will use it to ping the screensaver.\n" );
  1921. +    have_xss = have_xssextention();
  1922. +    if( have_xss && xcommon_verbose ) {
  1923. +        fprintf( stderr, "xcommon: Have XSS, will use it to disable the screensaver.\n" );
  1924. +    }
  1925. +
  1926. +#ifdef HAVE_XSSEXTENSION
  1927. +    if ( have_xss ) {
  1928. +        XScreenSaverSuspend( display, True );
  1929.      }
  1930. +#endif
  1931.  
  1932.      /* Initially, get the best width for our height. */
  1933.      output_width = xv_get_width_for_height( output_height );
  1934. @@ -1017,6 +1020,16 @@
  1935.              free( data );
  1936.          }
  1937.      }
  1938. +    
  1939. +    /* Set _NET_WM_PID */
  1940. +    {
  1941. +        if( xcommon_verbose ) {
  1942. +            fprintf( stderr, "xcommon: try to set _NET_WM_PID" );
  1943. +        }
  1944. +        pid_t mypid = getpid();
  1945. +        XChangeProperty(display, wm_window, net_wm_pid, cardinal, 32,
  1946. +                        PropModeReplace, (const unsigned char*) &mypid, 1);
  1947. +    }
  1948.  
  1949.      if( check_for_EWMH_wm( display, &wmname ) ) {
  1950.          if( xcommon_verbose ) {
  1951. @@ -1112,15 +1125,7 @@
  1952.      gettimeofday( &curtime, 0 );
  1953.      if( timediff( &curtime, &last_ping_time ) > SCREENSAVER_PING_TIME ) {
  1954.          last_ping_time = curtime;
  1955. -#ifdef HAVE_XTESTEXTENSION
  1956. -        if( have_xtest ) {
  1957. -            XTestFakeKeyEvent( display, kc_shift_l, True, CurrentTime );
  1958. -            XTestFakeKeyEvent( display, kc_shift_l, False, CurrentTime );
  1959. -        } else
  1960. -#endif
  1961. -        {
  1962. -            XResetScreenSaver( display );
  1963. -        }
  1964. +        XResetScreenSaver( display );
  1965.      }
  1966.  }
  1967.  
  1968. @@ -1715,6 +1720,11 @@
  1969.  
  1970.  void xcommon_close_display( void )
  1971.  {
  1972. +#ifdef HAVE_XSSEXTENSION
  1973. +    if ( have_xss ) {
  1974. +        XScreenSaverSuspend( display, False );
  1975. +    }
  1976. +#endif
  1977.      XDestroyWindow( display, output_window );
  1978.      XDestroyWindow( display, wm_window );
  1979.      XDestroyWindow( display, fs_window );
  1980. diff -Nur tvtime-1.0.2/src/xfullscreen.c tvtime-1.0.2-custom/src/xfullscreen.c
  1981. --- tvtime-1.0.2/src/xfullscreen.c      2004-10-14 02:12:02.000000000 +0200
  1982. +++ tvtime-1.0.2-custom/src/xfullscreen.c       2011-05-29 18:44:25.011109552 +0200
  1983. @@ -263,6 +263,10 @@
  1984.          int max_area = -1;
  1985.          int i;
  1986.  
  1987. +        *x = xf->heads[ 0 ].x;
  1988. +        *y = xf->heads[ 0 ].y;
  1989. +        *w = xf->heads[ 0 ].w;
  1990. +        *h = xf->heads[ 0 ].h;
  1991.          for( i = 0; i < xf->nheads; i++ ) {
  1992.              int head_x1 = xf->heads[ i ].x;
  1993.              int head_x2 = xf->heads[ i ].x + xf->heads[ i ].w - 1;
  1994. diff -Nur tvtime-1.0.2/src/xmltv.c tvtime-1.0.2-custom/src/xmltv.c
  1995. --- tvtime-1.0.2/src/xmltv.c    2004-09-26 18:40:01.000000000 +0200
  1996. +++ tvtime-1.0.2-custom/src/xmltv.c     2011-05-29 18:44:25.014442892 +0200
  1997. @@ -118,9 +118,9 @@
  1998.  typedef struct {
  1999.      const char *code;
  2000.      const char *name;
  2001. -} locale_t;
  2002. +} tv_locale_t;
  2003.  
  2004. -static locale_t locale_table[] = {
  2005. +static tv_locale_t locale_table[] = {
  2006.      {"AA", "Afar"},           {"AB", "Abkhazian"},      {"AF", "Afrikaans"},
  2007.      {"AM", "Amharic"},        {"AR", "Arabic"},         {"AS", "Assamese"},
  2008.      {"AY", "Aymara"},         {"AZ", "Azerbaijani"},    {"BA", "Bashkir"},
  2009. @@ -168,7 +168,7 @@
  2010.      {"XH", "Xhosa"},          {"YO", "Yoruba"},         {"ZH", "Chinese"},
  2011.      {"ZU", "Zulu"} };
  2012.  
  2013. -const int num_locales = sizeof( locale_table ) / sizeof( locale_t );
  2014. +const int num_locales = sizeof( locale_table ) / sizeof( tv_locale_t );
  2015.  
  2016.  /**
  2017.   * Timezone parsing code based loosely on the algorithm in
  2018. diff -Nur tvtime-1.0.2/src/xvoutput.c tvtime-1.0.2-custom/src/xvoutput.c
  2019. --- tvtime-1.0.2/src/xvoutput.c 2005-08-14 19:35:50.000000000 +0200
  2020. +++ tvtime-1.0.2-custom/src/xvoutput.c  2011-05-29 18:44:25.014442892 +0200
  2021. @@ -233,7 +233,7 @@
  2022.  {
  2023.      int size;
  2024.      uint8_t *alloc;
  2025. -
  2026. +    
  2027.      size = input_width * input_height * 2;
  2028.      if( use_shm ) {
  2029.          alloc = create_shm( size );