int cd_is_audio(int track) { if (!get_audio_info()) return -1; set_track(track); return (cdrom_data.track_type == 64) ? 0 : 1; }
int cd_get_tracks(int *first, int *last) { if (!get_audio_info()) return -1; if (first) *first = cdrom_data.low_audio; if (last) *last = cdrom_data.high_audio; return 0; }
int cd_play_range(int start, int end) { unsigned long startpos, endpos; if ((!get_audio_info()) || (MIN(start, end) < cdrom_data.low_audio) || (MAX(start, end) > cdrom_data.high_audio)) return -1; startpos = start_position(start); endpos = end_position(end); return (!play(startpos, endpos)) ? -1 : 0; }
int cd_play_from(int track) { unsigned long startpos, endpos; if (!get_audio_info() || (track < cdrom_data.low_audio) || (track > cdrom_data.high_audio)) return -1; startpos = start_position(track); endpos = cdrom_data.endofdisk; return (!play(startpos, endpos)) ? -1 : 0; }
static void intitialize_audio_encoder(struct obs_encoder *encoder) { struct audio_convert_info info; get_audio_info(encoder, &info); encoder->samplerate = info.samples_per_sec; encoder->planes = get_audio_planes(info.format, info.speakers); encoder->blocksize = get_audio_size(info.format, info.speakers, 1); encoder->framesize = encoder->info.frame_size(encoder->context.data); encoder->framesize_bytes = encoder->blocksize * encoder->framesize; reset_audio_buffers(encoder); }
int cd_init(void) { inregs.h.ah = 0x15; inregs.h.al = 0x00; inregs.x.bx = 0; int86 (0x2f, &inregs, &outregs); if (outregs.x.bx == 0) return -1; cdrom_data.drives = outregs.x.bx; cdrom_data.first_drive = outregs.x.cx; get_audio_info(); paused = 0; return 0; }
int cd_current_track(void) { unsigned long loc; short i; if (!audio_busy() || !get_audio_info()) return 0; loc = head_position(); for (i = cdrom_data.high_audio; i > cdrom_data.low_audio; i--) { set_track(i); if (loc > cdrom_data.track_position) return i; } return cdrom_data.low_audio; }
static void add_connection(struct obs_encoder *encoder) { if (encoder->info.type == OBS_ENCODER_AUDIO) { struct audio_convert_info audio_info = {0}; get_audio_info(encoder, &audio_info); audio_output_connect(encoder->media, encoder->mixer_idx, &audio_info, receive_audio, encoder); } else { struct video_scale_info info = {0}; get_video_info(encoder, &info); video_output_connect(encoder->media, &info, receive_video, encoder); } encoder->active = true; }
void audioSortDir(char *targetDir) { int cnt = 0; char link_source[PATH_MAX], link_target[PATH_MAX], *file_target = NULL; struct audio info; DIR *ourDir; if (*targetDir != '/') { d_log("audioSortDir: not an absolute path. (%s)\n", targetDir); return; } /* Look at something like that to verify that a release is complete? * (And tell user to run rescan if not) * char *sfv_data = NULL; * * sfv_data = ng_realloc2(sfv_data, n, 1, 1, 1); * sprintf(sfv_data, storage "/%s/sfvdata", targetDir); * * readsfv(sfv_data, &g.v, 0); */ cnt = extractDirname(link_target, targetDir); strlcpy(link_source, targetDir, PATH_MAX); if (chdir(targetDir) == -1) { d_log("audioSortDir: Failed to chdir() to %s: %s\n", targetDir, strerror(errno)); } if ((ourDir = opendir(targetDir)) == NULL) { printf("Error: Failed to open dir \"%s\" : %s\n", targetDir, strerror(errno)); return; } file_target = findfileextfromlist(ourDir, audio_types); get_audio_info(file_target, &info); audioSort(&info, link_source, link_target); closedir(ourDir); }
int audiodsp_start(void) { struct audiodsp_priv *priv=audiodsp_privdata(); struct audiodsp_microcode *pmcode; struct audio_info *audio_info; int ret,i; priv->frame_format.valid=0; priv->decode_error_count=0; priv->last_valid_pts=0; priv->out_len_after_last_valid_pts = 0; priv->decode_fatal_err = 0; priv->first_lookup_over = 0; pmcode=audiodsp_find_supoort_mcode(priv,priv->stream_fmt); if(pmcode==NULL) { DSP_PRNT("have not find a valid mcode for fmt(0x%x)\n",priv->stream_fmt); return -1; } stop_audiodsp_monitor(priv); dsp_stop(priv); ret=dsp_start(priv,pmcode); if(ret==0){ start_audiodsp_monitor(priv); #ifdef CONFIG_AM_VDEC_REAL if((pmcode->fmt == MCODEC_FMT_COOK) || (pmcode->fmt == MCODEC_FMT_RAAC) || (pmcode->fmt == MCODEC_FMT_AMR) || (pmcode->fmt == MCODEC_FMT_WMA) || (pmcode->fmt == MCODEC_FMT_ADPCM)|| (pmcode->fmt == MCODEC_FMT_PCM) || (pmcode->fmt == MCODEC_FMT_WMAPRO)|| (pmcode->fmt == MCODEC_FMT_ALAC)|| (pmcode->fmt & MCODEC_FMT_AC3) || (pmcode->fmt & MCODEC_FMT_EAC3) || (pmcode->fmt == MCODEC_FMT_APE) || (pmcode->fmt == MCODEC_FMT_FLAC)) { DSP_PRNT("dsp send audio info\n"); for(i = 0; i< 2000;i++){ if(DSP_RD(DSP_AUDIOINFO_STATUS) == DSP_AUDIOINFO_READY)//maybe at audiodsp side,INT not enabled yet,so wait a while break; msleep(1); } if(i == 2000) DSP_PRNT("audiodsp not ready for info \n"); DSP_WD(DSP_AUDIOINFO_STATUS,0); audio_info = get_audio_info(); DSP_PRNT("kernel sent info first 4 byte[0x%x],[0x%x],[0x%x],[0x%x]\n\t",audio_info->extradata[0],\ audio_info->extradata[1],audio_info->extradata[2],audio_info->extradata[3]); DSP_WD(DSP_GET_EXTRA_INFO_FINISH, 0); while(1){ dsp_mailbox_send(priv, 1, M2B_IRQ4_AUDIO_INFO, 0, (const char*)audio_info, sizeof(struct audio_info)); msleep(100); if(DSP_RD(DSP_GET_EXTRA_INFO_FINISH) == 0x12345678) break; } } #endif } return ret; }
__s32 audio_config(void) { __s32 i; __inf("audio_config, sample_rate:%d\n", audio_info.sample_rate); HDMI_WUINT32(0x040,0x00000000); HDMI_WUINT32(0x040,0x40000000); while(HDMI_RUINT32(0x040) != 0); HDMI_WUINT32(0x040,0x40000000); while(HDMI_RUINT32(0x040) != 0); if(!audio_info.audio_en) { return 0; } i = get_audio_info(audio_info.sample_rate); if(i == -1) { return 0; } if(audio_info.channel_num == 1) { HDMI_WUINT32(0x044,0x00000000); //audio fifo rst and select ddma, 2 ch 16bit pcm HDMI_WUINT32(0x048,0x00000000); //ddma,pcm layout0 1ch HDMI_WUINT32(0x04c,0x76543200); HDMI_WUINT32(0x0A0,0x710a0184); //audio infoframe head HDMI_WUINT32(0x0A4,0x00000000); //CA = 0X1F HDMI_WUINT32(0x0A8,0x00000000); HDMI_WUINT32(0x0Ac,0x00000000); }else if(audio_info.channel_num == 2) { HDMI_WUINT32(0x044,0x00000000); //audio fifo rst and select ddma, 2 ch 16bit pcm if(audio_info.data_raw == 0) { HDMI_WUINT32(0x048,0x00000001); //ddma,pcm layout0 2ch } else { HDMI_WUINT32(0x048,0x01000001); //ddma,raw layout0 2ch } HDMI_WUINT32(0x04c,0x76543210); HDMI_WUINT32(0x0A0,0x710a0184); //audio infoframe head HDMI_WUINT32(0x0A4,0x00000000); //CA = 0X1F HDMI_WUINT32(0x0A8,0x00000000); HDMI_WUINT32(0x0Ac,0x00000000); }else if(audio_info.channel_num == 8) { HDMI_WUINT32(0x044,0x00000000); //audio fifo rst and select ddma, 2 ch 16bit pcm HDMI_WUINT32(0x048,0x0000000f); //ddma,pcm layout1 8ch HDMI_WUINT32(0x04c,0x76543210); HDMI_WUINT32(0x0A0,0x520a0184); //audio infoframe head HDMI_WUINT32(0x0A4,0x1F000000); //CA = 0X1F HDMI_WUINT32(0x0A8,0x00000000); HDMI_WUINT32(0x0Ac,0x00000000); }else { __wrn("unkonwn num_ch:%d\n", audio_info.channel_num); } HDMI_WUINT32(0x050,audio_info.CTS ); //CTS and N HDMI_WUINT32(0x054,audio_info.ACR_N ); HDMI_WUINT32(0x058,audio_info.CH_STATUS0 ); HDMI_WUINT32(0x05c,audio_info.CH_STATUS1 ); HDMI_WUINT32(0x040,0x80000000); HDMI_WUINT32(0x004,0x80000000); //for audio test #if 0 //dedicated dma setting aw1623 env sys_put_wvalue(0xf1c023a4,0x40c00000); //ddma ch5 seting from addr =0x40c00000 sys_put_wvalue(0xf1c023a8,0x00000000); //des =0 sys_put_wvalue(0xf1c023ac,0x01f00000); //byte to trans sys_put_wvalue(0xf1c023b8,(31<<24) +(7<<16) + (31<<8) +(7<<0)); //data block and wait cycle sys_put_wvalue(0xf1c023a0,0xa4b80481); //from src0 to des1,continous mode #endif return 0; }
int main(int argc, char *argv[]) { int n, l, complete_type = 0, not_allowed = 0, argv_mode = 0; #ifdef USING_GLFTPD int gnum = 0, unum = 0; char myflags[20]; #endif char *ext, exec[4096], *complete_bar = 0, *inc_point[2]; unsigned int crc; struct stat fileinfo; uid_t f_uid; gid_t f_gid; double temp_time = 0; DIR *dir, *parent; struct dirent *dp; long loc; time_t timenow; #if (test_for_password || extract_nfo || zip_clean) off_t tempstream; #endif short rescan_quick = rescan_default_to_quick; char one_name[NAME_MAX]; char *temp_p = NULL; int chdir_allowed = 0, argnum = 0; GLOBAL g; #if (enable_rescan_script) char target[PATH_MAX+NAME_MAX]; #endif #if ( program_uid > 0 ) setegid(program_gid); seteuid(program_uid); #endif umask(0666 & 000); d_log("rescan: PZS-NG (rescan v2) %s debug log.\n", ng_version); d_log("rescan: Rescan executed by: (uid/gid) %d/%d\n", geteuid(), getegid()); #ifdef _ALT_MAX d_log("rescan: PATH_MAX not found - using predefined settings! Please report to the devs!\n"); #endif d_log("rescan: Allocating memory for variables\n"); g.ui = ng_realloc2(g.ui, sizeof(*g.ui) * 30, 1, 1, 1); g.gi = ng_realloc2(g.gi, sizeof(*g.gi) * 30, 1, 1, 1); bzero(one_name, NAME_MAX); #ifdef USING_GLFTPD if (getenv("FLAGS")) { strlcpy(myflags, getenv("FLAGS"), sizeof(myflags)); n = strlen(myflags); while (n > 0) { --n; l = strlen(rescan_chdir_flags); while(l > 0) { --l; if (myflags[n] == rescan_chdir_flags[l]) chdir_allowed = 1; } } } if (!geteuid()) chdir_allowed = 1; #endif /* With glftpd we can use env vars, rest of the world: commandline. */ #ifndef USING_GLFTPD if (argc < 7) { print_syntax(chdir_allowed); ng_free(g.ui); ng_free(g.gi); return 0; } argnum = 6; if (chdir(argv[5]) != 0) { printf("Could not chdir to <cwd = '%s'>, ftpd agnostic mode: %s\n", argv[5], strerror(errno)); d_log("rescan: Could not chdir to <cwd = '%s'>, ftpd agnostic mode: %s\n", argv[5], strerror(errno)); ng_free(g.ui); ng_free(g.gi); return 1; } #else argnum = 1; #endif while ((argnum < argc) && argc > 1) { if (!strncasecmp(argv[argnum], "--quick", 7)) rescan_quick = TRUE; else if (!strncasecmp(argv[argnum], "--normal", 8)) rescan_quick = FALSE; else if (!strncasecmp(argv[argnum], "--dir=", 6) && (strlen(argv[argnum]) > 7) && chdir_allowed) { temp_p = argv[argnum] + 6; if ((!matchpath(nocheck_dirs, temp_p)) && (matchpath(zip_dirs, temp_p) || matchpath(sfv_dirs, temp_p)) && !matchpath(group_dirs, temp_p)) { if (chdir(temp_p)) { d_log("rescan: Failed to chdir() to %s : %s\n", temp_p, strerror(errno)); not_allowed = 1; } } else { printf("Not allowed to chdir() to %s\n", temp_p); ng_free(g.ui); ng_free(g.gi); return 1; } printf("PZS-NG Rescan %s: Rescanning %s\n", ng_version, temp_p); argv_mode = 1; } else if (!strncasecmp(argv[argnum], "--chroot=", 9) && (strlen(argv[argnum]) > 10) && chdir_allowed) { if (temp_p == NULL) { temp_p = argv[argnum] + 9; if (chroot(temp_p) == -1) { d_log("rescan: Failed to chroot() to %s : %s\n", temp_p, strerror(errno)); not_allowed = 1; } } else { temp_p = argv[argnum] + 9; printf("Not allowed to chroot() to %s\n", temp_p); ng_free(g.ui); ng_free(g.gi); return 1; } printf("PZS-NG Rescan %s: Chroot'ing to %s\n", ng_version, temp_p); argv_mode = 1; } else if (!strncasecmp(argv[argnum], "--help", 6) || !strncasecmp(argv[argnum], "/?", 2) || !strncasecmp(argv[argnum], "--?", 3)) { print_syntax(chdir_allowed); ng_free(g.ui); ng_free(g.gi); return 0; } else { strlcpy(one_name, argv[argnum], sizeof(one_name)); rescan_quick = FALSE; printf("PZS-NG Rescan %s: Rescanning in FILE mode\n", ng_version); if (one_name[strlen(one_name) - 1] == '*') { one_name[strlen(one_name) - 1] = '\0'; } else if (!fileexists(one_name)) { d_log("PZS-NG Rescan: No file named '%s' exists.\n", one_name); one_name[0] = '\0'; not_allowed = 1; } argv_mode = 1; } argnum++; } if (one_name[0] == '\0') { if (rescan_quick == TRUE) { printf("PZS-NG Rescan %s: Rescanning in QUICK mode.\n", ng_version); } else { printf("PZS-NG Rescan %s: Rescanning in NORMAL mode.\n", ng_version); } } printf("PZS-NG Rescan %s: Use --help for options.\n\n", ng_version); if (not_allowed) { ng_free(g.ui); ng_free(g.gi); return 1; } if (!getcwd(g.l.path, PATH_MAX)) { d_log("rescan: getcwd() failed: %s\n", strerror(errno)); } if (subcomp(g.l.path, g.l.basepath) && (g.l.basepath[0] == '\0')) strlcpy(g.l.basepath, g.l.path, sizeof(g.l.basepath)); if (strncmp(g.l.path, g.l.basepath, PATH_MAX)) d_log("rescan: We are in subdir of %s\n", g.l.basepath); strlcpy(g.v.misc.current_path, g.l.path, sizeof(g.v.misc.current_path)); strlcpy(g.v.misc.basepath, g.l.basepath, sizeof(g.v.misc.basepath)); if ((matchpath(nocheck_dirs, g.l.path) && !rescan_nocheck_dirs_allowed) || (matchpath(group_dirs, g.l.path) && argv_mode) || (!matchpath(nocheck_dirs, g.l.path) && !matchpath(zip_dirs, g.l.path) && !matchpath(sfv_dirs, g.l.path) && !matchpath(group_dirs, g.l.path)) || insampledir(g.l.path)) { d_log("rescan: Dir matched with nocheck_dirs/sample_list, or is not in the zip/sfv/group-dirs.\n"); d_log("rescan: Freeing memory, and exiting.\n"); printf("Notice: Unable to rescan this dir - check config.\n\n"); ng_free(g.ui); ng_free(g.gi); return 0; } g.v.misc.slowest_user[0] = ULONG_MAX; bzero(&g.v.total, sizeof(struct race_total)); g.v.misc.fastest_user[0] = 0; g.v.misc.release_type = RTYPE_NULL; g.v.misc.write_log = 0; #ifdef USING_GLFTPD if (getenv("SECTION") == NULL) { sprintf(g.v.sectionname, "DEFAULT"); } else { snprintf(g.v.sectionname, sizeof(g.v.sectionname), "%s", getenv("SECTION")); } #else snprintf(g.v.sectionname, sizeof(g.v.sectionname), argv[4]); #endif g.l.length_path = (int)strlen(g.l.path); g.l.length_zipdatadir = sizeof(storage); n = g.l.length_path + g.l.length_zipdatadir + 11; g.l.race = ng_realloc2(g.l.race, n, 1, 1, 1); g.l.sfv = ng_realloc2(g.l.sfv, n - 1, 1, 1, 1); g.l.sfvbackup = ng_realloc2(g.l.sfvbackup, n + 1, 1, 1, 1); g.l.leader = ng_realloc2(g.l.leader, n - 2, 1, 1, 1); g.l.sfv_incomplete = 0; getrelname(&g); #ifdef USING_GLFTPD gnum = buffer_groups(GROUPFILE, 0); unum = buffer_users(PASSWDFILE, 0); #endif sprintf(g.l.sfv, storage "/%s/sfvdata", g.l.path); sprintf(g.l.sfvbackup, storage "/%s/sfvbackup", g.l.path); sprintf(g.l.leader, storage "/%s/leader", g.l.path); sprintf(g.l.race, storage "/%s/racedata", g.l.path); d_log("rescan: Creating directory to store racedata in\n"); maketempdir(g.l.path); d_log("rescan: Locking release\n"); while (1) { if ((l = create_lock(&g.v, g.l.path, PROGTYPE_RESCAN, 3, 0))) { d_log("rescan: Failed to lock release.\n"); if (l == 1) { d_log("rescan: version mismatch. Exiting.\n"); printf("Error. You need to rm -fR ftp-data/pzs-ng/* before rescan will work.\n"); /* */ ng_free(g.ui); ng_free(g.gi); ng_free(g.l.sfv); ng_free(g.l.sfvbackup); ng_free(g.l.leader); ng_free(g.l.race); #ifdef USING_GLFTPD buffer_groups(GROUPFILE, gnum); buffer_users(PASSWDFILE, unum); #endif exit(EXIT_FAILURE); } if (l == PROGTYPE_POSTDEL) { n = (signed int)g.v.data_incrementor; d_log("rescan: Detected postdel running - sleeping for one second.\n"); if (!create_lock(&g.v, g.l.path, PROGTYPE_RESCAN, 0, g.v.data_queue)) break; usleep(1000000); if (!create_lock(&g.v, g.l.path, PROGTYPE_RESCAN, 0, g.v.data_queue)) break; if ( n == (signed int)g.v.data_incrementor) { d_log("rescan: Failed to get lock. Forcing unlock.\n"); if (create_lock(&g.v, g.l.path, PROGTYPE_RESCAN, 2, g.v.data_queue)) { d_log("rescan: Failed to force a lock.\n"); d_log("rescan: Exiting with error.\n"); ng_free(g.ui); ng_free(g.gi); ng_free(g.l.sfv); ng_free(g.l.sfvbackup); ng_free(g.l.leader); ng_free(g.l.race); #ifdef USING_GLFTPD buffer_groups(GROUPFILE, gnum); buffer_users(PASSWDFILE, unum); #endif exit(EXIT_FAILURE); } break; } } else { for (l = 0; l <= max_seconds_wait_for_lock * 10; ++l) { d_log("rescan: sleeping for .1 second before trying to get a lock (queue: %d).\n", g.v.data_queue); usleep(100000); if (!create_lock(&g.v, g.l.path, PROGTYPE_RESCAN, 0, g.v.data_queue)) break; } if (l >= max_seconds_wait_for_lock * 10) { d_log("rescan: Failed to get lock. Will not force unlock.\n"); ng_free(g.ui); ng_free(g.gi); ng_free(g.l.sfv); ng_free(g.l.sfvbackup); ng_free(g.l.leader); ng_free(g.l.race); #ifdef USING_GLFTPD buffer_groups(GROUPFILE, gnum); buffer_users(PASSWDFILE, unum); #endif exit(EXIT_FAILURE); } } } usleep(10000); if (update_lock(&g.v, 1, 0) != -1) break; } move_progress_bar(1, &g.v, g.ui, g.gi); if (g.l.incomplete) unlink(g.l.incomplete); if (del_completebar) removecomplete(); dir = opendir("."); parent = opendir(".."); if (!((rescan_quick && findfileext(dir, ".sfv")) || *one_name)) { if (g.l.sfv) unlink(g.l.sfv); if (g.l.race) unlink(g.l.race); } printf("Rescanning files...\n"); if (findfileext(dir, ".zip")) { if (!fileexists(unzip_bin)) { printf("rescan: ERROR! Not able to check zip-files - %s does not exist!\n", unzip_bin); closedir(dir); closedir(parent); ng_free(g.ui); ng_free(g.gi); ng_free(g.l.sfv); ng_free(g.l.sfvbackup); ng_free(g.l.leader); ng_free(g.l.race); #ifdef USING_GLFTPD buffer_groups(GROUPFILE, gnum); buffer_users(PASSWDFILE, unum); #endif remove_lock(&g.v); exit(EXIT_FAILURE); } else { crc = 0; rewinddir(dir); timenow = time(NULL); while ((dp = readdir(dir))) { ext = find_last_of(dp->d_name, "."); if (*ext == '.') ext++; if (!strcasecmp(ext, "zip")) { stat(dp->d_name, &fileinfo); f_uid = fileinfo.st_uid; f_gid = fileinfo.st_gid; if ((timenow == fileinfo.st_ctime) && (fileinfo.st_mode & 0111)) { d_log("rescan.c: Seems this file (%s) is in the process of being uploaded. Ignoring for now.\n", dp->d_name); continue; } #ifdef USING_GLFTPD strlcpy(g.v.user.name, get_u_name(f_uid), sizeof(g.v.user.name)); strlcpy(g.v.user.group, get_g_name(f_gid), sizeof(g.v.user.group)); #else strlcpy(g.v.user.name, argv[1], sizeof(g.v.user.name)); strlcpy(g.v.user.group, argv[2], sizeof(g.v.user.group)); #endif strlcpy(g.v.file.name, dp->d_name, sizeof(g.v.file.name)); g.v.file.speed = 2005 * 1024; g.v.file.size = fileinfo.st_size; g.v.total.start_time = 0; #if (test_for_password || extract_nfo) tempstream = telldir(dir); if ((!findfileextcount(dir, ".nfo") || findfileextcount(dir, ".zip")) && !mkdir(".unzipped", 0777)) snprintf(exec, sizeof(exec), "%s -qqjo \"%s\" -d .unzipped 2>.delme", unzip_bin, g.v.file.name); else snprintf(exec, sizeof(exec), "%s -qqt \"%s\" 2>.delme", unzip_bin, g.v.file.name); seekdir(dir, tempstream); #else snprintf(exec, sizeof(exec), "%s -qqt \"%s\" 2>.delme", unzip_bin, g.v.file.name); #endif if (system(exec) == 0 || (allow_error2_in_unzip == TRUE && errno < 3 )) { writerace(g.l.race, &g.v, crc, F_CHECKED); } else { writerace(g.l.race, &g.v, crc, F_BAD); if (g.v.file.name) unlink(g.v.file.name); removedir(".unzipped"); continue; } #if (test_for_password || extract_nfo || zip_clean) tempstream = telldir(dir); if ((!findfileextcount(dir, ".nfo") || findfileextcount(dir, ".zip")) && check_zipfile(".unzipped", g.v.file.name, findfileextcount(dir, ".nfo"))) { d_log("rescan: File %s is password protected.\n", g.v.file.name); writerace(g.l.race, &g.v, crc, F_BAD); if (g.v.file.name) unlink(g.v.file.name); seekdir(dir, tempstream); continue; } seekdir(dir, tempstream); #endif if (!fileexists("file_id.diz")) { snprintf(exec, sizeof(exec), "%s -qqjnCLL \"%s\" file_id.diz 2>.delme", unzip_bin, g.v.file.name); if (execute(exec) != 0) { d_log("rescan: No file_id.diz found (#%d): %s\n", errno, strerror(errno)); } else { if (fileexists("file_id.diz.bad")) { loc = findfile(dir, "file_id.diz.bad"); seekdir(dir, loc); dp = readdir(dir); unlink(dp->d_name); } if (chmod("file_id.diz", 0666)) d_log("rescan: Failed to chmod %s: %s\n", "file_id.diz", strerror(errno)); } } } } if (fileexists(".delme")) unlink(".delme"); g.v.total.files = read_diz(); if (!g.v.total.files) { g.v.total.files = 1; unlink("file_id.diz"); } g.v.total.files_missing = g.v.total.files; readrace(g.l.race, &g.v, g.ui, g.gi); sortstats(&g.v, g.ui, g.gi); if (g.v.total.files_missing < 0) { g.v.total.files -= g.v.total.files_missing; g.v.total.files_missing = 0; } buffer_progress_bar(&g.v); if (g.v.total.files_missing == 0) { complete(&g, complete_type); createstatusbar(convert(&g.v, g.ui, g.gi, zip_completebar)); #if (chmod_completebar) if (!matchpath(group_dirs, g.l.path)) { if (chmod_each(convert(&g.v, g.ui, g.gi, zip_completebar), 0222)) d_log("rescan: Failed to chmod a statusbar: %s\n", strerror(errno)); } #endif } else { if (!matchpath(group_dirs, g.l.path) || create_incomplete_links_in_group_dirs) { if (create_incomplete()) { d_log("rescan: create_incomplete() returned something\n"); } } move_progress_bar(0, &g.v, g.ui, g.gi); } if (g.l.nfo_incomplete) { if (findfileext(dir, ".nfo")) { d_log("rescan: Removing missing-nfo indicator (if any)\n"); remove_nfo_indicator(&g); } else if (matchpath(check_for_missing_nfo_dirs, g.l.path) && (!matchpath(group_dirs, g.l.path) || create_incomplete_links_in_group_dirs)) { if (!g.l.in_cd_dir) { d_log("rescan: Creating missing-nfo indicator %s.\n", g.l.nfo_incomplete); if (create_incomplete_nfo()) { d_log("rescan: create_incomplete_nfo() returned something\n"); } } else { if (findfileextparent(parent, ".nfo")) { d_log("rescan: Removing missing-nfo indicator (if any)\n"); remove_nfo_indicator(&g); } else { d_log("rescan: Creating missing-nfo indicator (base) %s.\n", g.l.nfo_incomplete); if (create_incomplete_nfo()) { d_log("rescan: create_incomplete_nfo() returned something\n"); } } } } } } } else if ((temp_p = findfileext(dir, ".sfv")) || (create_missing_sfv && file_count(dir))) { if (!temp_p && create_missing_sfv && file_count(dir)) { d_log("rescan: No sfv found - creating one.\n"); make_sfv(g.l.path); if (!(temp_p = findfileext(dir, ".sfv"))) { d_log("rescan: Freeing memory, removing lock and exiting.\n"); unlink(g.l.sfv); if (fileexists(g.l.sfvbackup)) unlink(g.l.sfvbackup); unlink(g.l.race); closedir(dir); closedir(parent); ng_free(g.ui); ng_free(g.gi); ng_free(g.l.sfv); ng_free(g.l.sfvbackup); ng_free(g.l.leader); ng_free(g.l.race); #ifdef USING_GLFTPD buffer_groups(GROUPFILE, gnum); buffer_users(PASSWDFILE, unum); #endif remove_lock(&g.v); return 0; } } #if ( create_missing_sfv_link == TRUE ) d_log("rescan: Removing missing-sfv indicator (if any)\n"); unlink(g.l.sfv_incomplete); #endif strlcpy(g.v.file.name, temp_p, sizeof(g.v.file.name)); maketempdir(g.l.path); stat(g.v.file.name, &fileinfo); if (copysfv(g.v.file.name, g.l.sfv, &g.v)) { printf("Found invalid entries in SFV - Exiting.\n"); while ((dp = readdir(dir))) { ext = find_last_of(dp->d_name, "-"); if (!strcasecmp(ext, "-missing")) unlink(dp->d_name); } d_log("rescan: Freeing memory, removing lock and exiting\n"); unlink(g.l.sfv); if (fileexists(g.l.sfvbackup)) unlink(g.l.sfvbackup); unlink(g.l.race); closedir(dir); closedir(parent); ng_free(g.ui); ng_free(g.gi); ng_free(g.l.sfv); ng_free(g.l.sfvbackup); ng_free(g.l.leader); ng_free(g.l.race); #ifdef USING_GLFTPD buffer_groups(GROUPFILE, gnum); buffer_users(PASSWDFILE, unum); #endif remove_lock(&g.v); return 0; } g.v.total.start_time = 0; rewinddir(dir); while ((dp = readdir(dir))) { if (*one_name && strncasecmp(one_name, dp->d_name, strlen(one_name))) continue; l = (int)strlen(dp->d_name); ext = find_last_of(dp->d_name, ".-"); if (*ext == '.') ext++; if (!update_lock(&g.v, 1, 0)) { d_log("rescan: Another process wants the lock - will comply and remove lock, then exit.\n"); closedir(dir); closedir(parent); ng_free(g.ui); ng_free(g.gi); ng_free(g.l.sfv); ng_free(g.l.sfvbackup); ng_free(g.l.leader); ng_free(g.l.race); #ifdef USING_GLFTPD buffer_groups(GROUPFILE, gnum); buffer_users(PASSWDFILE, unum); #endif remove_lock(&g.v); exit(EXIT_FAILURE); } if ( !strcomp(ignored_types, ext) && (!(strcomp(allowed_types, ext) && !matchpath(allowed_types_exemption_dirs, g.l.path))) && strcasecmp("sfv", ext) && strcasecmp("nfo", ext) && strcasecmp("bad", ext) && strcasecmp("-missing", ext) && strncmp(dp->d_name, ".", 1) ) { stat(dp->d_name, &fileinfo); if (S_ISDIR(fileinfo.st_mode)) continue; if (ignore_zero_sized_on_rescan && !fileinfo.st_size) continue; f_uid = fileinfo.st_uid; f_gid = fileinfo.st_gid; #ifdef USING_GLFTPD strlcpy(g.v.user.name, get_u_name(f_uid), sizeof(g.v.user.name)); strlcpy(g.v.user.group, get_g_name(f_gid), sizeof(g.v.user.group)); #else strlcpy(g.v.user.name, argv[1], sizeof(g.v.user.name)); strlcpy(g.v.user.group, argv[2], sizeof(g.v.user.group)); #endif strlcpy(g.v.file.name, dp->d_name, sizeof(g.v.file.name)); g.v.file.speed = 2005 * 1024; g.v.file.size = fileinfo.st_size; temp_time = fileinfo.st_mtime; if (g.v.total.start_time == 0) g.v.total.start_time = temp_time; else g.v.total.start_time = (g.v.total.start_time < temp_time ? g.v.total.start_time : temp_time); g.v.total.stop_time = (temp_time > g.v.total.stop_time ? temp_time : g.v.total.stop_time); /* Hide users in group_dirs */ if (matchpath(group_dirs, g.l.path) && (hide_group_uploaders == TRUE)) { d_log("rescan: Hiding user in group-dir:\n"); if ((int)strlen(hide_gname) > 0) { snprintf(g.v.user.group, sizeof(g.v.user.group), "%s", hide_gname); d_log("rescan: Changing groupname\n"); } if ((int)strlen(hide_uname) > 0) { snprintf(g.v.user.name, sizeof(g.v.user.name), "%s", hide_uname); d_log("rescan: Changing username\n"); } #if (show_users_in_group_dirs == FALSE) if ((int)strlen(hide_uname) == 0) { d_log("rescan: Making username = groupname\n"); snprintf(g.v.user.name, sizeof(g.v.user.name), "%s", g.v.user.group); } #endif } if (!rescan_quick || (g.l.race && !match_file(g.l.race, dp->d_name))) crc = calc_crc32(dp->d_name); else crc = 1; if (!S_ISDIR(fileinfo.st_mode)) { if (g.v.file.name) unlink_missing(g.v.file.name); if (l > 44) { if (crc == 1) printf("\nFile: %s CHECKED", dp->d_name + l - 44); else printf("\nFile: %s %.8x", dp->d_name + l - 44, crc); } else { if (crc == 1) printf("\nFile: %-44s CHECKED", dp->d_name); else printf("\nFile: %-44s %.8x", dp->d_name, crc); } } if(fflush(stdout)) d_log("rescan: ERROR: %s\n", strerror(errno)); if (!rescan_quick || (g.l.race && !match_file(g.l.race, dp->d_name)) || !fileexists(dp->d_name)) writerace(g.l.race, &g.v, crc, F_NOTCHECKED); } } printf("\n"); testfiles(&g.l, &g.v, 1); printf("\n"); readsfv(g.l.sfv, &g.v, 0); readrace(g.l.race, &g.v, g.ui, g.gi); sortstats(&g.v, g.ui, g.gi); buffer_progress_bar(&g.v); if (g.l.nfo_incomplete) { if (findfileext(dir, ".nfo")) { d_log("rescan: Removing missing-nfo indicator (if any)\n"); remove_nfo_indicator(&g); } else if (matchpath(check_for_missing_nfo_dirs, g.l.path) && (!matchpath(group_dirs, g.l.path) || create_incomplete_links_in_group_dirs)) { if (!g.l.in_cd_dir) { d_log("rescan: Creating missing-nfo indicator %s.\n", g.l.nfo_incomplete); if (create_incomplete_nfo()) { d_log("rescan: create_incomplete_nfo() returned something\n"); } } else { if (findfileextparent(parent, ".nfo")) { d_log("rescan: Removing missing-nfo indicator (if any)\n"); remove_nfo_indicator(&g); } else { d_log("rescan: Creating missing-nfo indicator (base) %s.\n", g.l.nfo_incomplete); /* This is not pretty, but should be functional. */ if ((inc_point[0] = find_last_of(g.l.path, "/")) != g.l.path) *inc_point[0] = '\0'; if ((inc_point[1] = find_last_of(g.v.misc.release_name, "/")) != g.v.misc.release_name) *inc_point[1] = '\0'; if (create_incomplete_nfo()) { d_log("rescan: create_incomplete_nfo() returned something\n"); } if (*inc_point[0] == '\0') *inc_point[0] = '/'; if (*inc_point[1] == '\0') *inc_point[1] = '/'; } } } } #if (create_missing_sample_link) if (g.l.sample_incomplete) { if (findfileextsub(dir) || matchpartialdirname(missing_sample_check_ignore_list, g.v.misc.release_name, missing_sample_check_ignore_dividers)) { d_log("rescan: Removing missing-sample indicator (if any)\n"); remove_sample_indicator(&g); } else if (matchpath(check_for_missing_sample_dirs, g.l.path) && (!matchpath(group_dirs, g.l.path) || create_incomplete_links_in_group_dirs)) { if (!g.l.in_cd_dir) { d_log("rescan: Creating missing-sample indicator %s.\n", g.l.sample_incomplete); if (create_incomplete_sample()) { d_log("rescan: create_incomplete_sample() returned something\n"); } } else { if (findfileextsubp(dir)) { d_log("rescan: Removing missing-sample indicator (if any)\n"); remove_sample_indicator(&g); } else { d_log("rescan: Creating missing-sample indicator (base) %s.\n", g.l.sample_incomplete); /* This is not pretty, but should be functional. */ if ((inc_point[0] = find_last_of(g.l.path, "/")) != g.l.path) *inc_point[0] = '\0'; if ((inc_point[1] = find_last_of(g.v.misc.release_name, "/")) != g.v.misc.release_name) *inc_point[1] = '\0'; if (create_incomplete_sample()) { d_log("rescan: create_incomplete_sample() returned something\n"); } if (*inc_point[0] == '\0') *inc_point[0] = '/'; if (*inc_point[1] == '\0') *inc_point[1] = '/'; } } } } #endif if (g.v.misc.release_type == RTYPE_AUDIO) { get_audio_info(findfileextfromlist(dir, audio_types), &g.v.audio); /* Sort if we're not in a group-dir/nosort-dir. */ if (!matchpath(group_dirs, g.l.path) && !matchpath(audio_nosort_dirs, g.l.path)) { printf(" Resorting release.\n"); audioSort(&g.v.audio, g.l.link_source, g.l.link_target); } } if ((g.v.total.files_missing == 0) && (g.v.total.files > 0)) { switch (g.v.misc.release_type) { case RTYPE_RAR: complete_bar = rar_completebar; break; case RTYPE_OTHER: complete_bar = other_completebar; break; case RTYPE_AUDIO: complete_bar = audio_completebar; #if ( create_m3u == TRUE ) n = snprintf(exec, sizeof(exec), "%s", findfileext(dir, ".sfv")); strcpy(exec + n - 3, "m3u"); create_indexfile(g.l.race, &g.v, exec); #endif break; case RTYPE_VIDEO: complete_bar = video_completebar; break; } complete(&g, complete_type); if (complete_bar) { createstatusbar(convert(&g.v, g.ui, g.gi, complete_bar)); #if (chmod_completebar) if (!matchpath(group_dirs, g.l.path)) { if (chmod_each(convert(&g.v, g.ui, g.gi, complete_bar), 0222)) d_log("rescan: Failed to chmod a statusbar: %s\n", strerror(errno)); } #endif } #if (enable_rescan_script) d_log("rescan: Executing rescan_script script\n"); if (!fileexists(rescan_script)) { d_log("rescan: Warning - rescan_script (%s) - file does not exist!\n", rescan_script); } else { snprintf(target, sizeof(target), rescan_script " \"%s\"", g.v.file.name); if (execute(target) != 0) d_log("rescan: Failed to execute rescan_script: %s\n", strerror(errno)); } #endif } else { if (!matchpath(group_dirs, g.l.path) || create_incomplete_links_in_group_dirs) { if (create_incomplete()) { d_log("rescan: create_incomplete() returned something\n"); } } move_progress_bar(0, &g.v, g.ui, g.gi); } } else { int empty = 1; #if (create_missing_sfv_link == TRUE) if ((!matchpath(group_dirs, g.l.path) || create_incomplete_links_in_group_dirs) && g.l.sfv_incomplete && !matchpath(nocheck_dirs, g.l.path) && !matchpath(allowed_types_exemption_dirs, g.l.path)) { rewinddir(dir); while ((dp = readdir(dir))) { stat(dp->d_name, &fileinfo); if (S_ISREG(fileinfo.st_mode)) { ext = find_last_of(dp->d_name, "."); if (*ext == '.') ext++; if (*ext && get_filetype(&g, ext) == 3) { d_log("rescan: Creating missing-sfv indicator %s.\n", g.l.sfv_incomplete); if (create_incomplete_sfv()) d_log("rescan: create_incomplete_sfv() returned something.\n"); empty = 0; break; } } } } #endif if (empty && mark_empty_dirs_as_incomplete_on_rescan) { if (create_incomplete()) { d_log("rescan: create_incomplete() returned something\n"); } printf(" Empty dir - marking as incomplete.\n"); } } printf(" Passed : %i\n", (int)g.v.total.files - (int)g.v.total.files_missing); printf(" Failed : %i\n", (int)g.v.total.files_bad); printf(" Missing: %i\n", (int)g.v.total.files_missing); printf(" Total : %i\n", (int)g.v.total.files); if (g.v.total.files && !g.v.total.files_missing) { g.v.misc.data_completed = 1; } else { g.v.misc.data_completed = 0; } d_log("rescan: Freeing memory and removing lock.\n"); closedir(dir); closedir(parent); ng_free(g.l.race); ng_free(g.l.sfv); ng_free(g.l.sfvbackup); ng_free(g.l.leader); remove_lock(&g.v); updatestats_free(&g); #ifdef USING_GLFTPD buffer_groups(GROUPFILE, gnum); buffer_users(PASSWDFILE, unum); #endif exit(0); }
static int audiodsp_ioctl(struct inode *node, struct file *file, unsigned int cmd, unsigned long args) { struct audiodsp_priv *priv=audiodsp_privdata(); struct audiodsp_cmd *a_cmd; char name[64]; int len; unsigned long pts; int ret=0; unsigned long *val=(unsigned long *)args; #ifdef ENABLE_WAIT_FORMAT static int wait_format_times=0; #endif switch(cmd) { case AUDIODSP_SET_FMT: priv->stream_fmt=args; if(args == MCODEC_FMT_DTS) IEC958_mode_codec = 1; else if(args == MCODEC_FMT_AC3) IEC958_mode_codec = 2; else IEC958_mode_codec = 0; break; case AUDIODSP_START: if(IEC958_mode_raw_last != IEC958_mode_raw || IEC958_mode_codec_last != IEC958_mode_codec) { IEC958_mode_raw_last = IEC958_mode_raw; IEC958_mode_codec_last = IEC958_mode_codec; aml_alsa_hw_reprepare(); } priv->decoded_nb_frames = 0; priv->format_wait_count = 0; if(priv->stream_fmt<=0) { DSP_PRNT("Audio dsp steam format have not set!\n"); } else { ret=audiodsp_start(); } break; case AUDIODSP_STOP: //DSP_PRNT("audiodsp command stop\n"); stop_audiodsp_monitor(priv); dsp_stop(priv); priv->decoded_nb_frames = 0; priv->format_wait_count = 0; break; #ifdef ENABLE_WAIT_FORMAT case AUDIODSP_DECODE_START: if(priv->dsp_is_started) { dsp_codec_start(priv); wait_format_times=0; } else { DSP_PRNT("Audio dsp have not started\n"); } break; case AUDIODSP_WAIT_FORMAT: if(priv->dsp_is_started) { struct audio_info *audio_format; int ch = 0; audio_format = get_audio_info(); wait_format_times++; if(wait_format_times>100){ int audio_info = DSP_RD(DSP_AUDIO_FORMAT_INFO); if(audio_info){ priv->frame_format.channel_num = audio_info&0xf; if(priv->frame_format.channel_num) priv->frame_format.valid |= CHANNEL_VALID; priv->frame_format.data_width= (audio_info>>4)&0x3f; if(priv->frame_format.data_width) priv->frame_format.valid |= DATA_WIDTH_VALID; priv->frame_format.sample_rate = (audio_info>>10); if(priv->frame_format.sample_rate) priv->frame_format.valid |= SAMPLE_RATE_VALID; DSP_PRNT("warning::got info from mailbox failed,read from regiser\n"); ret = 0; }else{ DSP_PRNT("dsp have not set the codec stream's format details,valid=%x\n", priv->frame_format.valid); priv->format_wait_count++; if(priv->format_wait_count > 5){ if(audio_format->channels&&audio_format->sample_rate){ priv->frame_format.channel_num = audio_format->channels>2?2:audio_format->channels; priv->frame_format.sample_rate = audio_format->sample_rate; priv->frame_format.data_width = 16; priv->frame_format.valid = CHANNEL_VALID|DATA_WIDTH_VALID|SAMPLE_RATE_VALID; DSP_PRNT("we have not got format details from dsp,so use the info got from the header parsed instead\n"); ret = 0; }else{ ret = -1; } }else{ ret=-1; } } }else if(priv->frame_format.valid == (CHANNEL_VALID|DATA_WIDTH_VALID|SAMPLE_RATE_VALID)){