#include "standard.h"
#include "bits.h"
#include "config.h"
#include "audio.h"
Go to the source code of this file.
Defines | |
#define | DEF_AUD_INPUT_FILE "audio.in" |
#define | DEF_AUD_OUTPUT_FILE "audio.rec" |
Functions | |
audio_codec * | new_audio_codec (char *name) |
void | close_audio_codec (audio_codec *a) |
void | code_audio (audio_codec *a) |
void | decode_audio (audio_codec *a) |
Variables | |
int | debug |
|
Definition at line 14 of file audio.c. Referenced by new_audio_codec(). |
|
Definition at line 15 of file audio.c. Referenced by new_audio_codec(). |
|
Definition at line 41 of file audio.c. References a, audio_codec::input_file, audio_codec::name, and print_time(). Referenced by cleanup(). 00045 { 00046 if (a->input_file != NULL) { 00047 printf("%s AUDIO [%s] closing input file.\n", print_time(), a->name); 00048 fclose(a->input_file); 00049 } 00050 free(a); 00051 }
|
|
Definition at line 54 of file audio.c. References a, al_send_request(), bytes::block, error(), get_clock(), audio_codec::input_file, audio_codec::input_filename, audio_codec::name, new_bytes(), audio_codec::output, print_time(), randomize_byte(), and warn(). Referenced by main_loop(). 00058 { 00059 bytes *b; 00060 int size,r,i,sendok; 00061 00062 if (get_clock() % 30 == 0) /* encode every 30 ms */ 00063 { 00064 /* generate bytes structure to send of size 27 23 or 6*/ 00065 r = rand() % 3; 00066 switch (r) { 00067 case 0: 00068 size = 27; 00069 break; 00070 case 1: 00071 size = 23; 00072 break; 00073 case 2: 00074 size = 6; 00075 break; 00076 } 00077 00078 if (debug) { 00079 printf("%s AUDIO [%s] sent %d bytes\n", print_time(), a->name, size); 00080 } 00081 00082 b = new_bytes(size); 00083 if (!a->input_file) { 00084 a->input_file=fopen(a->input_filename, "r"); 00085 if (!a->input_file) { 00086 warn("code_audio", "input audio file does not exist.\n"); 00087 a->input_filename[0]=0; 00088 } 00089 } 00090 for (i=0;i<size;i++) { 00091 if (a->input_filename[0]) { 00092 if (feof(a->input_file)) 00093 fseek(a->input_file,0,0); 00094 b->block[i] = fgetc(a->input_file); 00095 } 00096 else { 00097 randomize_byte((b->block)+i); 00098 } 00099 } 00100 00101 /* send it to the al sending entity */ 00102 sendok = al_send_request(a->output, b); 00103 if (!sendok) 00104 error("code_audio","Sending bytes to AL failed"); 00105 } 00106 }
|
|
Definition at line 110 of file audio.c. References a, al_indication(), al_receive(), byte, error(), audio_codec::input, and audio_codec::output_filename. Referenced by main_loop(). 00115 { 00116 byte b; 00117 00118 FILE *outfile=NULL; 00119 00120 if (al_indication(a->input)) { 00121 outfile = fopen(a->output_filename, "a"); 00122 if (outfile == NULL) { 00123 error("decode_audio", "couldn't open output file"); 00124 } 00125 } 00126 00127 while (al_indication(a->input)) { 00128 b = al_receive(a->input); 00129 00130 fputc(b, outfile); 00131 } 00132 00133 if (outfile) { 00134 fclose(outfile); 00135 } 00136 }
|
|
Definition at line 17 of file audio.c. References a, DEF_AUD_INPUT_FILE, DEF_AUD_OUTPUT_FILE, error(), audio_codec::input_file, audio_codec::input_filename, audio_codec::name, and audio_codec::output_filename. Referenced by start_config(). 00021 { 00022 char s[256]; 00023 int x; 00024 audio_codec *a; 00025 00026 a = (audio_codec *) malloc(sizeof(audio_codec)); 00027 if (a == NULL) 00028 error("new_audio_codec","can't malloc audio codec"); 00029 00030 strcpy(a->name, name); 00031 00032 strcpy(a->input_filename, DEF_AUD_INPUT_FILE); 00033 strcpy(a->output_filename, DEF_AUD_OUTPUT_FILE); 00034 00035 a->input_file=NULL; 00036 00037 return a; 00038 }
|
|
|