gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r11325: updated testsuites and findc


From: Ben Limmer
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11325: updated testsuites and findcam/mic utilities they should no longer segfault
Date: Tue, 28 Jul 2009 12:39:20 -0600
User-agent: Bazaar (1.13.1)

------------------------------------------------------------
revno: 11325
committer: Ben Limmer <address@hidden>
branch nick: trunk
timestamp: Tue 2009-07-28 12:39:20 -0600
message:
  updated testsuites and findcam/mic utilities they should no longer segfault
modified:
  libmedia/gst/AudioInputGst.cpp
  libmedia/gst/AudioInputGst.h
  libmedia/gst/VideoInputGst.cpp
  testsuite/libmedia.all/test_audioinput.cpp
  testsuite/libmedia.all/test_videoinput.cpp
  utilities/findmicrophones.cpp
  utilities/findwebcams.cpp
    ------------------------------------------------------------
    revno: 11317.2.1
    committer: Ben Limmer <address@hidden>
    branch nick: cam_mic_impl_2
    timestamp: Tue 2009-07-28 12:37:36 -0600
    message:
      update testsuites and utilities so they don't segfault
    modified:
      libmedia/gst/AudioInputGst.cpp
      libmedia/gst/AudioInputGst.h
      libmedia/gst/VideoInputGst.cpp
      testsuite/libmedia.all/test_audioinput.cpp
      testsuite/libmedia.all/test_videoinput.cpp
      utilities/findmicrophones.cpp
      utilities/findwebcams.cpp
=== modified file 'libmedia/gst/AudioInputGst.cpp'
--- a/libmedia/gst/AudioInputGst.cpp    2009-07-27 15:44:55 +0000
+++ b/libmedia/gst/AudioInputGst.cpp    2009-07-28 18:37:36 +0000
@@ -353,8 +353,6 @@
         
         ok = gst_bin_add(GST_BIN(audio->_audioPlaybackBin), autosink);
         
-        ok &= gst_bin_add(GST_BIN(audio->_pipeline), audio->_audioPlaybackBin);
-        
         //create ghostpad which can be used to connect this bin to the
         //video_display_queue src ghostpad
         pad = gst_element_get_pad (autosink, "sink");
@@ -366,6 +364,11 @@
     
     gboolean
     AudioInputGst::makeAudioSourcePlaybackLink(GnashAudioPrivate *audio) {
+        if (gst_bin_get_by_name(GST_BIN(audio->_pipeline), "playbackBin") == 
NULL) {
+            gst_object_ref(audio->_audioPlaybackBin);
+            gst_bin_add(GST_BIN(audio->_pipeline), audio->_audioPlaybackBin);
+        }
+        
         gboolean ok;
         GstPad *audioPlaybackQueueSrc, *audioPlaybackBinSink;
         GstPadLinkReturn padreturn;
@@ -385,6 +388,44 @@
         }
     }
     
+    gboolean
+    AudioInputGst::breakAudioSourcePlaybackLink(GnashAudioPrivate *audio) {
+        if (audio->_pipelineIsPlaying == true) {
+            audioStop(audio);
+        }
+        
+        gboolean ok;
+        GstPad *audioPlaybackQueueSrc, *audioPlaybackBinSink;
+        GstStateChangeReturn state;
+        
+        audioPlaybackQueueSrc = gst_element_get_pad(audio->_audioMainBin,
+            "audioPlaybackQueueSrc");
+        audioPlaybackBinSink = gst_element_get_pad(audio->_audioPlaybackBin,
+            "sink");
+        
+        ok = gst_pad_unlink(audioPlaybackQueueSrc, audioPlaybackBinSink);
+        if (ok != true) {
+            log_error("%s: unlink failed", __FUNCTION__);
+            return false;
+        } else {
+            state = gst_element_set_state(audio->_audioPlaybackBin, 
GST_STATE_NULL);
+            if (state != GST_STATE_CHANGE_FAILURE) {
+                //return true;
+                ok = gst_bin_remove(GST_BIN(audio->_pipeline), 
audio->_audioPlaybackBin);
+                if (ok != true) {
+                    log_error("%s: couldn't remove audioPlaybackBin from 
pipeline",
+                        __FUNCTION__);
+                    return false;
+                } else {
+                    return true;
+                }
+            } else {
+                log_error("%s: changing state of audioPlaybackBin failed", 
__FUNCTION__);
+                return false;
+            }
+        }
+    }
+    
     //to handle messages while the main capture loop is running
     gboolean
     audio_bus_call (GstBus     *bus,
@@ -465,11 +506,14 @@
     
     gboolean
     AudioInputGst::makeAudioSourceSaveLink (GnashAudioPrivate* audio) {
+        if (gst_bin_get_by_name(GST_BIN(audio->_pipeline), "audioSaveBin") == 
NULL) {
+            gst_object_ref(audio->_audioSaveBin);
+            gst_bin_add(GST_BIN(audio->_pipeline), audio->_audioSaveBin);
+        }
+        
         GstPad *audioSaveQueueSrc, *audioSaveBinSink;
         GstPadLinkReturn padreturn;
         
-        gst_bin_add(GST_BIN(audio->_pipeline), audio->_audioSaveBin);
-        
         audioSaveQueueSrc = gst_element_get_pad(audio->_audioMainBin,
             "saveQueueSrc");
         audioSaveBinSink = gst_element_get_pad(audio->_audioSaveBin,
@@ -485,6 +529,41 @@
         }
     }
     
+    gboolean
+    AudioInputGst::breakAudioSourceSaveLink (GnashAudioPrivate *audio) {
+        if (audio->_pipelineIsPlaying == true) {
+            audioStop(audio);
+        }
+        gboolean ok;
+        GstPad *audioSaveQueueSrc, *audioSaveBinSink;
+        GstStateChangeReturn state;
+        
+        audioSaveQueueSrc = gst_element_get_pad(audio->_audioMainBin,
+            "saveQueueSrc");
+        audioSaveBinSink = gst_element_get_pad(audio->_audioSaveBin,
+            "sink");
+        
+        ok = gst_pad_unlink(audioSaveQueueSrc, audioSaveBinSink);
+        if (ok != true) {
+            log_error("%s: unlink failed", __FUNCTION__);
+            return false;
+        } else {
+            state = gst_element_set_state(audio->_audioSaveBin, 
GST_STATE_NULL);
+            if (state != GST_STATE_CHANGE_FAILURE) {
+                ok = gst_bin_remove(GST_BIN(audio->_pipeline), 
audio->_audioSaveBin);
+                if (ok != true) {
+                    log_error("%s: couldn't remove saveBin from pipeline", 
__FUNCTION__);
+                    return false;
+                } else {
+                    return true;
+                }
+            } else {
+                log_error("%s: audioSaveBin state change failed", 
__FUNCTION__);
+                return false;
+            }
+        }
+    }
+    
     bool
     AudioInputGst::audioPlay(GnashAudioPrivate *audio) {
         GstStateChangeReturn state;

=== modified file 'libmedia/gst/AudioInputGst.h'
--- a/libmedia/gst/AudioInputGst.h      2009-07-27 15:44:55 +0000
+++ b/libmedia/gst/AudioInputGst.h      2009-07-28 18:37:36 +0000
@@ -337,6 +337,13 @@
     /// @return True if the link was made successfully, false otherwise.
     gboolean makeAudioSourcePlaybackLink (GnashAudioPrivate *audio);
     
+    /// This function breaks the link between the audio playback queue and the
+    /// playback element.
+    /// @param audio A pointer to the GnashAudioPrivate class strucutre of the
+    ///   selected audio input device.
+    /// @return True if the link was successfully broken, false otherwise.
+    gboolean breakAudioSourcePlaybackLink (GnashAudioPrivate *audio);
+    
     /// This function makes the link between the audio save queue (which 
receives
     /// an audio stream from the source device) and the respective save 
elements.
     /// It's important to note that if you create the save bin you must make 
sure
@@ -347,6 +354,13 @@
     /// @return True if the link was made successfully, false otherwise.
     gboolean makeAudioSourceSaveLink (GnashAudioPrivate *audio);
     
+    /// This function breaks the link between the audio save queue and the 
audio
+    /// stream.
+    /// @param audio A pointer to the GnashAudioPrivate class of the selected
+    ///   audio input device.
+    /// @return True if the link was successfully broken, false otherwise.
+    gboolean breakAudioSourceSaveLink (GnashAudioPrivate *audio);
+    
     /// This function creates the audio save bin. A reference to this bin is
     /// stored in a GnashWebcamPrivate class structure under the _audioSaveBin
     /// variable. See the description of _audioSaveBin for a pipeline 
description.

=== modified file 'libmedia/gst/VideoInputGst.cpp'
--- a/libmedia/gst/VideoInputGst.cpp    2009-07-27 19:30:06 +0000
+++ b/libmedia/gst/VideoInputGst.cpp    2009-07-28 18:37:36 +0000
@@ -738,7 +738,7 @@
         
         //drop the display bin into the pipeline
         //gst_bin_add (GST_BIN (webcam->_webcamMainBin), 
webcam->_videoDisplayBin);
-        gst_bin_add (GST_BIN (webcam->_pipeline), webcam->_videoDisplayBin);
+        //gst_bin_add (GST_BIN (webcam->_pipeline), webcam->_videoDisplayBin);
         
         ok = gst_element_link_many(video_scale, video_sink, NULL);
         if (ok != true) {
@@ -760,6 +760,11 @@
     //the elements necessary to display video to screen (_videoDisplayBin)
     gboolean
     VideoInputGst::webcamMakeVideoDisplayLink(GnashWebcamPrivate *webcam) {
+        if (gst_bin_get_by_name(GST_BIN(webcam->_pipeline), 
"video_display_bin") == NULL) {
+            gst_object_ref(webcam->_videoDisplayBin);
+            gst_bin_add (GST_BIN(webcam->_pipeline), webcam->_videoDisplayBin);
+        }
+        
         gboolean ok;
         GstPad *video_display_queue_src, *video_display_bin_sink;
         
@@ -814,6 +819,7 @@
     gboolean
     VideoInputGst::webcamMakeVideoSaveLink(GnashWebcamPrivate *webcam) {
         if (gst_bin_get_by_name(GST_BIN(webcam->_pipeline), "video_save_bin") 
== NULL) {
+            gst_object_ref(webcam->_videoSaveBin);
             gst_bin_add(GST_BIN(webcam->_pipeline), webcam->_videoSaveBin);
         }
 

=== modified file 'testsuite/libmedia.all/test_audioinput.cpp'
--- a/testsuite/libmedia.all/test_audioinput.cpp        2009-07-27 15:44:55 
+0000
+++ b/testsuite/libmedia.all/test_audioinput.cpp        2009-07-28 18:37:36 
+0000
@@ -24,6 +24,7 @@
 #include <string>
 #include <sys/stat.h>
 #include <cstdio>
+#include <unistd.h>
 
 #include "dejagnu.h"
 #include "log.h"
@@ -176,6 +177,7 @@
     }
     
     //sleep to record a few seconds of audio (from mic or test source)
+    g_print("        NOTE: sleeping for 5 seconds here....\n");
     sleep(5);
     
     ok = aud.audioStop(audio);
@@ -195,9 +197,129 @@
             runtest.pass("the output file has data in it");
         }
     } else {
-        runtest.fail("there's no output video file in testsuite/libmedia.all");
-    }
-    
+        runtest.fail("there's no output audio file in testsuite/libmedia.all");
+    }
+    
+    //delete the old audioOut.ogg file
+    if (unlink(file.c_str()) == 0) {
+        g_print("        NOTE: deleting output file...\n");
+    }
+    
+    ok = aud.breakAudioSourcePlaybackLink(audio);
+    if (ok != true) {
+        runtest.fail("breakAudioSourcePlaybackLink() reported an error");
+    } else {
+        runtest.pass("breakAudioSourcePlaybackLink() reported no errors");
+    }
+    
+    ok = aud.audioPlay(audio);
+    if (ok != true) {
+        runtest.fail("audioPlay() reported an error");
+    } else {
+        runtest.pass("audioPlay() reported no errors");
+    }
+
+    g_print("        NOTE: sleeping for 10 seconds here....\n");
+    sleep(10);
+    
+    ok = aud.audioStop(audio);
+    if (ok != true) {
+        runtest.fail("audioStop() reported an error");
+    } else {
+        runtest.pass("audioStop() reported no errors");
+    }
+    
+    if (stat(file.c_str(), &st) == 0) {
+        runtest.pass("audioOut.ogg file is in testsuite/libmedia.all");
+        if (st.st_blocks == 0) {
+            runtest.fail("the output file is there, but there's no data in 
it!");
+        } else {
+            runtest.pass("the output file has data in it");
+        }
+    } else {
+        runtest.fail("there's no output audio file in testsuite/libmedia.all");
+    }
+    
+    //delete the old audioOut.ogg file
+    if (unlink(file.c_str()) == 0) {
+        g_print("        NOTE: deleting output file...\n");
+    }
+    
+    ok = aud.breakAudioSourceSaveLink(audio);
+    if (ok != true) {
+        runtest.fail("breakAudioSourceSaveLink() reported an error");
+    } else {
+        runtest.pass("breakAudioSourceSaveLink() reported no errors");
+    }
+    
+    ok = aud.audioPlay(audio);
+    if (ok != true) {
+        runtest.fail("audioPlay() reported an error");
+    } else {
+        runtest.pass("audioPlay() reported no errors");
+    }
+
+    g_print("        NOTE: sleeping for 5 seconds here....\n");
+    sleep(5);
+    
+    ok = aud.audioStop(audio);
+    if (ok != true) {
+        runtest.fail("audioStop() reported an error");
+    } else {
+        runtest.pass("audioStop() reported no errors");
+    }
+    
+    if (stat(file.c_str(), &st) == 0) {
+        runtest.fail("an output file was created and it shouldn't have");
+        if (unlink(file.c_str()) == 0) {
+            g_print("        NOTE: deleting output file...\n");
+        }
+    } else {
+        runtest.pass("no output file was created");
+    }
+    
+
+    ok = aud.makeAudioSourcePlaybackLink(audio);
+    if (ok != true) {
+        runtest.fail("couldn't remake the link audiosource->playback link");
+    } else {
+        runtest.pass("successfully remade the audiosource->playback link");
+    }
+    
+    ok = aud.makeAudioSourceSaveLink(audio);
+    if (ok != true) {
+        runtest.fail("couldn't remake the audiosource->save link");
+    } else {
+        runtest.pass("successfully remade the audiosource->save link");
+    }
+    
+    ok = aud.audioPlay(audio);
+    if (ok != true) {
+        runtest.fail("audioPlay() reported an error");
+    } else {
+        runtest.pass("audioPlay() reported no errors");
+    }
+
+    g_print("        NOTE: sleeping for 10 seconds here....\n");
+    sleep(10);
+    
+    ok = aud.audioStop(audio);
+    if (ok != true) {
+        runtest.fail("audioStop() reported an error");
+    } else {
+        runtest.pass("audioStop() reported no errors");
+    }
+    
+    if (stat(file.c_str(), &st) == 0) {
+        runtest.pass("audioOut.ogg file is in testsuite/libmedia.all");
+        if (st.st_blocks == 0) {
+            runtest.xfail("the output file is there, but there's no data in 
it!");
+        } else {
+            runtest.pass("the output file has data in it");
+        }
+    } else {
+        runtest.fail("there's no output audio file in testsuite/libmedia.all");
+    }
 }
 
 

=== modified file 'testsuite/libmedia.all/test_videoinput.cpp'
--- a/testsuite/libmedia.all/test_videoinput.cpp        2009-07-27 18:48:53 
+0000
+++ b/testsuite/libmedia.all/test_videoinput.cpp        2009-07-28 18:37:36 
+0000
@@ -203,12 +203,6 @@
         } else {
             runtest.pass("the _videoDisplayBin sink ghostpad was created");
         }
-        if ((gst_bin_get_by_name(GST_BIN(webcam->_pipeline),
-            "video_display_bin")) == NULL) {
-            runtest.fail("videoDisplayBin has an unexpected address");
-        } else {
-            runtest.pass("videoDisplayBin's address is set as expected");
-        }
     }
 
     result = false;

=== modified file 'utilities/findmicrophones.cpp'
--- a/utilities/findmicrophones.cpp     2009-07-24 20:42:41 +0000
+++ b/utilities/findmicrophones.cpp     2009-07-28 18:37:36 +0000
@@ -149,11 +149,17 @@
         g_print("set microphoneDevice %d\n", dev_select);
     } else {
         numdevs = findAudioDevs(audioVector);
-        g_print("\nThe gnashrc file reports default microphone is set to:\n");
-        g_print("%s (%s)\n", audioVector[fromrc]->deviceName,
-            audioVector[fromrc]->deviceType);
-        g_print("To change this setting, delete the 'set microphoneDevice' 
line\n");
-        g_print("from your gnashrc file and re-run this program.\n\n");
+        if (fromrc <= (audioVector.size() - 1)) {
+            g_print("\nThe gnashrc file reports default microphone is set 
to:\n");
+            g_print("%s (%s)\n", audioVector[fromrc]->deviceName,
+                audioVector[fromrc]->deviceType);
+            g_print("To change this setting, delete the 'set microphoneDevice' 
line\n");
+            g_print("from your gnashrc file and re-run this program.\n\n");
+        } else {
+            g_print("\nYou have an invalid microphone chosen in your gnashrc 
file.\n");
+            g_print("Try reattaching the device or deleting the value from 
gnashrc\n");
+            g_print("and running this program again\n");
+        }
     }
     return 1;
 }

=== modified file 'utilities/findwebcams.cpp'
--- a/utilities/findwebcams.cpp 2009-07-27 21:02:18 +0000
+++ b/utilities/findwebcams.cpp 2009-07-28 18:39:20 +0000
@@ -206,11 +206,17 @@
         g_print("set webcamDevice %d\n", vidVector[dev_select + 
numDuplicates]->deviceNumber);
     } else {
         numdevs = findVidDevs(vidVector);
-        g_print("\nThe gnashrc file reports default webcam is set to:\n");
-        g_print("%s (%s)\n", vidVector[fromrc]->deviceName,
-            vidVector[fromrc]->deviceType);
-        g_print("To change this setting, delete the 'set webcamDevice' 
line\n");
-        g_print("from your gnashrc file and re-run this program.\n\n");
+        if (fromrc <= (vidVector.size() - 1)) {
+            g_print("\nThe gnashrc file reports default webcam is set to:\n");
+            g_print("%s (%s)\n", vidVector[fromrc]->deviceName,
+                vidVector[fromrc]->deviceType);
+            g_print("To change this setting, delete the 'set webcamDevice' 
line\n");
+            g_print("from your gnashrc file and re-run this program.\n\n");
+        } else {
+            g_print("\nYou have an invalid webcam chosen in your gnashrc 
file.\n");
+            g_print("Try reattaching the device or deleting the value from 
gnashrc\n");
+            g_print("and running this program again\n");
+        }
     }
     return 1;
 }


reply via email to

[Prev in Thread] Current Thread [Next in Thread]