Replaced polling loop for LCR and chan_lcr with select based event loop.
[lcr.git] / port.cpp
index 5998bc6..e88175b 100644 (file)
--- a/port.cpp
+++ b/port.cpp
@@ -316,6 +316,8 @@ void Port::set_tone(const char *dir, const char *name)
                        SCPY(p_tone_dir, dir);
                        SCPY(p_tone_name, name);
                }
+               /* trigger playback */
+               update_load();
        } else {
                p_tone_name[0]= '\0';
                p_tone_dir[0]= '\0';
@@ -382,6 +384,8 @@ void Port::set_vbox_tone(const char *dir, const char *name)
 
        SPRINT(p_tone_dir,  dir);
        SPRINT(p_tone_name,  name);
+       /* trigger playback */
+       update_load();
 
        /* now we check if the cause exists, otherwhise we use error tone. */
        if (p_tone_dir[0]) {
@@ -585,13 +589,6 @@ try_loop:
 }
 
 
-/* port handler:
- * process transmission clock */
-int Port::handler(void)
-{
-       return(0);
-}
-
 /* endpoint sends messages to the port
  * this is called by the message_epoint inherited by child classes
  * therefor a return=1 means: stop, no more processing
@@ -648,6 +645,8 @@ int Port::open_record(int type, int vbox, int skip, char *extension, int anon_ig
        /* RIFFxxxxWAVEfmt xxxx(fmt-size)dataxxxx... */
        char dummyheader[8+4+8+sizeof(fmt)+8];
        char filename[256];
+       time_t now;
+       struct tm *now_tm;
 
        if (!extension) {
                PERROR("Port(%d) not an extension\n", p_serial);
@@ -676,8 +675,11 @@ int Port::open_record(int type, int vbox, int skip, char *extension, int anon_ig
 
        if (vbox == 1)
                UPRINT(strchr(filename,'\0'), "/announcement");
-       else
+       else {
+               time(&now);
+               now_tm = localtime(&now);
                UPRINT(strchr(filename,'\0'), "/%04d-%02d-%02d_%02d%02d%02d", now_tm->tm_year+1900, now_tm->tm_mon+1, now_tm->tm_mday, now_tm->tm_hour, now_tm->tm_min, now_tm->tm_sec);
+       }
        if (vbox == 2) {
                p_record_vbox_year = now_tm->tm_year;
                p_record_vbox_mon = now_tm->tm_mon;
@@ -698,6 +700,7 @@ int Port::open_record(int type, int vbox, int skip, char *extension, int anon_ig
                PERROR("Port(%d) cannot record because file cannot be opened '%s'\n", p_serial, filename);
                return(0);
        }
+       update_rxoff();
        fduse++;
 
        p_record_type = type;
@@ -882,6 +885,7 @@ void Port::close_record(int beep, int mute)
        fclose(p_record);
        fduse--;
        p_record = NULL;
+       update_rxoff();
 
        if (rename(p_record_filename, filename) < 0) {
                PERROR("Port(%d) cannot rename from '%s' to '%s'\n", p_serial, p_record_filename, filename);
@@ -1139,4 +1143,11 @@ different_again:
 
 }
 
+void Port::update_rxoff(void)
+{
+}
+
+void Port::update_load(void)
+{
+}