Commit c63265904f73de4c4e2b158d6b24ee49e433562c
1 parent
804e56cd
fix(source convert):Closes #I3Y1L0
Showing
1 changed file
with
77 additions
and
42 deletions
| ... | ... | @@ -113,28 +113,17 @@ void taskKeyFunc(void) |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | -/******************************************************************************** | |
| 117 | -* poweron defalt souce * | |
| 118 | -*********************************************************************************/ | |
| 119 | - | |
| 120 | -#define MEDIA_DEFAULT MEDIA_AUX | |
| 121 | -//#define MEDIA_DEFAULT MEDIA_BT_HCI | |
| 122 | -//#define MEDIA_DEFAULT MEDIA_USB_DEVICE | |
| 123 | - | |
| 124 | -U8 app_defalt_poweron_souce (void) | |
| 125 | -{ | |
| 126 | - return MEDIA_DEFAULT; | |
| 127 | -} | |
| 128 | - | |
| 129 | 116 | typedef struct{ |
| 130 | 117 | U32 source_id; |
| 131 | 118 | void (*source_entry)(void); |
| 132 | 119 | } APP_NAV_SOURCE; |
| 133 | 120 | |
| 121 | + | |
| 122 | +//first element in this table use for default source | |
| 134 | 123 | const APP_NAV_SOURCE source_table[] = |
| 135 | 124 | { |
| 136 | - //{MEDIA_BT_HCI,app_nav_rmt_convert_bt_hci}, | |
| 137 | - {MEDIA_AUX,app_nav_rmt_convert_aux}, | |
| 125 | + {MEDIA_AUX,app_nav_rmt_convert_aux}, | |
| 126 | + {MEDIA_BT_HCI,app_nav_rmt_convert_bt_hci}, | |
| 138 | 127 | {MEDIA_OPTICAL,app_nav_rmt_convert_spdif}, |
| 139 | 128 | |
| 140 | 129 | #ifdef USB_HOST_ENABLE |
| ... | ... | @@ -146,7 +135,7 @@ const APP_NAV_SOURCE source_table[] = |
| 146 | 135 | #endif |
| 147 | 136 | |
| 148 | 137 | #if ( (defined USB_DEV_ENABLE) && (defined USB_SPEAKER) ) |
| 149 | - {MEDIA_USB_SPEAKER, app_nav_rmt_convert_pc_speaker}, | |
| 138 | + //{MEDIA_USB_SPEAKER, app_nav_rmt_convert_pc_speaker}, | |
| 150 | 139 | #endif |
| 151 | 140 | |
| 152 | 141 | // {MEDIA_OPTICAL,app_nav_rmt_convert_spdif}, |
| ... | ... | @@ -154,6 +143,30 @@ const APP_NAV_SOURCE source_table[] = |
| 154 | 143 | // {MEDIA_ARC,app_nav_rmt_convert_ARC} |
| 155 | 144 | }; |
| 156 | 145 | |
| 146 | +/******************************************************************************** | |
| 147 | +* poweron defalt souce * | |
| 148 | +*********************************************************************************/ | |
| 149 | + | |
| 150 | +U8 app_defalt_poweron_souce (void) | |
| 151 | +{ | |
| 152 | + if (sizeof(source_table) != 0) | |
| 153 | + { | |
| 154 | + return source_table[0].source_id; | |
| 155 | + } | |
| 156 | + else | |
| 157 | + { | |
| 158 | + return MEDIA_AUX; | |
| 159 | + } | |
| 160 | +} | |
| 161 | + | |
| 162 | +/******************************************************************************** | |
| 163 | +* This is an empty function, it doesn't do anything * | |
| 164 | +*********************************************************************************/ | |
| 165 | +void source_entry_null(void) | |
| 166 | +{ | |
| 167 | + | |
| 168 | +} | |
| 169 | + | |
| 157 | 170 | /**************************************************************************************** |
| 158 | 171 | * from current source to get next souce * |
| 159 | 172 | *****************************************************************************************/ |
| ... | ... | @@ -161,28 +174,37 @@ void* app_get_next_source_entry (U8 curr_source_id) |
| 161 | 174 | { |
| 162 | 175 | void *srouce_entry; |
| 163 | 176 | int i; |
| 164 | - for (i=0;i<sizeof(source_table)/sizeof(APP_NAV_SOURCE);i++) | |
| 177 | + U16 source_count = sizeof(source_table)/sizeof(APP_NAV_SOURCE); | |
| 178 | + | |
| 179 | + if (source_count) | |
| 165 | 180 | { |
| 166 | - if (curr_source_id == source_table[i].source_id) | |
| 181 | + for (i=0;i<source_count;i++) | |
| 167 | 182 | { |
| 168 | - break; | |
| 183 | + if (curr_source_id == source_table[i].source_id) | |
| 184 | + { | |
| 185 | + break; | |
| 186 | + } | |
| 169 | 187 | } |
| 170 | - } | |
| 171 | 188 | |
| 172 | - if (i == sizeof(source_table)/sizeof(APP_NAV_SOURCE)-1) | |
| 173 | - { | |
| 174 | - srouce_entry = source_table[0].source_entry; | |
| 175 | - } | |
| 176 | - else if (i < sizeof(source_table)/sizeof(APP_NAV_SOURCE)-1) | |
| 177 | - { | |
| 178 | - srouce_entry = source_table[i+1].source_entry; | |
| 179 | - } | |
| 189 | + if (i != source_count) | |
| 190 | + { | |
| 191 | + i++;//next source | |
| 192 | + i %= source_count; | |
| 193 | + srouce_entry = source_table[i].source_entry; | |
| 194 | + } | |
| 195 | + else | |
| 196 | + { | |
| 197 | + srouce_entry = source_table[0].source_entry; | |
| 198 | + DBG_Printf("err:current source id:%d is not in source table! return default source id\r\n",curr_source_id); | |
| 199 | + } | |
| 200 | + | |
| 201 | + return srouce_entry; | |
| 202 | + } | |
| 180 | 203 | else |
| 181 | 204 | { |
| 182 | - srouce_entry = source_table[0].source_entry; | |
| 183 | - DBG_Printf("err:current source:%d is not in source table!\r\n",curr_source_id); | |
| 205 | + DBG_Printf("source table is null\r\n"); | |
| 206 | + return source_entry_null; | |
| 184 | 207 | } |
| 185 | - return srouce_entry; | |
| 186 | 208 | } |
| 187 | 209 | |
| 188 | 210 | /**************************************************************************************** |
| ... | ... | @@ -192,24 +214,35 @@ void* app_get_cur_source_entry (U8 curr_source_id) |
| 192 | 214 | { |
| 193 | 215 | void *srouce_entry; |
| 194 | 216 | int i; |
| 195 | - for (i=0;i<sizeof(source_table)/sizeof(APP_NAV_SOURCE);i++) | |
| 217 | + U16 source_count = sizeof(source_table)/sizeof(APP_NAV_SOURCE); | |
| 218 | + | |
| 219 | + if (source_count) | |
| 196 | 220 | { |
| 197 | - if (curr_source_id == source_table[i].source_id) | |
| 221 | + for (i=0;i<source_count;i++) | |
| 198 | 222 | { |
| 199 | - break; | |
| 223 | + if (curr_source_id == source_table[i].source_id) | |
| 224 | + { | |
| 225 | + break; | |
| 226 | + } | |
| 200 | 227 | } |
| 201 | - } | |
| 202 | 228 | |
| 203 | - if (i <= sizeof(source_table)/sizeof(APP_NAV_SOURCE)-1) | |
| 204 | - { | |
| 205 | - srouce_entry = source_table[i].source_entry; | |
| 206 | - } | |
| 229 | + if (i != source_count) | |
| 230 | + { | |
| 231 | + srouce_entry = source_table[i].source_entry; | |
| 232 | + } | |
| 233 | + else | |
| 234 | + { | |
| 235 | + srouce_entry = source_table[0].source_entry; | |
| 236 | + DBG_Printf("err:current source id:%d is not in source table! return default source id\r\n",curr_source_id); | |
| 237 | + } | |
| 238 | + | |
| 239 | + return srouce_entry; | |
| 240 | + } | |
| 207 | 241 | else |
| 208 | 242 | { |
| 209 | - srouce_entry = source_table[0].source_entry; | |
| 210 | - DBG_Printf("err:current source:%d is not in source table!\r\n",curr_source_id); | |
| 243 | + DBG_Printf("source table is null\r\n"); | |
| 244 | + return app_nav_rmt_convert_aux; | |
| 211 | 245 | } |
| 212 | - return srouce_entry; | |
| 213 | 246 | } |
| 214 | 247 | |
| 215 | 248 | void app_nav_media_convert(void) |
| ... | ... | @@ -384,11 +417,13 @@ void app_nav_power_on(void) |
| 384 | 417 | #if 1 |
| 385 | 418 | |
| 386 | 419 | void (*source_entry)(void); |
| 420 | + #ifdef OPTEK_LINK_ENABLE | |
| 387 | 421 | if ((app_main_data.share_link_role == SL_ROLE_SLAVE) || (app_main_data.share_link_role == SL_ROLE_BT)) |
| 388 | 422 | { |
| 389 | 423 | source_entry = app_nav_rmt_convert_bt_hci; |
| 390 | 424 | } |
| 391 | 425 | else |
| 426 | + #endif | |
| 392 | 427 | { |
| 393 | 428 | source_entry = app_get_cur_source_entry (app_main_data.media); |
| 394 | 429 | } | ... | ... |
Please
register
or
login
to post a comment