ant-phone/src/isdnparser.y

179 lines
4.1 KiB
Plaintext
Raw Normal View History

2007-11-24 13:45:25 +00:00
%name-prefix="isdn_"
%{
/*
* isdn4linux options file format parser
*
* This file is part of ANT (Ant is Not a Telephone)
*
* Copyright 2002, 2003 Roland Stigge
*
* ANT is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ANT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ANT; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/* regular GNU system includes */
#include <stdio.h>
#include <stdlib.h>
/* own header files */
#include "globals.h"
#include "util.h"
#include "settings.h"
#include "isdntree.h"
typedef struct isdn_list_store_t isdn_list_store_t;
struct isdn_list_store_t {
isdn_tree_node_t* list; /* list itself (start) */
isdn_tree_node_t** last; /* pointer to pointer to last element */
/* (which in turn should always be NULL) */
};
int isdn_lex(void);
void isdn_error(const char *message);
%}
/* types of semantic values */
%union {
char* s;
isdn_list_store_t list;
isdn_tree_node_t* element;
}
/* terminal symbols */
%token <s> ISDN_TOKEN_NAME
%token <s> ISDN_TOKEN_VALUE
/* non terminal symbols */
%type <list> config;
%type <list> sections;
%type <element> section;
%type <list> entries;
%type <element> entry;
%type <s> value;
%%
config : entries sections
{
if ($1.list == NULL) {
$$ = $2;
} else {
$$.list = $1.list;
*$1.last = $2.list;
$$.last = $2.last;
}
isdn_tree = $$.list;
}
;
sections : { $$.list = NULL; $$.last = NULL; }
| sections section
{
if ($1.list == NULL) {
$$.list = $2;
$$.last = &$2->next;
} else {
$$.list = $1.list;
*$1.last = $2;
$$.last = &$2->next;
}
}
;
section : '[' ISDN_TOKEN_NAME ']' entries
{
if (!($$ =
(isdn_tree_node_t*) malloc(sizeof(isdn_tree_node_t))))
{
Version 0.2.0: CAPI 2.0, ALSA, threading, low-latency. Changes in short: * Re-work of session handling to use sound and ISDN threads, which greatly reduces latency and CPU usage * Complete re-work of ISDN subsystem to use CAPI 2.0 * Complete re-work of sound subsystem to use ALSA * Re-work of recording subsystem to produce better results * Re-work of debug and error message handling (centralized) * Added --sleep and --wakeup remote commands to facilitate release and re-acquire of CAPI connection * Code documentation (partial) Reduced latency: ---------------- We are now using separate threads to handle ISDN input (and send it to audio output) and audio input (which again sends it to ISDN). This means, we are not dependent on GTK GUI reaction time. This enables very good sound quality with low latency and low CPU consumption (normally not measurable). Tested with 3x parallel "while true; do true; done" and "find /". No sound problems, even though the threads don't run with real time priority (which can be implemented now relatively easily, though). ISDN system: ------------ We now support CAPI 2.0. This means, any card supported by CAPI 2.0 should work and also ant-phone should be able to coexist with other ISDN applications. New CAPI code was tested with Fritz!Card, both with fcpci driver and with mISDN driver. There are also remote-CAPI implementations which forward local CAPI requests to a remote host (e.g., a Fritz!Box router). They should be also usable with new CAPI subsystem (not tested). Sound system: ------------- Since we are now using ALSA, it's much easier to coexist with other sound applications. However, sound device specification has been changed. You should now type in ALSA names (normally 'default') instead of raw devices. Recording: ---------- Recording subsystem now uses ring buffers and the buffers are flushed in GTK thread on timeout. Although it would be possible to have special thread for this purpose, it doesn't really make sense, since we buffer about 2 seconds. In 2 seconds, the application better responds... Anyway, in the worst case, there will be some samples skipped. Also, recording tries to stitch together incoming samples on local as well as remote channels as it best fits based on time code. Certain jitter is compensated for automatically, bigger jitter may produce some cracks. However, in tests there was no such problem. Debug and error message handling: --------------------------------- All debug and error messages should now go through macros dbgprintf() and errprintf(). This allows for implementing of debug log viewer later. For new/rewritten code, all debug and error messages start with "COMPONENT: " prefix. This allows for easier identification in logs. Additionally, there are further debug levels, up to 4. Debug level 3 and higher prints very noisy information about each audio packet processed. Sleep and wakeup commands: -------------------------- Some ISDN card drivers need to be unloaded before suspending the machine to disk and loaded again after resume. This is not possible, as long as the application is holding the CAPI connection. Therefore, two new command-line commands have been implemented, which allow turning off and on the CAPI connection (--sleep and --wakeup, respectively). They can be integrated into suspend and resume scripts to take care of stopping and resuming CAPI. Code documentation: ------------------- Documentation for new code and for big rewritten parts has been changed to Doxygen format. Instead of plain comments, you'll see comments in form /*! ... */ with tags in form @tag, which allow Doxygen to generate pretty-printed source code reference documentation. Doxygen script file has not been actually produced. The rest of the files should be changed as well to use Doxygen format tags in documentation of functions and structures.
2007-11-24 17:55:27 +00:00
errprintf("Error: Out of memory.\n");
2007-11-24 13:45:25 +00:00
exit(1);
}
$$->type = ISDN_NODE_TYPE_SECTION;
$$->name = $2;
$$->content.section = $4.list;
/* finally: only list needed */
$$->next = NULL;
}
;
entries : { $$.list = NULL; $$.last = NULL; }
| entries entry
{
if ($1.list == NULL) {
$$.list = $2;
$$.last = &$2->next;
} else {
$$.list = $1.list;
*$1.last = $2;
$$.last = &$2->next;
}
}
| entries error
{
Version 0.2.0: CAPI 2.0, ALSA, threading, low-latency. Changes in short: * Re-work of session handling to use sound and ISDN threads, which greatly reduces latency and CPU usage * Complete re-work of ISDN subsystem to use CAPI 2.0 * Complete re-work of sound subsystem to use ALSA * Re-work of recording subsystem to produce better results * Re-work of debug and error message handling (centralized) * Added --sleep and --wakeup remote commands to facilitate release and re-acquire of CAPI connection * Code documentation (partial) Reduced latency: ---------------- We are now using separate threads to handle ISDN input (and send it to audio output) and audio input (which again sends it to ISDN). This means, we are not dependent on GTK GUI reaction time. This enables very good sound quality with low latency and low CPU consumption (normally not measurable). Tested with 3x parallel "while true; do true; done" and "find /". No sound problems, even though the threads don't run with real time priority (which can be implemented now relatively easily, though). ISDN system: ------------ We now support CAPI 2.0. This means, any card supported by CAPI 2.0 should work and also ant-phone should be able to coexist with other ISDN applications. New CAPI code was tested with Fritz!Card, both with fcpci driver and with mISDN driver. There are also remote-CAPI implementations which forward local CAPI requests to a remote host (e.g., a Fritz!Box router). They should be also usable with new CAPI subsystem (not tested). Sound system: ------------- Since we are now using ALSA, it's much easier to coexist with other sound applications. However, sound device specification has been changed. You should now type in ALSA names (normally 'default') instead of raw devices. Recording: ---------- Recording subsystem now uses ring buffers and the buffers are flushed in GTK thread on timeout. Although it would be possible to have special thread for this purpose, it doesn't really make sense, since we buffer about 2 seconds. In 2 seconds, the application better responds... Anyway, in the worst case, there will be some samples skipped. Also, recording tries to stitch together incoming samples on local as well as remote channels as it best fits based on time code. Certain jitter is compensated for automatically, bigger jitter may produce some cracks. However, in tests there was no such problem. Debug and error message handling: --------------------------------- All debug and error messages should now go through macros dbgprintf() and errprintf(). This allows for implementing of debug log viewer later. For new/rewritten code, all debug and error messages start with "COMPONENT: " prefix. This allows for easier identification in logs. Additionally, there are further debug levels, up to 4. Debug level 3 and higher prints very noisy information about each audio packet processed. Sleep and wakeup commands: -------------------------- Some ISDN card drivers need to be unloaded before suspending the machine to disk and loaded again after resume. This is not possible, as long as the application is holding the CAPI connection. Therefore, two new command-line commands have been implemented, which allow turning off and on the CAPI connection (--sleep and --wakeup, respectively). They can be integrated into suspend and resume scripts to take care of stopping and resuming CAPI. Code documentation: ------------------- Documentation for new code and for big rewritten parts has been changed to Doxygen format. Instead of plain comments, you'll see comments in form /*! ... */ with tags in form @tag, which allow Doxygen to generate pretty-printed source code reference documentation. Doxygen script file has not been actually produced. The rest of the files should be changed as well to use Doxygen format tags in documentation of functions and structures.
2007-11-24 17:55:27 +00:00
errprintf("Error region from %d:%d up to %d:%d.\n",
2007-11-24 13:45:25 +00:00
@2.first_line, @2.first_column,
@2.last_line, @2.last_column);
$$ = $1;
}
;
entry : ISDN_TOKEN_NAME '=' value
{
if (!($$ =
(isdn_tree_node_t*) malloc(sizeof(isdn_tree_node_t))))
{
Version 0.2.0: CAPI 2.0, ALSA, threading, low-latency. Changes in short: * Re-work of session handling to use sound and ISDN threads, which greatly reduces latency and CPU usage * Complete re-work of ISDN subsystem to use CAPI 2.0 * Complete re-work of sound subsystem to use ALSA * Re-work of recording subsystem to produce better results * Re-work of debug and error message handling (centralized) * Added --sleep and --wakeup remote commands to facilitate release and re-acquire of CAPI connection * Code documentation (partial) Reduced latency: ---------------- We are now using separate threads to handle ISDN input (and send it to audio output) and audio input (which again sends it to ISDN). This means, we are not dependent on GTK GUI reaction time. This enables very good sound quality with low latency and low CPU consumption (normally not measurable). Tested with 3x parallel "while true; do true; done" and "find /". No sound problems, even though the threads don't run with real time priority (which can be implemented now relatively easily, though). ISDN system: ------------ We now support CAPI 2.0. This means, any card supported by CAPI 2.0 should work and also ant-phone should be able to coexist with other ISDN applications. New CAPI code was tested with Fritz!Card, both with fcpci driver and with mISDN driver. There are also remote-CAPI implementations which forward local CAPI requests to a remote host (e.g., a Fritz!Box router). They should be also usable with new CAPI subsystem (not tested). Sound system: ------------- Since we are now using ALSA, it's much easier to coexist with other sound applications. However, sound device specification has been changed. You should now type in ALSA names (normally 'default') instead of raw devices. Recording: ---------- Recording subsystem now uses ring buffers and the buffers are flushed in GTK thread on timeout. Although it would be possible to have special thread for this purpose, it doesn't really make sense, since we buffer about 2 seconds. In 2 seconds, the application better responds... Anyway, in the worst case, there will be some samples skipped. Also, recording tries to stitch together incoming samples on local as well as remote channels as it best fits based on time code. Certain jitter is compensated for automatically, bigger jitter may produce some cracks. However, in tests there was no such problem. Debug and error message handling: --------------------------------- All debug and error messages should now go through macros dbgprintf() and errprintf(). This allows for implementing of debug log viewer later. For new/rewritten code, all debug and error messages start with "COMPONENT: " prefix. This allows for easier identification in logs. Additionally, there are further debug levels, up to 4. Debug level 3 and higher prints very noisy information about each audio packet processed. Sleep and wakeup commands: -------------------------- Some ISDN card drivers need to be unloaded before suspending the machine to disk and loaded again after resume. This is not possible, as long as the application is holding the CAPI connection. Therefore, two new command-line commands have been implemented, which allow turning off and on the CAPI connection (--sleep and --wakeup, respectively). They can be integrated into suspend and resume scripts to take care of stopping and resuming CAPI. Code documentation: ------------------- Documentation for new code and for big rewritten parts has been changed to Doxygen format. Instead of plain comments, you'll see comments in form /*! ... */ with tags in form @tag, which allow Doxygen to generate pretty-printed source code reference documentation. Doxygen script file has not been actually produced. The rest of the files should be changed as well to use Doxygen format tags in documentation of functions and structures.
2007-11-24 17:55:27 +00:00
errprintf("Error: Out of memory.\n");
2007-11-24 13:45:25 +00:00
exit(1);
}
$$->type = ISDN_NODE_TYPE_ENTRY;
$$->name = $1;
$$->content.value = $3;
$$->next = NULL;
}
| ISDN_TOKEN_NAME '=' '{' config '}'
{
if (!($$ =
(isdn_tree_node_t*) malloc(sizeof(isdn_tree_node_t))))
{
Version 0.2.0: CAPI 2.0, ALSA, threading, low-latency. Changes in short: * Re-work of session handling to use sound and ISDN threads, which greatly reduces latency and CPU usage * Complete re-work of ISDN subsystem to use CAPI 2.0 * Complete re-work of sound subsystem to use ALSA * Re-work of recording subsystem to produce better results * Re-work of debug and error message handling (centralized) * Added --sleep and --wakeup remote commands to facilitate release and re-acquire of CAPI connection * Code documentation (partial) Reduced latency: ---------------- We are now using separate threads to handle ISDN input (and send it to audio output) and audio input (which again sends it to ISDN). This means, we are not dependent on GTK GUI reaction time. This enables very good sound quality with low latency and low CPU consumption (normally not measurable). Tested with 3x parallel "while true; do true; done" and "find /". No sound problems, even though the threads don't run with real time priority (which can be implemented now relatively easily, though). ISDN system: ------------ We now support CAPI 2.0. This means, any card supported by CAPI 2.0 should work and also ant-phone should be able to coexist with other ISDN applications. New CAPI code was tested with Fritz!Card, both with fcpci driver and with mISDN driver. There are also remote-CAPI implementations which forward local CAPI requests to a remote host (e.g., a Fritz!Box router). They should be also usable with new CAPI subsystem (not tested). Sound system: ------------- Since we are now using ALSA, it's much easier to coexist with other sound applications. However, sound device specification has been changed. You should now type in ALSA names (normally 'default') instead of raw devices. Recording: ---------- Recording subsystem now uses ring buffers and the buffers are flushed in GTK thread on timeout. Although it would be possible to have special thread for this purpose, it doesn't really make sense, since we buffer about 2 seconds. In 2 seconds, the application better responds... Anyway, in the worst case, there will be some samples skipped. Also, recording tries to stitch together incoming samples on local as well as remote channels as it best fits based on time code. Certain jitter is compensated for automatically, bigger jitter may produce some cracks. However, in tests there was no such problem. Debug and error message handling: --------------------------------- All debug and error messages should now go through macros dbgprintf() and errprintf(). This allows for implementing of debug log viewer later. For new/rewritten code, all debug and error messages start with "COMPONENT: " prefix. This allows for easier identification in logs. Additionally, there are further debug levels, up to 4. Debug level 3 and higher prints very noisy information about each audio packet processed. Sleep and wakeup commands: -------------------------- Some ISDN card drivers need to be unloaded before suspending the machine to disk and loaded again after resume. This is not possible, as long as the application is holding the CAPI connection. Therefore, two new command-line commands have been implemented, which allow turning off and on the CAPI connection (--sleep and --wakeup, respectively). They can be integrated into suspend and resume scripts to take care of stopping and resuming CAPI. Code documentation: ------------------- Documentation for new code and for big rewritten parts has been changed to Doxygen format. Instead of plain comments, you'll see comments in form /*! ... */ with tags in form @tag, which allow Doxygen to generate pretty-printed source code reference documentation. Doxygen script file has not been actually produced. The rest of the files should be changed as well to use Doxygen format tags in documentation of functions and structures.
2007-11-24 17:55:27 +00:00
errprintf("Error: Out of memory.\n");
2007-11-24 13:45:25 +00:00
exit(1);
}
$$->type = ISDN_NODE_TYPE_SUBSECTION;
$$->name = $1;
$$->content.subsection = $4.list;
/* finally: only list needed */
$$->next = NULL;
}
;
value : ISDN_TOKEN_VALUE
| ISDN_TOKEN_NAME
;
%%
/*
* callback for yyparse(), (also) called on errors (hopefully) handled
* by error token actions in grammar, but not if errors occur to
* often (bison needs 3 "correct" tokens to recover)
*/
void isdn_error(const char *message) {
if (debug)
Version 0.2.0: CAPI 2.0, ALSA, threading, low-latency. Changes in short: * Re-work of session handling to use sound and ISDN threads, which greatly reduces latency and CPU usage * Complete re-work of ISDN subsystem to use CAPI 2.0 * Complete re-work of sound subsystem to use ALSA * Re-work of recording subsystem to produce better results * Re-work of debug and error message handling (centralized) * Added --sleep and --wakeup remote commands to facilitate release and re-acquire of CAPI connection * Code documentation (partial) Reduced latency: ---------------- We are now using separate threads to handle ISDN input (and send it to audio output) and audio input (which again sends it to ISDN). This means, we are not dependent on GTK GUI reaction time. This enables very good sound quality with low latency and low CPU consumption (normally not measurable). Tested with 3x parallel "while true; do true; done" and "find /". No sound problems, even though the threads don't run with real time priority (which can be implemented now relatively easily, though). ISDN system: ------------ We now support CAPI 2.0. This means, any card supported by CAPI 2.0 should work and also ant-phone should be able to coexist with other ISDN applications. New CAPI code was tested with Fritz!Card, both with fcpci driver and with mISDN driver. There are also remote-CAPI implementations which forward local CAPI requests to a remote host (e.g., a Fritz!Box router). They should be also usable with new CAPI subsystem (not tested). Sound system: ------------- Since we are now using ALSA, it's much easier to coexist with other sound applications. However, sound device specification has been changed. You should now type in ALSA names (normally 'default') instead of raw devices. Recording: ---------- Recording subsystem now uses ring buffers and the buffers are flushed in GTK thread on timeout. Although it would be possible to have special thread for this purpose, it doesn't really make sense, since we buffer about 2 seconds. In 2 seconds, the application better responds... Anyway, in the worst case, there will be some samples skipped. Also, recording tries to stitch together incoming samples on local as well as remote channels as it best fits based on time code. Certain jitter is compensated for automatically, bigger jitter may produce some cracks. However, in tests there was no such problem. Debug and error message handling: --------------------------------- All debug and error messages should now go through macros dbgprintf() and errprintf(). This allows for implementing of debug log viewer later. For new/rewritten code, all debug and error messages start with "COMPONENT: " prefix. This allows for easier identification in logs. Additionally, there are further debug levels, up to 4. Debug level 3 and higher prints very noisy information about each audio packet processed. Sleep and wakeup commands: -------------------------- Some ISDN card drivers need to be unloaded before suspending the machine to disk and loaded again after resume. This is not possible, as long as the application is holding the CAPI connection. Therefore, two new command-line commands have been implemented, which allow turning off and on the CAPI connection (--sleep and --wakeup, respectively). They can be integrated into suspend and resume scripts to take care of stopping and resuming CAPI. Code documentation: ------------------- Documentation for new code and for big rewritten parts has been changed to Doxygen format. Instead of plain comments, you'll see comments in form /*! ... */ with tags in form @tag, which allow Doxygen to generate pretty-printed source code reference documentation. Doxygen script file has not been actually produced. The rest of the files should be changed as well to use Doxygen format tags in documentation of functions and structures.
2007-11-24 17:55:27 +00:00
errprintf(
2007-11-24 13:45:25 +00:00
"Warning: Parsing isdn options file: %d:%d: %s.\n",
isdn_lloc.first_line, isdn_lloc.first_column, message);
}