mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 03:50:31 +00:00
Version 0.1.7 from FTP
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@251 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
26
asterisk.c
26
asterisk.c
@@ -17,6 +17,8 @@
|
|||||||
#include <asterisk/options.h>
|
#include <asterisk/options.h>
|
||||||
#include <asterisk/cli.h>
|
#include <asterisk/cli.h>
|
||||||
#include <asterisk/channel.h>
|
#include <asterisk/channel.h>
|
||||||
|
#include <asterisk/ulaw.h>
|
||||||
|
#include <asterisk/callerid.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
@@ -35,9 +37,6 @@ int fully_booted = 0;
|
|||||||
|
|
||||||
char defaultlanguage[MAX_LANGUAGE] = DEFAULT_LANGUAGE;
|
char defaultlanguage[MAX_LANGUAGE] = DEFAULT_LANGUAGE;
|
||||||
|
|
||||||
#define HIGH_PRIORITY 1
|
|
||||||
#define HIGH_PRIORITY_SCHED SCHED_RR
|
|
||||||
|
|
||||||
static void urg_handler(int num)
|
static void urg_handler(int num)
|
||||||
{
|
{
|
||||||
/* Called by soft_hangup to interrupt the select, read, or other
|
/* Called by soft_hangup to interrupt the select, read, or other
|
||||||
@@ -64,14 +63,17 @@ static void set_icon(char *text)
|
|||||||
static int set_priority(int pri)
|
static int set_priority(int pri)
|
||||||
{
|
{
|
||||||
struct sched_param sched;
|
struct sched_param sched;
|
||||||
|
memset(&sched, 0, sizeof(sched));
|
||||||
/* We set ourselves to a high priority, that we might pre-empt everything
|
/* We set ourselves to a high priority, that we might pre-empt everything
|
||||||
else. If your PBX has heavy activity on it, this is a good thing. */
|
else. If your PBX has heavy activity on it, this is a good thing. */
|
||||||
if (pri) {
|
if (pri) {
|
||||||
sched.sched_priority = HIGH_PRIORITY;
|
sched.sched_priority = 10;
|
||||||
if (sched_setscheduler(0, HIGH_PRIORITY_SCHED, &sched)) {
|
if (sched_setscheduler(0, SCHED_RR, &sched)) {
|
||||||
ast_log(LOG_WARNING, "Unable to set high priority\n");
|
ast_log(LOG_WARNING, "Unable to set high priority\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
} else
|
||||||
|
if (option_verbose)
|
||||||
|
ast_verbose("Set to realtime thread\n");
|
||||||
} else {
|
} else {
|
||||||
sched.sched_priority = 0;
|
sched.sched_priority = 0;
|
||||||
if (sched_setscheduler(0, SCHED_OTHER, &sched)) {
|
if (sched_setscheduler(0, SCHED_OTHER, &sched)) {
|
||||||
@@ -161,6 +163,11 @@ int main(int argc, char *argv[])
|
|||||||
fd_set rfds;
|
fd_set rfds;
|
||||||
int res;
|
int res;
|
||||||
char filename[80] = "";
|
char filename[80] = "";
|
||||||
|
char hostname[256];
|
||||||
|
if (gethostname(hostname, sizeof(hostname)))
|
||||||
|
strncpy(hostname, "<Unknown>", sizeof(hostname));
|
||||||
|
ast_ulaw_init();
|
||||||
|
callerid_init();
|
||||||
if (getenv("HOME"))
|
if (getenv("HOME"))
|
||||||
snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
|
snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
|
||||||
/* Check if we're root */
|
/* Check if we're root */
|
||||||
@@ -178,6 +185,7 @@ int main(int argc, char *argv[])
|
|||||||
case 'c':
|
case 'c':
|
||||||
option_console++;
|
option_console++;
|
||||||
option_nofork++;
|
option_nofork++;
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
option_highpriority++;
|
option_highpriority++;
|
||||||
break;
|
break;
|
||||||
@@ -205,14 +213,14 @@ int main(int argc, char *argv[])
|
|||||||
signal(SIGINT, quit_handler);
|
signal(SIGINT, quit_handler);
|
||||||
signal(SIGTERM, quit_handler);
|
signal(SIGTERM, quit_handler);
|
||||||
signal(SIGHUP, quit_handler);
|
signal(SIGHUP, quit_handler);
|
||||||
|
if (set_priority(option_highpriority))
|
||||||
|
exit(1);
|
||||||
if (init_logger())
|
if (init_logger())
|
||||||
exit(1);
|
exit(1);
|
||||||
if (load_pbx())
|
if (load_pbx())
|
||||||
exit(1);
|
exit(1);
|
||||||
if (load_modules())
|
if (load_modules())
|
||||||
exit(1);
|
exit(1);
|
||||||
if (set_priority(option_highpriority))
|
|
||||||
exit(1);
|
|
||||||
/* We might have the option of showing a console, but for now just
|
/* We might have the option of showing a console, but for now just
|
||||||
do nothing... */
|
do nothing... */
|
||||||
if (option_console && !option_verbose)
|
if (option_console && !option_verbose)
|
||||||
@@ -225,7 +233,7 @@ int main(int argc, char *argv[])
|
|||||||
/* Register our quit function */
|
/* Register our quit function */
|
||||||
char title[256];
|
char title[256];
|
||||||
set_icon("Asterisk");
|
set_icon("Asterisk");
|
||||||
snprintf(title, sizeof(title), "Asterisk Console (pid %d)", getpid());
|
snprintf(title, sizeof(title), "Asterisk Console on '%s' (pid %d)", hostname, getpid());
|
||||||
set_title(title);
|
set_title(title);
|
||||||
ast_cli_register(&quit);
|
ast_cli_register(&quit);
|
||||||
consolethread = pthread_self();
|
consolethread = pthread_self();
|
||||||
|
@@ -7,11 +7,11 @@
|
|||||||
SASR = -DSASR
|
SASR = -DSASR
|
||||||
######### Define SASR if >> is a signed arithmetic shift (-1 >> 1 == -1)
|
######### Define SASR if >> is a signed arithmetic shift (-1 >> 1 == -1)
|
||||||
|
|
||||||
MULHACK = -DUSE_FLOAT_MUL
|
#MULHACK = -DUSE_FLOAT_MUL
|
||||||
######### Define this if your host multiplies floats faster than integers,
|
######### Define this if your host multiplies floats faster than integers,
|
||||||
######### e.g. on a SPARCstation.
|
######### e.g. on a SPARCstation.
|
||||||
|
|
||||||
FAST = -DFAST
|
#FAST = -DFAST
|
||||||
######### Define together with USE_FLOAT_MUL to enable the GSM library's
|
######### Define together with USE_FLOAT_MUL to enable the GSM library's
|
||||||
######### approximation option for incorrect, but good-enough results.
|
######### approximation option for incorrect, but good-enough results.
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ WAV49 = -DWAV49
|
|||||||
# CC = /usr/lang/acc
|
# CC = /usr/lang/acc
|
||||||
# CCFLAGS = -c -O
|
# CCFLAGS = -c -O
|
||||||
|
|
||||||
CC = gcc -ansi -pedantic
|
CC = gcc -ansi -pedantic -O6 -mpentium -fomit-frame-pointer -fschedule-insns2
|
||||||
CCFLAGS += -c -DNeedFunctionPrototypes=1 -finline-functions -funroll-loops
|
CCFLAGS += -c -DNeedFunctionPrototypes=1 -finline-functions -funroll-loops
|
||||||
|
|
||||||
LD = $(CC)
|
LD = $(CC)
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
# the GNU General Public License
|
# the GNU General Public License
|
||||||
#
|
#
|
||||||
|
|
||||||
FORMAT_LIBS=format_g723.so format_wav.so format_mp3.so format_wav_gsm.so format_gsm.so
|
FORMAT_LIBS=format_g723.so format_wav.so format_mp3.so format_wav_gsm.so format_gsm.so format_vox.so
|
||||||
|
|
||||||
GSMLIB=../codecs/gsm/lib/libgsm.a
|
GSMLIB=../codecs/gsm/lib/libgsm.a
|
||||||
|
|
||||||
@@ -28,5 +28,8 @@ clean:
|
|||||||
format_wav.so : format_wav.o
|
format_wav.so : format_wav.o
|
||||||
$(CC) -shared -Xlinker -x -o $@ $< -laudiofile
|
$(CC) -shared -Xlinker -x -o $@ $< -laudiofile
|
||||||
|
|
||||||
|
format_mp3.so : format_mp3.o
|
||||||
|
$(CC) -shared -Xlinker -x -o $@ $< -lm
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
for x in $(FORMAT_LIBS); do $(INSTALL) -m 755 $$x $(MODULES_DIR) ; done
|
for x in $(FORMAT_LIBS); do $(INSTALL) -m 755 $$x $(MODULES_DIR) ; done
|
||||||
|
@@ -230,8 +230,8 @@ static int gsm_write(struct ast_filestream *fs, struct ast_frame *f)
|
|||||||
ast_log(LOG_WARNING, "Asked to write non-GSM frame (%d)!\n", f->subclass);
|
ast_log(LOG_WARNING, "Asked to write non-GSM frame (%d)!\n", f->subclass);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (f->datalen != 33) {
|
if (f->datalen % 33) {
|
||||||
ast_log(LOG_WARNING, "Invalid data length, %d, should be 33\n", f->datalen);
|
ast_log(LOG_WARNING, "Invalid data length, %d, should be multiple of 33\n", f->datalen);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if ((res = write(fs->fd, f->data, f->datalen)) != f->datalen) {
|
if ((res = write(fs->fd, f->data, f->datalen)) != f->datalen) {
|
||||||
@@ -296,3 +296,8 @@ char *description()
|
|||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *key()
|
||||||
|
{
|
||||||
|
return ASTERISK_GPL_KEY;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user