#include <WavInfo.h>
Public Methods | |
WavInfo () | |
virtual void | initServer () |
virtual void | processServer () |
int | get_exit_value () const |
void | set_exit_value (int v_) |
Private Methods | |
virtual void | pos_arg (const char *arg_) |
Private Attributes | |
string | m_wav_file |
u_int | m_pos_arg_count |
int | m_exit_value |
bool | m_silent |
|
Definition at line 34 of file WavInfo.cpp. References m_silent.
00035 : m_pos_arg_count (0), 00036 m_exit_value (0), 00037 m_silent (false) 00038 { 00039 // ---Configuration--- 00040 rm_opt ('f', "config-file" ); 00041 rm_opt ('n', "instance" ); 00042 rm_opt ('p', "port" ); 00043 00044 // ---Process bookkeeping--- 00045 rm_opt ('b', "daemon" ); 00046 rm_opt ('l', "pidfile" ); 00047 rm_opt ('L', "ommit-pidfile"); 00048 00049 add_flag_opt (0, "silent", &m_silent); 00050 00051 m_log_file = "/dev/null"; 00052 m_debug_mask = 0; 00053 } |
|
Definition at line 39 of file WavInfo.h. References m_exit_value. Referenced by main.
00039 { return m_exit_value; } |
|
Definition at line 74 of file WavInfo.cpp. References m_pos_arg_count, and set_exit_value. Referenced by main.
00075 { 00076 trace("WavInfo::initServer"); 00077 ASSA::Log::disable_timestamp (); 00078 00079 if (m_pos_arg_count != 1) { 00080 std::cerr << "WavPause: missing wav file\n" 00081 << "Try `WavPause --help` for more information.\n"; 00082 set_exit_value (1); 00083 return; 00084 } 00085 00086 if (m_silent) { 00087 close (1); 00088 close (2); 00089 pid_t nullfd = 0; 00090 nullfd = open("/dev/null", O_WRONLY | O_CREAT, 0666); 00091 (void) dup2 (nullfd, 1); 00092 (void) dup2 (nullfd, 2); 00093 (void) close (nullfd); 00094 } 00095 DL((APP,"Service has been initialized\n")); 00096 } |
|
Definition at line 56 of file WavInfo.cpp. References m_pos_arg_count, and m_wav_file.
00057 { 00058 trace("WavInfo::pos_arg"); 00059 00060 switch(m_pos_arg_count) { 00061 case 0: 00062 m_wav_file = arg_; 00063 break; 00064 00065 default: 00066 std::cerr << "Error: unexpected argument " << arg_ << '\n' 00067 << "Try `WavInfo --help` for more information.\n"; 00068 Assert_exit (false); 00069 } 00070 m_pos_arg_count++; 00071 } |
|
Definition at line 99 of file WavInfo.cpp. References m_wav_file, and set_exit_value. Referenced by main.
00100 { 00101 trace("WavInfo::processServer"); 00102 00103 if (stopServer ()) { 00104 return; 00105 } 00106 00107 AFfilehandle in_file; 00108 in_file = afOpenFile (m_wav_file.c_str (), "r", NULL); 00109 00110 if (in_file == NULL) { 00111 EL((ERROR,"File \"%s\" open error\n", m_wav_file.c_str ())); 00112 set_exit_value (1); 00113 return; 00114 } 00115 00116 char* formatstring; 00117 char* labelstring; 00118 int in_file_format = -1; 00119 int version; 00120 00121 in_file_format = afGetFileFormat (in_file, &version); 00122 00123 formatstring = 00124 (char *) afQueryPointer (AF_QUERYTYPE_FILEFMT, 00125 AF_QUERY_DESC, 00126 in_file_format, 00127 0, 0); 00128 labelstring = 00129 (char *) afQueryPointer (AF_QUERYTYPE_FILEFMT, 00130 AF_QUERY_LABEL, 00131 in_file_format, 00132 0, 0); 00133 00134 if (formatstring == NULL || labelstring == NULL) { 00135 EL((ERROR,"Corrupted header in \"%s\"\n", m_wav_file.c_str ())); 00136 set_exit_value (1); 00137 return; 00138 } 00139 00140 std::cout << '\n' 00141 << "File Name: " << m_wav_file << '\n' 00142 << "File Format: " << formatstring << " (" 00143 << labelstring << ")\n"; 00144 00145 int sampleFormat; 00146 int sampleWidth; 00147 int byteOrder; 00148 int compressionType; 00149 00150 afGetSampleFormat(in_file, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth); 00151 byteOrder = afGetByteOrder(in_file, AF_DEFAULT_TRACK); 00152 00153 std::cout << "Data Format: "; 00154 00155 compressionType = afGetCompression (in_file, AF_DEFAULT_TRACK); 00156 00157 if (compressionType == AF_COMPRESSION_NONE) { 00158 switch (sampleFormat) { 00159 case AF_SAMPFMT_TWOSCOMP: 00160 std::cout << sampleWidth << "-bit integer (2's complement, " 00161 << (byteOrder == AF_BYTEORDER_BIGENDIAN ? 00162 "big endian" : "little endian") 00163 << ")"; 00164 break; 00165 00166 case AF_SAMPFMT_UNSIGNED: 00167 std::cout << sampleWidth << "-bit integer (unsigned, " 00168 << (byteOrder == AF_BYTEORDER_BIGENDIAN ? 00169 "big endian" : "little endian") 00170 << ")"; 00171 break; 00172 00173 case AF_SAMPFMT_FLOAT: 00174 std::cout << "single-precision (32-bit) floating point, " 00175 << (byteOrder == AF_BYTEORDER_BIGENDIAN ? 00176 "big endian" : "little endian"); 00177 break; 00178 00179 case AF_SAMPFMT_DOUBLE: 00180 std::cout << "double-precision (64-bit) floating point, " 00181 << (byteOrder == AF_BYTEORDER_BIGENDIAN ? 00182 "big endian" : "little endian"); 00183 break; 00184 00185 default: 00186 std::cout << "unknown"; 00187 break; 00188 } 00189 } 00190 else { 00191 char* compressionName; 00192 compressionName = (char*) afQueryPointer (AF_QUERYTYPE_COMPRESSION, 00193 AF_QUERY_NAME, 00194 compressionType, 00195 0, 0); 00196 if (compressionName == NULL) { 00197 std::cout << "unknown compression"; 00198 } 00199 else { 00200 std::cout << compressionName << " compression"; 00201 } 00202 } 00203 std::cout << "\n"; 00204 00205 std::cout << "Audio Data: " 00206 << afGetTrackBytes(in_file, AF_DEFAULT_TRACK) 00207 << " bytes begins at offset " 00208 << afGetDataOffset(in_file, AF_DEFAULT_TRACK) 00209 << '(' << std::hex << afGetDataOffset(in_file, AF_DEFAULT_TRACK) 00210 << " hex)\n"; 00211 00212 AFframecount total_frames = afGetFrameCount (in_file, AF_DEFAULT_TRACK); 00213 int frame_size = (int)afGetVirtualFrameSize (in_file, AF_DEFAULT_TRACK, 1); 00214 00215 int channel_count = afGetChannels(in_file, AF_DEFAULT_TRACK); 00216 00217 std::cout << " " << channel_count << " channel" 00218 << (afGetChannels(in_file, AF_DEFAULT_TRACK) > 1 ? "s, " : ", ") 00219 << std::dec << total_frames << " frames\n"; 00220 00221 double sample_rate = afGetRate(in_file, AF_DEFAULT_TRACK); 00222 std::cout << "Sampling Rate: " << sample_rate << " Hz\n"; 00223 00224 double duration = afGetFrameCount(in_file, AF_DEFAULT_TRACK) / 00225 afGetRate(in_file, AF_DEFAULT_TRACK); 00226 00227 std::cout << "Duration: " << duration << " seconds\n" 00228 << '\n'; 00229 00230 afCloseFile (in_file); 00231 m_reactor.stopReactor (); 00232 DL((APP,"Service stopped!\n")); 00233 } |
|
Definition at line 40 of file WavInfo.h. References m_exit_value. Referenced by initServer, and processServer.
00040 { m_exit_value = v_; } |
|
Definition at line 49 of file WavInfo.h. Referenced by get_exit_value, and set_exit_value. |
|
Definition at line 48 of file WavInfo.h. Referenced by initServer, and pos_arg. |
|
Definition at line 50 of file WavInfo.h. Referenced by WavInfo. |
|
Definition at line 47 of file WavInfo.h. Referenced by pos_arg, and processServer. |