Commit 24e7c7ed authored by Arnaud Blanchard's avatar Arnaud Blanchard

Add blc_quit in parameter of blc_init of each program

parent b38b5fba
Pipeline #53 failed with stages
......@@ -77,12 +77,14 @@ void input_queue_callback( void *inUserData, AudioQueueRef inAQ, AudioQueueBuffe
//Read keyboard, eventually wait for data_ack
if (sem_trywait(output.sem_ack_data)==-1){
if (errno==EAGAIN) {
fprintf(stderr, "%s: reader not ready iteration %d\n", blc_program_name, blc_loop_iteration);
ready=0;
if (output.sem_ack_data){
if (sem_trywait(output.sem_ack_data)==-1){
if (errno==EAGAIN) {
fprintf(stderr, "%s: reader not ready iteration %d\n", blc_program_name, blc_loop_iteration);
ready=0;
}
else EXIT_ON_SYSTEM_ERROR("");
}
else EXIT_ON_SYSTEM_ERROR(NULL);
}
......@@ -111,7 +113,7 @@ void input_queue_callback( void *inUserData, AudioQueueRef inAQ, AudioQueueBuffe
blc_command_loop_end();
}
void start_acquisition(AudioQueueRef queue){
void start_acquisition(AudioQueueRef queue, int samplerate){
AudioQueueBufferRef buffer[QUEUE_BUFFERS_NB];
AudioStreamBasicDescription audio_format;
OSStatus err;
......@@ -119,7 +121,7 @@ void start_acquisition(AudioQueueRef queue){
//OS X audio management
CLEAR(audio_format);
audio_format.mSampleRate = 44100;
audio_format.mSampleRate = samplerate;
audio_format.mFormatID= kAudioFormatLinearPCM;
switch (output.type){
......@@ -158,38 +160,36 @@ void start_acquisition(AudioQueueRef queue){
int main(int argc, char **argv)
{
AudioQueueRef queue=NULL;
char const *length_str, *type_str;
char *output_name;
char const *length_str, *type_str, *samplerate_str;
char const *output_name;
int samplerate;
uint32_t type='FL32';
blc_program_set_description("Acquire the audio buffer.");
// blc_program_add_option(&synchro_new_data, '/', "new_data_post", NULL, "send new data post to all outputs blc_channels", NULL);
blc_program_add_option(&display, 'd', "display", "F|WIDTHxHEIGHT", "display a text graph. 'F' for fullscreen. -1 for width or heigt for max dimention.", NULL);
blc_program_add_option((char const**)&output_name, 'o', "output", "string", "name of the channel where the buffer will be put", DEFAULT_OUTPUT_NAME);
blc_program_add_option(&samplerate_str, 'S', "samplerate", "integer", "frequency of sampling", "44100");
blc_program_add_option(&output_name, 'o', "output", "string", "name of the channel where the buffer will be put", DEFAULT_OUTPUT_NAME);
blc_program_add_option(&length_str, 's', "size", "integer", "size of the sound buffer", "4096");
blc_program_add_option(&type_str, 't', "type", "INT8|FL32", "type of the data", "FL32");
blc_program_init(&argc, &argv, NULL);
blc_program_init(&argc, &argv, blc_quit);
SSCANF(1, length_str, "%ld", &buffer_length);
SSCANF(1, samplerate_str, "%d", &samplerate);
type=STRING_TO_UINT32(type_str);
if (display) init_terminal_display(display);
if (strcmp(DEFAULT_OUTPUT_NAME, output_name)==0) {
asprintf(&output_name, ":sound%d", getpid());
asprintf((char**)&output_name, ":sound%d", getpid());
}
output.create_or_open(output_name, BLC_CHANNEL_WRITE, type, 'LPCM', 1, buffer_length);
output.publish();
//The blc_command_loop_start will block until someone read and aknowledge the result.
// blc_loop_try_add_waiting_semaphore(output.sem_ack_data);
//if (channel.sem_new_data) blc_loop_add_posting_semaphore(channel.sem_new_data);
blc_command_loop_init(0);
//start_acquisition starts a non blocking thread calling regularly (each time new sound buffer avalable) input_queue_callback.
start_acquisition(queue);
start_acquisition(queue, samplerate);
//We wait for quiting request
blc_loop_wait_stop();
......
......@@ -155,7 +155,7 @@ int main(int argc, char **argv)
blc_program_add_option(&display, 'd', "display", "F|WIDTHxHEIGHT", "display a text graph. 'F' for fullscreen. -1 for width or heigt for max dimention.", NULL);
blc_program_add_option(&type_str, 't', "type", "INT8|FL32", "type of the data", "FL32");
blc_program_add_parameter(&input_name, "blc_channel", 1, "channel to play sound", NULL);
blc_program_init(&argc, &argv, NULL);
blc_program_init(&argc, &argv, blc_quit);
type=STRING_TO_UINT32(type_str);
if (display) init_terminal_display(display);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment