char num = 0;
char input_string[128] = "";
char *tok = NULL;
+ char *ptr = NULL;
int tonetime=0;
double volume=1.0;
int volume_type = -1;
fflush(stdin);
g_print("enter number(0~H exit:q), volume type(0~7), volume(0.0~1.0), time(ms), enable_session(0:unable , 1:enable):\t ");
if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- tok = strtok(input_string, " ");
+ tok = strtok_r(input_string, " ", &ptr);
if(!tok) continue;
if(tok[0] == 'q') {
break;
else if(num == '{') { tone =MM_SOUND_TONE_LOW_FRE; }
else if(num == '}') { tone =MM_SOUND_TONE_MED_FRE; }
else if(num == '~') { tone =MM_SOUND_TONE_HIGH_FRE; }
- tok = strtok(NULL, " ");
+ tok = strtok_r(NULL, " ", &ptr);
if(tok) volume_type = (double)atoi(tok);
- tok = strtok(NULL, " ");
+ tok = strtok_r(NULL, " ", &ptr);
if(tok) volume = (double)atof(tok);
- tok = strtok(NULL, " ");
+ tok = strtok_r(NULL, " ", &ptr);
if(tok)
{
tonetime = atoi(tok);
tonetime = MIN_TONE_PLAY_TIME;
}
- tok = strtok(NULL, " ");
+ tok = strtok_r(NULL, " ", &ptr);
if(tok) enable_session = (bool)atof(tok);
debug_log("volume type: %d\t volume is %f\t tonetime: %d\t enable_session %d ", volume_type, volume, tonetime, enable_session);
char num = 0;
char input_string[128] = "";
char *tok = NULL;
+ char *ptr = NULL;
char *stream_type = NULL;
int tonetime=0;
double volume=1.0;
fflush(stdin);
g_print("enter number(0~H exit:q), stream type(media, system, ...), volume(0.0~1.0), time(ms):\t ");
if (fgets(input_string, sizeof(input_string)-1, stdin)) {
- tok = strtok(input_string, " ");
+ tok = strtok_r(input_string, " ", &ptr);
if(!tok) continue;
if(tok[0] == 'q') {
break;
else if(num == '}') { tone =MM_SOUND_TONE_MED_FRE; }
else if(num == '~') { tone =MM_SOUND_TONE_HIGH_FRE; }
- stream_type = strtok(NULL, " ");
+ stream_type = strtok_r(NULL, " ", &ptr);
- tok = strtok(NULL, " ");
+ tok = strtok_r(NULL, " ", &ptr);
if(tok) volume = (double)atof(tok);
- tok = strtok(NULL, " ");
+ tok = strtok_r(NULL, " ", &ptr);
if(tok)
{
tonetime = atoi(tok);
else if (strncmp (cmd, "b",1) == 0)
{
DIR *basedir;
- struct dirent *entry;
+ struct dirent *entry = NULL;
+ struct dirent *prev_entry = NULL;
+ int entry_len;
+ int ret;
struct stat file_stat;
char fullpath[MAX_PATH_LEN]="";
struct timespec start_time = {0,};
basedir = opendir(g_dir_name);
if(basedir != NULL)
{
- while( (entry = readdir(basedir)) != NULL)
+ entry_len = offsetof(struct dirent, d_name) + fpathconf(dirfd(basedir), MAX_STRING_LEN) + 1;
+ prev_entry = malloc(entry_len);
+
+ while (1)
{
- int playfail =0;
+ int playfail = 0;
int mywait = 0;
+
+ ret = readdir_r(basedir, prev_entry, &entry);
+ if (ret == 0)
+ {
+ debug_error("error on readdir_r(%s)", basedir);
+ break;
+ }
+ if (entry == NULL)
+ break;
+
if(entry->d_name[0] == '.')
continue;
memset(fullpath, '\0' ,sizeof(fullpath));
}
debug_log("goto next file");
}
+ free(prev_entry);
closedir(basedir);
}
else