g_print("audio_open_input: %s\n",transmitter->microphone_name);
mic_buffer_size = 256;
-/*
- switch(protocol) {
- case ORIGINAL_PROTOCOL:
- mic_buffer_size = 720;
- break;
- case NEW_PROTOCOL:
- mic_buffer_size = 64;
- break;
-#ifdef SOAPYSDR
- case SOAPYSDR_PROTOCOL:
- mic_buffer_size = 720;
- break;
-#endif
- default:
- break;
- }
-*/
-
+
g_print("audio_open_input: mic_buffer_size=%d\n",mic_buffer_size);
i=0;
while(transmitter->microphone_name[i]!=' ') {
if(i>=FORMATS) {
g_print("audio_open_input: cannot find usable format\n");
+ audio_close_input();
return err;
}
mic_ring_buffer=(float *) g_new(float,MICRINGLEN);
mic_ring_read_pt = mic_ring_write_pt=0;
if (mic_ring_buffer == NULL) {
+ audio_close_input();
return -1;
}
mic_read_thread_id = g_thread_try_new("microphone",mic_read_thread,NULL,&error);
if(!mic_read_thread_id ) {
g_print("g_thread_new failed on mic_read_thread: %s\n",error->message);
+ audio_close_input();
+ return -1;
}
return 0;
static void process_ozy_byte(int b) {
int i,j;
+ float fsample;
switch(state) {
case SYNC_0:
if(b==SYNC) {
break;
case MIC_SAMPLE_LOW:
mic_sample|=(short)(b&0xFF);
- if(!transmitter->local_microphone) {
- mic_samples++;
- if(mic_samples>=mic_sample_divisor) { // reduce to 48000
- add_mic_sample(transmitter,(float)mic_sample/32768.0);
- mic_samples=0;
- }
+ mic_samples++;
+ if(mic_samples>=mic_sample_divisor) { // reduce to 48000
+ fsample = transmitter->local_microphone ? audio_get_next_mic_sample() : (float) mic_sample * 0.00003051;
+ add_mic_sample(transmitter,fsample);
+ mic_samples=0;
}
nsamples++;
if(nsamples==iq_samples) {