rpms/fmtools/F-12 radio.gif, NONE, 1.1 fmlircrc, 1.1, 1.2 fmtools.spec, 1.11, 1.12 import.log, 1.6, 1.7 tkradio.py, 1.3, 1.4

Paulo Roma Cavalcanti roma at fedoraproject.org
Wed Jan 6 07:41:40 UTC 2010


Author: roma

Update of /cvs/pkgs/rpms/fmtools/F-12
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv4070/F-12

Modified Files:
	fmlircrc fmtools.spec import.log tkradio.py 
Added Files:
	radio.gif 
Log Message:
improved tkradio


Index: fmlircrc
===================================================================
RCS file: /cvs/pkgs/rpms/fmtools/F-12/fmlircrc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- fmlircrc	31 Dec 2009 14:50:40 -0000	1.1
+++ fmlircrc	6 Jan 2010 07:41:40 -0000	1.2
@@ -47,6 +47,12 @@ end
 
 begin
     prog   = tkradio
+    button = loop
+    config = loop
+end
+
+begin
+    prog   = tkradio
     button = vol+
     config = volup
 end


Index: fmtools.spec
===================================================================
RCS file: /cvs/pkgs/rpms/fmtools/F-12/fmtools.spec,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -p -r1.11 -r1.12
--- fmtools.spec	31 Dec 2009 14:50:40 -0000	1.11
+++ fmtools.spec	6 Jan 2010 07:41:40 -0000	1.12
@@ -1,17 +1,18 @@
 Summary: Simple Video for Linux radio card programs
 Name:    fmtools
 Version: 2.0
-Release: 8%{?dist}
+Release: 9%{?dist}
 License: GPLv2+
 Group:   Applications/Multimedia
 URL:     http://www.stanford.edu/~blp/fmtools/
-Source0: http://benpfaff.org/fmtools/fmtools/%{name}-%{version}.tar.gz
+Source0: http://benpfaff.org/fmtools/%{name}-%{version}.tar.gz
 Patch0:  fmtools.patch
 Source1: fmcontrol.tar.gz
 Source2: http://www.stanford.edu/~blp/fmtools/tkradio
 Source3: http://www.stanford.edu/~blp/fmtools/tkradio-mute
 Source4: fmtools.desktop
 Source5: radio.png
+Source8: radio.gif
 Source6: tkradio.py
 Source7: fmlircrc
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -30,7 +31,8 @@ Summary:       Python/Tk wrapper for fmt
 Group:         Applications/Multimedia
 BuildRequires: desktop-file-utils
 Requires:      %{name} = %{version}
-Requires:      python, python-lirc, tkinter, alsa-utils
+Requires:      python, python-lirc, notify-python
+Requires:      vorbis-tools, tkinter, alsa-utils
 BuildArch:     noarch
 
 %description tkradio
@@ -69,6 +71,7 @@ desktop-file-install                    
 
 install -Dpm 0644 %{SOURCE5} %{buildroot}%{_datadir}/pixmaps/radio.png
 install -Dpm 0644 %{SOURCE7} %{buildroot}%{_datadir}/%{name}/fmlircrc
+install -Dpm 0644 %{SOURCE8} %{buildroot}%{_datadir}/%{name}/radio.gif
 
 %clean
 rm -rf %{buildroot}
@@ -87,9 +90,15 @@ rm -rf %{buildroot}
 %{_datadir}/applications/fmtools.desktop
 %{_datadir}/pixmaps/radio.png
 %{_datadir}/%{name}/fmlircrc
+%{_datadir}/%{name}/radio.gif
 
 %changelog
 
+* Sat Jan 02 2010 Paulo Roma <roma at lcg.ufrj.br> 2.0-9
+- Added libnotify support.
+- Addded compression using oggenc.
+- Added window icon.
+
 * Sun Dec 30 2009 Paulo Roma <roma at lcg.ufrj.br> 2.0-8
 - Added recording support.
 


Index: import.log
===================================================================
RCS file: /cvs/pkgs/rpms/fmtools/F-12/import.log,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -p -r1.6 -r1.7
--- import.log	31 Dec 2009 14:50:40 -0000	1.6
+++ import.log	6 Jan 2010 07:41:40 -0000	1.7
@@ -4,3 +4,4 @@ fmtools-2_0-5_fc12:F-12:fmtools-2.0-5.fc
 fmtools-2_0-6_fc12:F-12:fmtools-2.0-6.fc12.src.rpm:1261758030
 fmtools-2_0-7_fc12:F-12:fmtools-2.0-7.fc12.src.rpm:1261945933
 fmtools-2_0-8_fc12:F-12:fmtools-2.0-8.fc12.src.rpm:1262270955
+fmtools-2_0-9_fc12:F-12:fmtools-2.0-9.fc12.src.rpm:1262763571


Index: tkradio.py
===================================================================
RCS file: /cvs/pkgs/rpms/fmtools/F-12/tkradio.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -p -r1.3 -r1.4
--- tkradio.py	31 Dec 2009 14:50:40 -0000	1.3
+++ tkradio.py	6 Jan 2010 07:41:40 -0000	1.4
@@ -9,10 +9,23 @@ import Tkinter
 import os, sys, string
 import datetime, time
 from threading import Thread
+from subprocess import Popen, PIPE
+
 try:
-   import pylirc
+    import pylirc
+except:
+    sys.exit ( "pylirc not found: http://pylirc.mccabe.nu/" )
+
+try:
+    import pynotify
+    if pynotify.init("tkradio"):
+        use_notify = True
+    else:
+        use_notify = False
+        print "pynotify module initialization failed"
 except:
-   exit ( "pylirc not found: http://pylirc.mccabe.nu/" )
+    use_notify = False
+    print "notify-python not found: http://www.galago-project.org/downloads.php"
 
 # These are stations in the Rio de Janeiro area. 
 # Customize for your own locale. They can be set
@@ -38,6 +51,7 @@ volume   = 100             # initial vol
 state    = False           # keep track of mutting/unmutting
 blocking = 0               # lirc blocking control
 tid      = 0               # recorder thread id
+lid      = 0               # loopback process id
 fmrec    = None            # recorder thread variable
 irrec    = None            # lirc thread variable
 
@@ -57,7 +71,7 @@ class IRRec(Thread):
        self.__on = False 
 
    def run(self):
-      print "IRRrec awaits IR commands"
+      """Run the thread code."""
 
       code = {"config" : ""}
 
@@ -81,14 +95,19 @@ class IRRec(Thread):
                    elif ( code["config"] == "voldown" ):
                         voldown()
                    elif ( code["config"] in "0123456789" ):
+                        time.sleep(1)
+                        b=pylirc.nextcode()
+                        if ( b and b[0] in "0123456789" ):
+                             code["config"] += b[0]
                         setStation ( int (code["config"]) )
                    elif ( code["config"] == "rec" ):
                         rec_on()
                    elif ( code["config"] == "stop" ):
                         rec_off()
+                   elif ( code["config"] == "loop" ):
+                        loopon()
                    elif ( code["config"] == "quit" ):
-                        print "Not implemented yet, sorry..." 
-                        # self.stop()
+                        quit()
                    else:
                         # Print all the configs...
                         print "Command: %s, Repeat: %d" % (code["config"], code["repeat"])
@@ -136,9 +155,15 @@ class FMRec(Thread):
                 data = str(datetime.date.today())
                 hora = list(time.localtime(time.time()))
                 hora = str(hora[3])+":"+str(hora[4])+":"+str(hora[5])
-                rec_file = '/tmp/tkradio-'+fmstations[cur_station][0]+"-"+data+"-"+hora+'.wav' 
-                lparam = ['/usr/bin/arecord', '-D', 'default', '-d', '0', '-f', 'cd', rec_file]
-                self.__pid = os.spawnv (os.P_NOWAIT, "/usr/bin/arecord", lparam )
+                rec_file = '/tmp/tkradio-'+fmstations[cur_station][0]+"-"+data+"-"+hora+'.ogg' 
+                arec_param = ['/usr/bin/arecord', '-D', 'default', '-d', '0', '-f', 'cd', '-']
+                ogge_param = ['/usr/bin/oggenc', '-', '-Q', '-o', rec_file] 
+                if use_notify:
+                   n = pynotify.Notification("tkradio recording on file:", rec_file, "/usr/share/pixmaps/radio.png")
+                   n.show()
+                p1 = Popen(arec_param, stdout=PIPE)
+                p2 = Popen(ogge_param, stdin=p1.stdout)
+                self.__pid = p1.pid
 
            time.sleep(1.0) # Suspend execution for the given number of seconds
 
@@ -192,8 +217,9 @@ def quit():
     # kill all threads
     if ( fmrec ): fmrec.stop()
     if ( irrec ): irrec.stop() 
-    
-    sys.exit ( 0 )
+    if ( lid ): os.kill ( lid, 9 )
+ 
+    os._exit (0)
 
 def mute():
     """Mute/Unmute the radio."""
@@ -283,6 +309,36 @@ def trigger ():
          fmrec.start()
          tid = 1
 
+def loop():
+    """Route the capture sources on the sound card back in as PCM audio."""
+  
+    global lid
+
+    if ( loopvar.get() == "ON" ): 
+         if ( not lid ):
+              arec_param = ['/usr/bin/arecord', '-D', 'default', '-d', '0', '-f', 'cd']
+              apla_param = ['/usr/bin/aplay', '-f', 'cd', '-D', 'default'] 
+              p1 = Popen(arec_param, stdout=PIPE)
+              p2 = Popen(apla_param, stdin=p1.stdout)
+              lid = p1.pid
+              n = pynotify.Notification("tkradio", "Software Loop Back activated",
+                                            "/usr/share/pixmaps/radio.png")
+              n.set_timeout(2000)
+              n.show()
+    else: 
+         if ( lid ):
+              os.kill ( lid, 9 )
+              lid = 0
+
+def loopon():
+    """Toggles the loop variable."""
+
+    if ( loopvar.get() == "ON" ):
+         loopvar.set ("OFF")
+    else:
+         loopvar.set ("ON")
+    loop()
+
 def rec():
     """Record the current station."""
 
@@ -303,6 +359,25 @@ def rec_off():
     recvar.set ("OFF")
     if ( fmrec ): fmrec.stop()
 
+def mouse_wheel(event):
+    """Respond to mouse wheel events."""
+
+    if event.num == 5 or event.delta == -120:
+       voldown ()
+    if event.num == 4 or event.delta == 120:
+       volup ()
+
+def str2num(datum):
+    """A conversion function that "guesses" the best conversion."""
+
+    try:
+        return int(datum)
+    except:
+        try:
+            return float(datum)
+        except:
+            return datum
+
 def main (argv=None):
     """Main program."""
 
@@ -315,7 +390,9 @@ def main (argv=None):
     global cur_station   # current station
     global ns            # number of preset fm stations
     global recvar        # variable for setting record on/off
+    global loopvar       # variable for setting loopback on/off
     global irrec         # lirc thread variable
+    global lid           # loopback process id
 
     if argv is None:
        argv = sys.argv
@@ -329,7 +406,7 @@ def main (argv=None):
     if ( stat ): 
          pid = stat.split()[1]
          if ( cid != int(pid) ): 
-              exit ( argv[0] + " is already running: pid = " + pid )
+              sys.exit ( "%s is already running: pid = %s" %(argv[0], pid) )
 
     mw = Tk()
     # do not resize the radio
@@ -369,18 +446,37 @@ def main (argv=None):
     freq.insert(0,station.get())
     freq.pack(side="bottom")
 
+    recvar = StringVar()   # creates a checkbutton for the alarm state
+    loopvar = StringVar()  # creates a checkbutton for the loopback
+    recvar.set ( "OFF" )
+    aid = os.popen ( '/sbin/pidof arecord' ).readline()
+    aid = aid.replace('\n','')
+    aid = str2num(aid)
+    if ( aid ): # is the loop back already on?
+         loopvar.set ( "ON" )
+         lid = aid
+    else:
+         loopvar.set ( "OFF" )
+
     # create quit and mute buttons
     Button(top,text="Exit", command = quit).pack(side="right")
-    recvar = StringVar()  # creates a checkbutton for the alarm state
-    recvar.set ( "OFF" )
-    Checkbutton (top, text="Rec", variable=recvar, onvalue="ON", offvalue="OFF", command=rec).pack(side="right")
     btm=Button(top,text="Off", command = mute, textvariable = btmute)
     btm.pack(side="left")
+    Checkbutton (top, text="Rec", variable=recvar, onvalue="ON", offvalue="OFF", command=rec).pack(side="top",anchor=W)
+    Checkbutton (top, text="Loop", variable=loopvar, onvalue="ON", offvalue="OFF", command=loop).pack(side="right")
+
+    # mouse whell control
+    mw.bind("<Button-4>", mouse_wheel)
+    mw.bind("<Button-5>", mouse_wheel)
 
     # turn the radio on
     setstation()
     radio ("on")
 
+    # set an icon for the window
+    icon_img = PhotoImage(file="/usr/share/fmtools/radio.gif")
+    mw.tk.call('wm', 'iconphoto', mw._w, icon_img)
+
     lircid = os.popen ( '/sbin/pidof lircd' ).readline()
     if ( lircid ): # is lirc running?
          # handle lirc events
@@ -390,7 +486,11 @@ def main (argv=None):
               fname = "/usr/share/fmtools/fmlircrc"
          lirc_handle = pylirc.init("tkradio", fname, blocking)
          if (lirc_handle):
-             print "Succesfully opened lirc, handle is " + str(lirc_handle)
+             if ( use_notify ):
+                  n = pynotify.Notification("tkradio", "Successfully opened lirc. Handle is "+str(lirc_handle), 
+                                            "/usr/share/pixmaps/radio.png")
+                  n.set_timeout(2000)
+                  n.show()
              irrec = IRRec(lirc_handle)
              irrec.start()
 
@@ -399,6 +499,5 @@ def main (argv=None):
 try:
   if __name__=="__main__":
      sys.exit(main())
-except KeyboardInterrupt:
-     radio ("off")
-     sys.exit('Bye, bye')
+except KeyboardInterrupt,SystemExit:
+     quit()




More information about the fedora-extras-commits mailing list