|
From: | Luke Berndt |
Subject: | [Discuss-gnuradio] Locking TopBlock stops WavFile-Sink |
Date: | Mon, 5 Jan 2015 07:21:26 -0500 |
It looks like there is an issue where locking/unlocking the TopBlock causes WavFile-Sink to stop recording. A plain File-Sink does not have this problem. This problem is new to 3.7 and didn’t exist in 3.6. Is this the intended behavior? I am doing something wrong? Should I be using Stop/Wait? I have put together an even more simplified C++ program here: https://github.com/robotastic/topblock-lock When you run it, the wav file will stop growing after 5 secs when the graph is locked/unlocked and the file sink raw file will keep growing. To compile, do ‘cmake .’ then ‘make’ then ‘topblock-lock' Here is the basic code: time_t last_monkey; gr::top_block_sptr tb; gr::blocks::vector_source_f::sptr src; gr::blocks::throttle::sptr throttle; gr::blocks::wavfile_sink::sptr wav_sink; gr::blocks::file_sink::sptr raw_sink; char filename[160]; char raw_filename[160]; volatile sig_atomic_t exit_flag = 0; void exit_interupt(int sig){ // can be called asynchronously exit_flag = 1; // set flag } int main(int argc, char **argv) { std::string device_addr; double samp_rate=32000; signal(SIGINT, exit_interupt); tb = gr::make_top_block("Main"); vector<float> floatVector; srand((unsigned)time(NULL)); for (int i =0; i < 2000; i++){ float r = static_cast <float> (rand()) / static_cast <float> (RAND_MAX); floatVector.push_back(r); } src = ""> throttle = gr::blocks::throttle::make(sizeof(float), samp_rate); std::stringstream path_stream; path_stream << boost::filesystem::current_path().string() << "/recordings"; boost::filesystem::create_directories(path_stream.str()); sprintf(filename, "%s/main-0.wav", path_stream.str().c_str()); wav_sink = gr::blocks::wavfile_sink::make(filename,1,samp_rate,16); sprintf(raw_filename, "%s/main-0.raw", path_stream.str().c_str()); raw_sink = gr::blocks::file_sink::make(sizeof(float), raw_filename); tb->connect(src,0,throttle,0); tb->connect(throttle,0,wav_sink,0); tb->connect(throttle,0,raw_sink,0); last_monkey = time(NULL); tb->start(); while (1) { if(exit_flag){ printf("\n Signal caught!\n"); tb->stop(); return 0; } if ((time(NULL) - last_monkey) > 10) { last_monkey = time(NULL); tb->lock(); tb->unlock(); } } // Exit normally. return 0; } |
[Prev in Thread] | Current Thread | [Next in Thread] |