tvtime crashes when no device is attached/tvtime does not work when handset is attached

Bug #575938 reported by MarkusRechberger
60
This bug affects 12 people
Affects Status Importance Assigned to Milestone
tvtime (Ubuntu)
Fix Released
Low
Unassigned
Declined for Dapper by Scott Kitterman
Declined for Hardy by Daniel T Chen
Declined for Jaunty by Scott Kitterman
Declined for Karmic by Scott Kitterman
Declined for Lucid by Sebastien Bacher
Declined for Maverick by Sebastien Bacher

Bug Description

Binary package hint: tvtime

the audio patch from whoopie introduces some issues

1. tvtime will not start when a particular USB Audio device is attached which does not support 2 channels(stereo), a USB Handset can cause this issue

2. tvtime will crash when there's no device attached

the attached patch fixes the crash when no device is attached and ignore audio when there are problems.

Tags: tvtime

Related branches

Revision history for this message
MarkusRechberger (mrechberger) wrote :

attached the diff for tvtime.c and audiolib.c

Revision history for this message
MarkusRechberger (mrechberger) wrote :

the tvtime.c diff is messed up with other changes here are the relevant ones for tvtime.c:

@@ -1204,11 +1176,14 @@
     int matte_y = 0;
     int matte_h = 0;
     int matte_mode = 0;
     int restarttvtime = 0;
     int return_value = 0;
     int last_current_id = -1;
     int quiet_screenshots = 0;
     char prevloc[ 256 ];
+ int audio_state = 0;

@@ -2069,9 +2054,34 @@

         if( tuner_state == TUNER_STATE_HAS_SIGNAL ) {
             has_signal = 1;
+ /* reopen the device for now, there are several issues which don't allow pausing the
+ audio data transfer.
+
+ TODO:
+ The driver(?) seems to crash when setting up the alsa parameters again during the same
+ session.
+ */
+
+ if (empia_device && audio_state == 0 && videoinput_get_audio(vidin) == NULL) {
+ videoinput_set_audio(vidin, alsa_open(empia_device, "default", SND_PCM_FORMAT_S16_LE, 2 /* 2 channels */, 48000 /* rate */));
+ if (videoinput_get_audio(vidin)) {
+ audio_state=0;
+ printf("starting alsa transfer\n");
+ alsa_start_threaded_loop(videoinput_get_audio(vidin));
+ } else {
+ audio_state=-1;
+ }
+ }
+
             if( osd ) tvtime_osd_signal_present( osd, 1 );
         } else if( tuner_state == TUNER_STATE_NO_SIGNAL ) {
             if( osd ) tvtime_osd_signal_present( osd, 0 );
+ if (vidin && videoinput_get_audio(vidin)) {
+ alsa_join_threaded_loop(videoinput_get_audio(vidin));
+ alsa_close(videoinput_get_audio_p(vidin));
+ videoinput_set_audio(vidin, NULL);
+ }
+
             if( fadepos < 256 ) {
                 crossfade_frame( fadeframe, saveframe, blueframe, width,
                                  height, width*2, width*2, width*2, fadepos );
@@ -2511,6 +2521,11 @@
     /* Return to normal scheduling. */
     set_default_priority();

+ if (vidin && videoinput_get_audio(vidin)) {
+ alsa_join_threaded_loop(videoinput_get_audio(vidin));
+ alsa_close(videoinput_get_audio_p(vidin));
+ }
+
     /* Remember to save our settings if we were scanning. */
     if( scanning ) {
         station_writeconfig( stationmgr );

Revision history for this message
Peter Meiser (meiser79) wrote :

Hi Markus, could you review the attached patch if it includes all needed changes?

Then, I would create a debdiff and ask for an SRU.

Thanks,
Whoopie

Revision history for this message
MarkusRechberger (mrechberger) wrote : Re: [Bug 575938] Re: tvtime crashes when no device is attached/tvtime does not work when handset is attached

Hi,

On Thu, May 6, 2010 at 12:10 PM, Whoopie <email address hidden> wrote:
> Hi Markus, could you review the attached patch if it includes all needed
> changes?
>
> Then, I would create a debdiff and ask for an SRU.
>

the vidin checks are missing in tvtime.c this still causes tvtime to
crash when no device is attached.

Markus

> Thanks,
> Whoopie
>
> ** Patch added: "tvtime-alsa.diff"
>   http://launchpadlibrarian.net/47923044/tvtime-alsa.diff
>
> --
> tvtime crashes when no device is attached/tvtime does not work when handset is attached
> https://bugs.launchpad.net/bugs/575938
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Revision history for this message
Peter Meiser (meiser79) wrote :

Ok, new patch attached.

Revision history for this message
MarkusRechberger (mrechberger) wrote :

---- tvtime-1.0.2.orig/src/videoinput.h
-+++ tvtime-1.0.2/src/videoinput.h
-@@ -280,6 +280,20 @@ int videoinput_get_pal_audio_mode( video
+diff -Naur a/src/videoinput.h b/src/videoinput.h
+--- a/src/videoinput.h 2010-05-06 11:46:09.000000000 +0200
++++ b/src/videoinput.h 2010-05-06 11:40:37.000000000 +0200
+@@ -280,6 +280,20 @@
  const char *videoinput_get_driver_name( videoinput_t *vidin );

  /**

such diffs are a little bit confusing, can you just create a final
package and I will test? :)

Markus

On Thu, May 6, 2010 at 12:58 PM, Whoopie <email address hidden> wrote:
> Ok, new patch attached.
>
> ** Patch added: "tvtime-alsa.diff"
>   http://launchpadlibrarian.net/47925125/tvtime-alsa.diff
>
> --
> tvtime crashes when no device is attached/tvtime does not work when handset is attached
> https://bugs.launchpad.net/bugs/575938
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Revision history for this message
MarkusRechberger (mrechberger) wrote :

On Thu, May 6, 2010 at 1:18 PM, Markus Rechberger <email address hidden> wrote:
> ---- tvtime-1.0.2.orig/src/videoinput.h
> -+++ tvtime-1.0.2/src/videoinput.h
> -@@ -280,6 +280,20 @@ int videoinput_get_pal_audio_mode( video
> +diff -Naur a/src/videoinput.h b/src/videoinput.h
> +--- a/src/videoinput.h 2010-05-06 11:46:09.000000000 +0200
> ++++ b/src/videoinput.h 2010-05-06 11:40:37.000000000 +0200
> +@@ -280,6 +280,20 @@
>  const char *videoinput_get_driver_name( videoinput_t *vidin );
>
>  /**
>
>
> such diffs are a little bit confusing, can you just create a final
> package and I will test? :)

aside of that it seems that you picked all changes now.

>
> Markus
>
> On Thu, May 6, 2010 at 12:58 PM, Whoopie <email address hidden> wrote:
>> Ok, new patch attached.
>>
>> ** Patch added: "tvtime-alsa.diff"
>>   http://launchpadlibrarian.net/47925125/tvtime-alsa.diff
>>
>> --
>> tvtime crashes when no device is attached/tvtime does not work when handset is attached
>> https://bugs.launchpad.net/bugs/575938
>> You received this bug notification because you are a direct subscriber
>> of the bug.
>>
>

Revision history for this message
Peter Meiser (meiser79) wrote :

Building a package in my testing PPA now -> https://launchpad.net/~whoopie79/+archive/testing/+packages

Revision history for this message
MarkusRechberger (mrechberger) wrote :

On Thu, May 6, 2010 at 2:34 PM, Whoopie <email address hidden> wrote:
> Building a package in my testing PPA now ->
> https://launchpad.net/~whoopie79/+archive/testing/+packages
>

this works fine thanks for putting everything together.

I did following tests:
* tvtime does not work with uvcvideo but should not crash it either -
this is solved now
* tvtime did not start up when my skype handset was attached - this is
also solved now

 --
> tvtime crashes when no device is attached/tvtime does not work when handset is attached
> https://bugs.launchpad.net/bugs/575938
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Revision history for this message
Peter Meiser (meiser79) wrote :

Here the debdiff.

Revision history for this message
MarkusRechberger (mrechberger) wrote :

when starting tvtime from the menu tvtime will usually not work because the first device usually is a webcam.
please replace videoinput_new() in tvtime.c with following implementation, it will search /dev for alternative video devices if the default videodevice is inappropriate

    /* something else than default is given */
    if (strcmp(config_get_v4l_device ( ct ), "/dev/video0")!=0) {
       vidin = videoinput_new( config_get_v4l_device( ct ),
                               config_get_inputwidth( ct ),
                               config_get_audio_boost( ct ),
                               norm, verbose, error_string2 );
    } else {
       vidin = videoinput_new( config_get_v4l_device( ct ),
                               config_get_inputwidth( ct ),
                               config_get_audio_boost( ct ),
                               norm, verbose, error_string2 );
       if (!vidin) {
           DIR *dirp;
           struct dirent *dp;

           dirp = opendir("/dev");
           if (dirp) {
              while(vidin == NULL && (dp=readdir(dirp))!=NULL) {
                 if (strncmp(dp->d_name, "video", 5)==0) {
                   char vidpath[21];
                   memset(vidpath, 0x0, sizeof(vidpath));
                   snprintf(vidpath, 20, "/dev/%s", dp->d_name);

                   lfprintf( stderr, _("retrying with: %s\n"), vidpath);
                   vidin = videoinput_new( vidpath,
                                           config_get_inputwidth( ct ),
                                           config_get_audio_boost( ct ),
                                           norm, verbose, error_string2 );
                 }
              }
              closedir(dirp);
           }
       }
    }

Revision history for this message
yaztromo (tromo) wrote :

@Whoopie.

Upgrade from karmic to lucid broke tvtime on my system. I'm using an Audiophile USB with ALSA. The tvtime package in your ppa fixed it. Many thanks!

Revision history for this message
new4u (new4u) wrote :

@Whoopie,

Upgrade (clean install) from karmic 64 bit where everything worked to lucid 64 bit which broke tvtime on my system. I'm using an Logitec USB webcam. The tvtime package in your ppa fixed it. Many thanks!

Changed in tvtime (Ubuntu):
status: New → Confirmed
Revision history for this message
Sebastien Bacher (seb128) wrote :

is that still an issue in the maverick version? it would be nice to send the change to upstream and debian

Changed in tvtime (Ubuntu):
importance: Undecided → Low
Revision history for this message
Steffen Röcker (sroecker) wrote :

Yes. debian doesn't include the alsa patch so it's not affected.

Revision history for this message
Christophe Van Reusel (christophevr) wrote :

Hello Sebastien

Yes It's still an issue into maverick. For the usb problem you still can blacklist the usb audio if You don't need the usb mic or another usb audio input by adding blacklist snd-usb-audio to the /etc/modprobe.d/blacklist.conf file.

For the wrong device which doesn't allow tvtime to start there is a little work-around :

If you tvtuner is a pci device, just boot up pc whith usb camera unplugged, then look up into path /dev/v4l/by-path
There you will find a link named pci-xxxxxx-video-index0 just look tif the link is to /dev/video0 if it's the case , and tvtime runs now when you added into tvtime config file <option name="V4LDevice" value="/dev/video0" /> Change this line with the link found into /dev/v4l/by-path for me it is <option name="V4LDevice" value="/dev/v4l/by-path/pci-0000:04:02.0-video-index0"/>

If I now plugin the usb webcam or out nothing changes. If I boot with webcam in the webcam receives /dev/video0 and the pci tvtuner receives video1 if I boot with webcam unplugged pci device has video0 obviously if i plugin webcam after boot it will have video1 . But tvtime starts now always with my tv tuner since I put pci-0000:04:02.0-video-index0 for the v4l device option.

BUT THE BEST AND SIMPLEST WAY , VERY VERY THANKS to WHOOPIE,

Just install first tvtime from ubuntu itself with synaptic or apt-get. then download Whoopie's very good made deb package for your sytem for me it is amd64 . That wich is made for lucid does work very well into maverick . and install it with sudo dpkg -i .
it will replace the basic tvtime, other libs who are required into maverick will already be present.

and then tvtime runs perfect without having to blacklist snd-usb-audio.

Revision history for this message
Christophe Van Reusel (christophevr) wrote :

Also a small for Maverick,

Maverick does not have anymore /dev/mixer . So there is now unmuting mixer setting anymore during tvtime start possible. You will habe to use alsamixer for that. I use gnome-alsa-mixer for that. Yes ennoying But's its' life.

Revision history for this message
Christophe Van Reusel (christophevr) wrote :

Also an extra add About maverick,

Currently there is no oss-support at all , As the very well basic oss emu and other stuff is anyway present into the kernel source 2.6.35,

I hope that it's just something they've forgotten. Currently the last maverick generic kernel config has about oss

CONFIG_SOUND=m
# CONFIG_SOUND_OSS_CORE is not set
CONFIG_SND=m
CONFIG_SND_TIMER=m
CONFIG_SND_PCM=m
CONFIG_SND_HWDEP=m
CONFIG_SND_RAWMIDI=m
CONFIG_SND_JACK=y
CONFIG_SND_SEQUENCER=m
CONFIG_SND_SEQ_DUMMY=m
# CONFIG_SND_MIXER_OSS is not set
# CONFIG_SND_PCM_OSS is not set
# CONFIG_SND_SEQUENCER_OSS is not set

This should be :

CONFIG_SOUND=m
CONFIG_SOUND_OSS_CORE=y
CONFIG_SOUND_OSS_CORE_PRECLAIM=y
CONFIG_SND=m
CONFIG_SND_TIMER=m
CONFIG_SND_PCM=m
CONFIG_SND_HWDEP=m
CONFIG_SND_RAWMIDI=m
CONFIG_SND_JACK=y
CONFIG_SND_SEQUENCER=m
CONFIG_SND_SEQ_DUMMY=m
CONFIG_SND_OSSEMUL=y
CONFIG_SND_MIXER_OSS=m
CONFIG_SND_PCM_OSS=m
CONFIG_SND_PCM_OSS_PLUGINS=y
CONFIG_SND_SEQUENCER_OSS=y

Evidently the oss kernel sound core modules snd_pcm_oss and snd_mixer_oss are missing as well.
And those are needed for oss emu to work.

To have this all one the kernel, he unfortunately needs to be recompiled with those settings enabled.

And yes if ubuntu does not wan't to do that Ubuntu will be unusable for many even the majority of multimedia applications.as from Maverick

Revision history for this message
Bogoljub Popovic (bp21000) wrote :

@Whoopie:

Could youd rebuild (make bugfix) tvtime package for maverick, Version: 1.0.2-6.1ubuntu1
 and add it to your PPA?

Thanks a lot!

Revision history for this message
Steffen Röcker (sroecker) wrote :

This is still an issue for natty.

Applying Whoopie#s patch from post #5 fixes it.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package tvtime - 1.0.2-7ubuntu2

---------------
tvtime (1.0.2-7ubuntu2) precise; urgency=low

  * Update tvtime-1.0.2-alsa.patch to resolve crashes when the default
    video device is inappropriate. Patch from Markus Rechberger,
    thanks! (LP: #575938, #552060)
    - Delete tvtime-1.0.2-videoinput_get_audio-check-vidin.patch as a
      result.
    - Rediff tvtime-1.0.2-alsamixer.patch, pal_audio_mode_persistence.patch.
 -- Daniel T Chen <email address hidden> Sat, 05 Nov 2011 10:44:44 -0400

Changed in tvtime (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.