修复拔插SD卡后回放读取SD卡文件异常
This commit is contained in:
		
							parent
							
								
									eda5bf1933
								
							
						
					
					
						commit
						ad888c0db2
					
				| 
						 | 
				
			
			@ -326,11 +326,6 @@ SF_ST_MMC_DEV *SF_StrgCheckWorkableDev(void)
 | 
			
		|||
        }
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	for(int i = 0; i < 2; i++)
 | 
			
		||||
	{
 | 
			
		||||
		sf_mmc_dev[i]->dev_type = workable_dev;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if(workable_dev == MMC_DEV_NO)
 | 
			
		||||
	{
 | 
			
		||||
		//MLOGD("Strg Check, No dev can use\n");
 | 
			
		||||
| 
						 | 
				
			
			@ -338,13 +333,13 @@ SF_ST_MMC_DEV *SF_StrgCheckWorkableDev(void)
 | 
			
		|||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		sf_mmc_dev[workable_dev]->dev_type = workable_dev;
 | 
			
		||||
		//MLOGD("Strg Check, workable_dev = %d\n", workable_dev);
 | 
			
		||||
		SF_SetMMCDev(sf_mmc_dev[workable_dev]);
 | 
			
		||||
		return sf_mmc_dev[workable_dev];
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if 1
 | 
			
		||||
static int sfStrgOnActionSendCurrentDev(SF_ST_MMC_DEV *pMMCDev)
 | 
			
		||||
{
 | 
			
		||||
	SF_MESSAGE_BUF_S stMessageBuf = {0};
 | 
			
		||||
| 
						 | 
				
			
			@ -356,7 +351,6 @@ static int sfStrgOnActionSendCurrentDev(SF_ST_MMC_DEV *pMMCDev)
 | 
			
		|||
	MLOGD("sf sys strg update current dev!\n");
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static void* mmc_monitoring_thread(void *arg)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -807,6 +807,48 @@ INT32 System_OnStrgSetActDrive(VControl *pCtrl, UINT32 paramNum, UINT32 *paramAr
 | 
			
		|||
	return NVTEVT_CONSUME;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int search_str_in_file(char *path, char *str)
 | 
			
		||||
{
 | 
			
		||||
    FILE *fp = NULL;
 | 
			
		||||
    UINT32 u32ize = 0;
 | 
			
		||||
    int found = 0;
 | 
			
		||||
    char *pStrSrc = NULL;
 | 
			
		||||
 | 
			
		||||
    fp = fopen(path, "r");
 | 
			
		||||
    if (fp) {
 | 
			
		||||
        fseek(fp, 0, SEEK_END);
 | 
			
		||||
        u32ize = ftell(fp); // take file size
 | 
			
		||||
        fseek(fp, 0, SEEK_SET); // move to position zero
 | 
			
		||||
        pStrSrc = (char *)malloc(u32ize * sizeof(char));
 | 
			
		||||
 | 
			
		||||
        if (pStrSrc) {
 | 
			
		||||
            fread(pStrSrc, 1, u32ize, fp);
 | 
			
		||||
            if (strstr(pStrSrc, str)) {
 | 
			
		||||
                found = 1;
 | 
			
		||||
            }
 | 
			
		||||
            free(pStrSrc);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        fclose(fp);
 | 
			
		||||
        fp = NULL;
 | 
			
		||||
        pStrSrc = NULL;
 | 
			
		||||
        u32ize = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return found;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int System_check_mmcblk0p1(void)
 | 
			
		||||
{
 | 
			
		||||
    SysMain_system("ls /dev/mmcblk0p1 > /tmp/lsdev.txt");
 | 
			
		||||
    vos_util_delay_ms(100);
 | 
			
		||||
    if (search_str_in_file("/tmp/lsdev.txt", "/dev/mmcblk0p1")) {
 | 
			
		||||
        return 1;
 | 
			
		||||
    } else {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
INT32 System_OnStrgInsert(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray)
 | 
			
		||||
{
 | 
			
		||||
	UINT32 strg_id = paramArray[0];
 | 
			
		||||
| 
						 | 
				
			
			@ -853,6 +895,31 @@ INT32 System_OnStrgInsert(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray)
 | 
			
		|||
    //SysMain_system("df"); //only for debug, the "/mnt/sd" path must be existed.
 | 
			
		||||
    #endif
 | 
			
		||||
 | 
			
		||||
	/* wait mmcblk */
 | 
			
		||||
    if(strg_id == STRG_ID_SD){
 | 
			
		||||
 | 
			
		||||
        UINT32 count = 0 , delay = 50, timeout = 60;
 | 
			
		||||
 | 
			
		||||
        while(count++ < timeout)
 | 
			
		||||
        {
 | 
			
		||||
            if (System_check_mmcblk0p1()){
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            else{
 | 
			
		||||
                vos_util_delay_ms(delay);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if(System_check_mmcblk0p1()){
 | 
			
		||||
            /* hotplug */
 | 
			
		||||
            if(count != 1)
 | 
			
		||||
                vos_util_delay_ms(50);
 | 
			
		||||
        }
 | 
			
		||||
        else{
 | 
			
		||||
            DBG_ERR("mmcblk0p1 not found!\n");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	if(strg_id == STRG_ID_SD){
 | 
			
		||||
		DX_HANDLE pStrgDev = (DX_HANDLE)sdio_getStorageObject(STRG_OBJ_FAT1);
 | 
			
		||||
		if (GxStrg_OpenDevice(strg_id, pStrgDev) != TRUE) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -712,9 +712,9 @@ static SINT32 sf_app_process_cmd_SD(SF_MESSAGE_BUF_S *pMessageBuf)
 | 
			
		|||
	{
 | 
			
		||||
		sfStrgDevSdHandler(pMessageBuf->arg1, pMessageBuf->arg2, pMessageBuf->arg3);
 | 
			
		||||
	}
 | 
			
		||||
	//else if(pMessageBuf->arg2 == MMC_DEV_EMMC)
 | 
			
		||||
	else if(pMessageBuf->arg2 == MMC_DEV_EMMC)
 | 
			
		||||
	{
 | 
			
		||||
		//sfStrgDevEmmcHandler(pMessageBuf->arg1, pMessageBuf->arg2, pMessageBuf->arg3);
 | 
			
		||||
		sfStrgDevEmmcHandler(pMessageBuf->arg1, pMessageBuf->arg2, pMessageBuf->arg3);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	switch(pMessageBuf->arg1)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user