Aux_thread() { while(1) { boolean pcm_handle_opened = 0; if (Aux_detected == 1) { /* Aux가 핸들을 가지고 있을 경우*/ if (vendor.audio.skb.i2s0_owner_is == AUX) { if(vendor.audio.skb.i2s0_owner_to_be == NUGUCALL) { if (pcm_handle_opened) { pcm_close(); pcm_handle_opened = 0; vendor.audio.skb.i2s0_owner_is = NUGUCALL; } } else if(vendor.audio.skb.i2s0_owner_to_be == AUX) { if(!pcm_handle_opened) { pcm_handle_opened = 1; pcm_open() } } sleep(1000); } else { if (vendor.audio.skb.i2s0_owner_is == NUGUCALL) { print("can't get handle because of NUGUCALL); } else if (vendor.audio.skb.i2s0_owner_is == NUGU) { if (vendor.audio.skb.i2s0_owner_to_be != AUX) { vendor.audio.skb.i2s0_owner_to_be = AUX; } } sleep(1000); } } else { if(pcm_handle_opened) { vendor.audio.skb.i2s0_owner_to_be = NUGU; vendor.audio.skb.i2s0_owner_is = NUGU; } } } } NUGU_thread() { boolean nugucall_detect = 0, pcm_handle_opened = 1; while() { if (nugucall_detect == 1) { /* handle 필요 */ if (vendor.audio.skb.i2s0_owner_is == NUGU || endor.audio.skb.i2s0_owner_is == NUGUCALL) { if(pcm_handle_opened == 0) { pcm_handle_opened = 1; pcm_open(); } } else { vendor.audio.skb.i2s0_owner_to_be = NUGUCALL; } sleep(1000); } else { if(vendor.audio.skb.i2s0_owner_to_be != NUGU) /* AUX 또는 KARAOKE 가 handle 요구 */ { if (pcm_handle_opened) { pcm_close(); pcm_handle_opened = 0; } vendor.audio.skb.i2s0_owner_is = vendor.audio.skb.i2s0_owner_to_be; } else { if(vendor.audio.skb.i2s0_owner_is == NUGU) { if (!pcm_handle_opened) { pcm_open(); pcm_handle_opened = 1; } } } } } }