📄 voudp.cpp
字号:
//// Copyright 2004 Alan Post//// This file is part of voudp.//// voudp 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.//// voudp 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// voudp; if not, write to the Free Software Foundation, Inc., 59 Temple Place,// Suite 330, Boston, MA 02111-1307 USA//#include "constants.h"#include "sender.h"#include "die.h"#include <unistd.h>#include <assert.h>#include <stdio.h>static size_t read_fully( int infd, char *buf, size_t to_read ){ size_t total_read = 0; while ( 1 ) { ssize_t nread = read( infd, buf + total_read, to_read - total_read ); if ( nread == -1 ) die ( "read" ); total_read += (size_t) nread; if ( nread == 0 || total_read == to_read ) return total_read; } assert( "not reachable" == NULL ); return 0;}int main( int argc, char **argv ){ setbuf( stderr, NULL ); Sender sender; recipient_info_t info = { argv[1], atoi( argv[2]), (size_t) atol( argv[3]), (size_t) atol( argv[4])}; sender.set_recipient_info( "BATZOOKA", info ); sender.start_recipient( "BATZOOKA" ); u_int16_t mono_u_frame[ samples_per_frame ]; float frame[ samples_per_frame ]; size_t bytes_read; while ( bytes_read = read_fully( STDIN_FILENO, (char*)mono_u_frame, sizeof( mono_u_frame )), bytes_read > 0 ) { for ( size_t i = 0; i < samples_per_frame; i++ ) { int32_t s = mono_u_frame[i]; s -= 32768; frame[ i ] = (float) s; } sender.push_frame( frame ); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -