blargg_err_t Sfm_Emu::start_track_( int track ) { RETURN_ERR( Music_Emu::start_track_( track ) ); resampler.clear(); filter.clear(); const byte * ptr = file_begin(); int metadata_size = get_le32(ptr + 4); if ( file_size() < metadata_size + Sfm_Emu::sfm_min_file_size ) return "SFM file too small"; char * temp = new char[metadata_size + 1]; temp[metadata_size] = '\0'; memcpy(temp, ptr + 8, metadata_size); metadata.parseDocument(temp); delete [] temp; apu.init_rom( ipl_rom ); apu.reset(); memcpy( apu.m.ram.ram, ptr + 8 + metadata_size, 65536 ); memcpy( apu.dsp.m.regs, ptr + 8 + metadata_size + 65536, 128 ); apu.set_sfm_queue( ptr + 8 + metadata_size + 65536 + 128, ptr + file_size() ); byte regs[Snes_Spc::reg_count] = {0}; char * end; const char * value; regs[Snes_Spc::r_test] = META_ENUM_INT("smp:test"); regs[Snes_Spc::r_control] |= META_ENUM_INT("smp:iplrom") ? 0x80 : 0; regs[Snes_Spc::r_dspaddr] = META_ENUM_INT("smp:dspaddr"); value = metadata.enumValue("smp:ram"); if (value) { regs[Snes_Spc::r_f8] = strtoul(value, &end, 10); if (*end) { value = end + 1; regs[Snes_Spc::r_f9] = strtoul(value, &end, 10); } } char temp_path[256]; for (int i = 0; i < 3; ++i) { sprintf(temp_path, "smp:timer[%u]:", i); size_t length = strlen(temp_path); strcpy(temp_path + length, "enable"); value = metadata.enumValue(temp_path); if (value) { regs[Snes_Spc::r_control] |= strtoul(value, &end, 10) ? 1 << i : 0; } strcpy(temp_path + length, "target"); value = metadata.enumValue(temp_path); if (value) { regs[Snes_Spc::r_t0target + i] = strtoul(value, &end, 10); } strcpy(temp_path + length, "stage"); value = metadata.enumValue(temp_path); if (value) { for (int j = 0; j < 3; ++j) { if (value) value = strchr(value, ','); if (value) ++value; } if (value) { regs[Snes_Spc::r_t0out + i] = strtoul(value, &end, 10); } } } apu.load_regs( regs ); apu.m.rom_enabled = 0; apu.regs_loaded(); for (int i = 0; i < 3; ++i) { sprintf(temp_path, "smp:timer[%u]:", i); size_t length = strlen(temp_path); strcpy(temp_path + length, "stage"); value = metadata.enumValue(temp_path); if (value) { const char * stage = value; apu.m.timers[i].next_time = strtoul(stage, &end, 10) + 1; for (int j = 0; j < 2; ++j) { if (stage) stage = strchr(stage, ','); if (stage) ++stage; } if (stage) { apu.m.timers[i].divider = strtoul(value, &end, 10); } } } apu.dsp.m.echo_hist_pos = &apu.dsp.m.echo_hist[META_ENUM_INT("dsp:echohistaddr")]; value = metadata.enumValue("dsp:echohistdata"); if (value) { for (int i = 0; i < 8; ++i) { apu.dsp.m.echo_hist[i][0] = strtoul(value, &end, 10); value = strchr(value, ','); if (!value) break; ++value; apu.dsp.m.echo_hist[i][1] = strtoul(value, &end, 10); value = strchr(value, ','); if (!value) break; ++value; } } apu.dsp.m.phase = META_ENUM_INT("dsp:sample"); apu.dsp.m.kon = META_ENUM_INT("dsp:kon"); apu.dsp.m.noise = META_ENUM_INT("dsp:noise"); apu.dsp.m.counter = META_ENUM_INT("dsp:counter"); apu.dsp.m.echo_offset = META_ENUM_INT("dsp:echooffset"); apu.dsp.m.echo_length = META_ENUM_INT("dsp:echolength"); apu.dsp.m.new_kon = META_ENUM_INT("dsp:koncache"); apu.dsp.m.endx_buf = META_ENUM_INT("dsp:endx"); apu.dsp.m.envx_buf = META_ENUM_INT("dsp:envx"); apu.dsp.m.outx_buf = META_ENUM_INT("dsp:outx"); apu.dsp.m.t_pmon = META_ENUM_INT("dsp:pmon"); apu.dsp.m.t_non = META_ENUM_INT("dsp:non"); apu.dsp.m.t_eon = META_ENUM_INT("dsp:eon"); apu.dsp.m.t_dir = META_ENUM_INT("dsp:dir"); apu.dsp.m.t_koff = META_ENUM_INT("dsp:koff"); apu.dsp.m.t_brr_next_addr = META_ENUM_INT("dsp:brrnext"); apu.dsp.m.t_adsr0 = META_ENUM_INT("dsp:adsr0"); apu.dsp.m.t_brr_header = META_ENUM_INT("dsp:brrheader"); apu.dsp.m.t_brr_byte = META_ENUM_INT("dsp:brrdata"); apu.dsp.m.t_srcn = META_ENUM_INT("dsp:srcn"); apu.dsp.m.t_esa = META_ENUM_INT("dsp:esa"); apu.dsp.m.t_echo_enabled = !META_ENUM_INT("dsp:echodisable"); apu.dsp.m.t_dir_addr = META_ENUM_INT("dsp:diraddr"); apu.dsp.m.t_pitch = META_ENUM_INT("dsp:pitch"); apu.dsp.m.t_output = META_ENUM_INT("dsp:output"); apu.dsp.m.t_looped = META_ENUM_INT("dsp:looped"); apu.dsp.m.t_echo_ptr = META_ENUM_INT("dsp:echoaddr"); #define META_ENUM_LEVELS(n, o) \ value = metadata.enumValue(n); \ if (value) \ { \ (o)[0] = strtoul(value, &end, 10); \ if (*end) \ { \ value = end + 1; \ (o)[1] = strtoul(value, &end, 10); \ } \ } META_ENUM_LEVELS("dsp:mainout", apu.dsp.m.t_main_out); META_ENUM_LEVELS("dsp:echoout", apu.dsp.m.t_echo_out); META_ENUM_LEVELS("dsp:echoin", apu.dsp.m.t_echo_in); #undef META_ENUM_LEVELS for (int i = 0; i < 8; ++i) { sprintf(temp_path, "dsp:voice[%u]:", i); size_t length = strlen(temp_path); Spc_Dsp::voice_t & voice = apu.dsp.m.voices[i]; strcpy(temp_path + length, "brrhistaddr"); value = metadata.enumValue(temp_path); if (value) { voice.buf_pos = strtoul(value, &end, 10); } strcpy(temp_path + length, "brrhistdata"); value = metadata.enumValue(temp_path); if (value) { for (int j = 0; j < Spc_Dsp::brr_buf_size; ++j) { voice.buf[j] = voice.buf[j + Spc_Dsp::brr_buf_size] = strtoul(value, &end, 10); if (!*end) break; value = end + 1; } } strcpy(temp_path + length, "interpaddr"); voice.interp_pos = META_ENUM_INT(temp_path); strcpy(temp_path + length, "brraddr"); voice.brr_addr = META_ENUM_INT(temp_path); strcpy(temp_path + length, "brroffset"); voice.brr_offset = META_ENUM_INT(temp_path); strcpy(temp_path + length, "vbit"); voice.vbit = META_ENUM_INT(temp_path); strcpy(temp_path + length, "vidx"); voice.regs = &apu.dsp.m.regs[META_ENUM_INT(temp_path)]; strcpy(temp_path + length, "kondelay"); voice.kon_delay = META_ENUM_INT(temp_path); strcpy(temp_path + length, "envmode"); voice.env_mode = (Spc_Dsp::env_mode_t) META_ENUM_INT(temp_path); strcpy(temp_path + length, "env"); voice.env = META_ENUM_INT(temp_path); strcpy(temp_path + length, "envxout"); voice.t_envx_out = META_ENUM_INT(temp_path); strcpy(temp_path + length, "envcache"); voice.hidden_env = META_ENUM_INT(temp_path); } filter.set_gain( (int) (gain() * Spc_Filter::gain_unit) ); apu.clear_echo( true ); return blargg_ok; }
blargg_err_t Zip_Extractor::open_path_v() { RETURN_ERR( open_arc_file( true ) ); return File_Extractor::open_path_v(); }
int DthAudio_startAudioPlayback(e_HatsAudioDevice_t dev, const char *file, const char *filef) { DECLARE_ERR(); hats_audio_err_t vl_audioerr = HATS_AUDIO_NO_ERROR; struct stat stat_src, stat_final; int res_stat_src, res_stat_final; res_stat_final = stat(filef, &stat_final); SYSLOG(LOG_DEBUG, "Audio file %s %s.", filef, (0 == res_stat_final) ? "exists" : "does NOT exist"); res_stat_src = stat(file, &stat_src); SYSLOG(LOG_DEBUG, "Uploaded file %s %s.", file, (0 == res_stat_src) ? "exists" : "does NOT exist"); /* error case: no audio file available */ if ((-1 == res_stat_final) && (-1 == res_stat_src)) { SYSLOG(LOG_ERR, "No audio file available for playback.\nPlease upload one and try again."); TAT_SET_LAST_ERR(TAT_ERROR_FILE_OPEN); } else { /* need to generate the converted file if it is older than the uploaded one or if it does not exist */ if ((-1 == res_stat_final) || (stat_final.st_mtime < stat_src.st_mtime)) { SYSLOG(LOG_NOTICE, "Converting %s to %s via device %u...", file, filef, dev); vl_audioerr = ConvWaveFile(dev, file, filef); if (HATS_AUDIO_NO_ERROR == vl_audioerr) { /* conversion succeeded */ SYSLOG(LOG_NOTICE, "File successfully converted."); } else { /* error on conversion*/ SYSLOG(LOG_ERR, "Conversion failed"); } } /* if the conversion succeed , try to play the file */ if (HATS_AUDIO_NO_ERROR == vl_audioerr) { vl_audioerr = StartPCMTransfer(dev, CODEC_PLAYBACK, NORMAL_PLAYBACK_MODE, (char *) filef); if (HATS_AUDIO_NO_ERROR == vl_audioerr) { /* play on going */ SYSLOG(LOG_NOTICE, "File is playing..."); dthaudio_activity = TATAUDIO_PLAYBACK_ON; } else { /* error when playing the converted file */ SYSLOG(LOG_ERR, "Fail to play the converted file"); /* Try to play the non converted file*/ vl_audioerr = StartPCMTransfer(dev, CODEC_PLAYBACK, NORMAL_PLAYBACK_MODE, (char *) file); if (HATS_AUDIO_NO_ERROR == vl_audioerr) { /* play on going */ SYSLOG(LOG_NOTICE, "Non-converted File is playing..."); dthaudio_activity = TATAUDIO_PLAYBACK_ON; } else { /* error: what? */ TAT_SET_LAST_ERR(hats_audio_err_to_dth(vl_audioerr)); SYSLOG(LOG_ERR, "Fail to play the Non-converted file"); SYSLOG(LOG_ERR, "Unkown error...\n"); } } } else { /*conversion has failed, file should be directly played*/ vl_audioerr = StartPCMTransfer(dev, CODEC_PLAYBACK, NORMAL_PLAYBACK_MODE, (char *) file); if (HATS_AUDIO_NO_ERROR == vl_audioerr) { /* play on going */ SYSLOG(LOG_NOTICE, "Non-converted File is playing..."); dthaudio_activity = TATAUDIO_PLAYBACK_ON; } else { TAT_SET_LAST_ERR(hats_audio_err_to_dth(vl_audioerr)); SYSLOG(LOG_ERR, "Fail to play the Non-converted file"); printf("Unkown error...\n"); } } } RETURN_ERR(); }
blargg_err_t load_mem_( byte const begin [], int size ) { RETURN_ERR( parse_header( begin, size, &file ) ); set_track_count( file.header->max_track + 1 ); return blargg_ok; }
int DthAudio_01SimpleGet(struct dth_element *elem, void *value) { DECLARE_ERR(); uint32_t *pl_value = STATIC_CAST(value, uint32_t *); SYSLOG(LOG_DEBUG, "DTH Get with elem->user_data=%u", elem->user_data); switch (elem->user_data) { #if defined HATS_AB_8520_HW case TATAUDIO_MODEM_LOOP: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); TAT_IF_OK(*pl_value = dthaudio_loop_interface); break; #endif case TATAUDIO_AUDIT_ACTIVITY: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); TAT_IF_OK(*pl_value = dthaudio_activity); break; case TATAUDIO_DEVICE: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); TAT_IF_OK(*pl_value = dthaudio_playback_device); break; case TATAUDIO_SRC: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); TAT_IF_OK(*pl_value = dthaudio_source); break; case TATAUDIO_SINK: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); TAT_IF_OK(*pl_value = dthaudio_sink); break; case TATAUDIO_AVCONNECTOR: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); TAT_IF_OK(*pl_value = dthaudio_avconnector); break; #if defined HATS_AB_8520_HW case TATAUDIO_JACK_USB_MIC_SWITCH: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); TAT_IF_OK(*pl_value = dthaudio_micswitch); break; case TATAUDIO_HEADSET_SWITCH: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); TAT_IF_OK(*pl_value = dthaudio_headsetswitch); break; #endif default: TAT_SET_LAST_ERR(TAT_BAD_REQ); } RETURN_ERR(); }
int DthAudio_03SimpleExec(struct dth_element *elem) { DECLARE_ERR(); SYSLOG(LOG_DEBUG, "DTH Exec with elem->user_data=%u", elem->user_data); switch (elem->user_data) { case TATAUDIO_DIGITAL_LOOP_IN_AB: if (TATAUDIO_START == dthaudio_digital_loop_in_ab_action) { TAT_TRY(DthAudio_startABDigitalAudioLoop()); } else TAT_TRY(DthAudio_stopAudioLoop(CODEC_PLAYBACK)); break; case TATAUDIO_DIGITAL_LOOP_IN_AP: if (TATAUDIO_START == dthaudio_digital_loop_in_ap_action) { TAT_TRY(DthAudio_startAPDigitalAudioLoop()); } else TAT_TRY(DthAudio_stopAudioLoop(CODEC_PLAYBACK)); break; case TATAUDIO_ANALOG_LOOP: if (TATAUDIO_START == dthaudio_analog_loop_action) { TAT_TRY(DthAudio_startAnalogAudioLoop()); } else TAT_TRY(DthAudio_stopAudioLoop(CODEC_CAPTURE)); break; #if 0 case TATAUDIO_DIGITAL_LOOP_IN_MODEM: if (TATAUDIO_MOD_START == dthaudio_digital_loop_in_modem_action) { TAT_TRY(DthAudio_startModemAudioLoop()); } else if (TATAUDIO_MOD_STOP == dthaudio_digital_loop_in_modem_action) { TAT_TRY(DthAudio_stopModemAudioLoop()); } else if (TATAUDIO_SET_MODEM_MODE == dthaudio_digital_loop_in_modem_action) { TAT_TRY(DthAudio_setModemAudioLoop()); } break; #endif case TATAUDIO_PLAYBACK: if (TATAUDIO_START == dthaudio_playback_action) { if (TATAUDIO_HDMI_DEVICE == dthaudio_playback_device) { TAT_TRY(DthAudio_startAudioPlayback(AUDIO_DEVICE_HDMI, PLAYBACK_UPLOAD_FILE, PLAYBACK_FINAL_FILE)); } else { TAT_TRY(DthAudio_startAudioPlayback(AUDIO_DEVICE_0, PLAYBACK_UPLOAD_FILE, PLAYBACK_FINAL_FILE)); } } else if (TATAUDIO_STOP == dthaudio_playback_action) { if (TATAUDIO_HDMI_DEVICE == dthaudio_playback_device) { TAT_TRY(DthAudio_stopAudioPlayback(AUDIO_DEVICE_HDMI)); } else { TAT_TRY(DthAudio_stopAudioPlayback(AUDIO_DEVICE_0)); } } break; case TATAUDIO_RECORD: if (TATAUDIO_START == dthaudio_record_action) { if (TATAUDIO_HDMI_DEVICE == dthaudio_playback_device) { TAT_TRY(StartPCMTransfer(AUDIO_DEVICE_HDMI, CODEC_CAPTURE, NORMAL_CAPTURE_MODE, RECORD_FILE)); } else { TAT_TRY(StartPCMTransfer(AUDIO_DEVICE_0, CODEC_CAPTURE, NORMAL_CAPTURE_MODE, RECORD_FILE)); } } else if (TATAUDIO_STOP == dthaudio_record_action) { if (TATAUDIO_HDMI_DEVICE == dthaudio_playback_device) { TAT_TRY(StopPCMTransfer(AUDIO_DEVICE_HDMI, CODEC_CAPTURE)); } else { TAT_TRY(StopPCMTransfer(AUDIO_DEVICE_0, CODEC_CAPTURE)); } } break; default: TAT_SET_LAST_ERR(TAT_BAD_REQ); } /* sends asychronous events in order to indicate a value change in the parameters values*/ SYSLOG(LOG_INFO, "DthAudio_SendAsyncEventParameters VALUE_CHANGED ..."); //printf("\nDthAudio_SendAsyncEventParameters VALUE_CHANGED for full list....\n"); DthAudio_SendAsyncEventParameters(a_dthaudio_fulllistpath, VALUE_CHANGED, (mode_t)0); libtatasync_msg_send(VALUE_CHANGED, "/DTH/AUDIO/Tests/Activity"); RETURN_ERR(); }
void main() { int err; int verify_client = OFF; /* To verify a client certificate, set ON */ int listen_sock; int sock; struct sockaddr_in sa_serv; struct sockaddr_in sa_cli; size_t client_len; char *str; char buf[4096]; SSL_CTX *ctx; SSL *ssl; SSL_METHOD *meth; X509 *client_cert = NULL; short int s_port = 5555; /*----------------------------------------------------------------*/ /* Load encryption & hashing algorithms for the SSL program */ SSL_library_init(); /* Load the error strings for SSL & CRYPTO APIs */ SSL_load_error_strings(); /* Create a SSL_METHOD structure (choose a SSL/TLS protocol version) */ meth = SSLv3_method(); /* Create a SSL_CTX structure */ ctx = SSL_CTX_new(meth); if (!ctx) { ERR_print_errors_fp(stderr); exit(1); } /* Load the server certificate into the SSL_CTX structure */ if (SSL_CTX_use_certificate_file(ctx, RSA_SERVER_CERT, SSL_FILETYPE_PEM) <= 0) { ERR_print_errors_fp(stderr); exit(1); } /* Load the private-key corresponding to the server certificate */ if (SSL_CTX_use_PrivateKey_file(ctx, RSA_SERVER_KEY, SSL_FILETYPE_PEM) <= 0) { ERR_print_errors_fp(stderr); exit(1); } /* Check if the server certificate and private-key matches */ if (!SSL_CTX_check_private_key(ctx)) { fprintf(stderr,"Private key does not match the certificate public key\n"); exit(1); } if(verify_client == ON) { /* Load the RSA CA certificate into the SSL_CTX structure */ if (!SSL_CTX_load_verify_locations(ctx, RSA_SERVER_CA_CERT, NULL)) { ERR_print_errors_fp(stderr); exit(1); } /* Set to require peer (client) certificate verification */ SSL_CTX_set_verify(ctx,SSL_VERIFY_PEER,NULL); /* Set the verification depth to 1 */ SSL_CTX_set_verify_depth(ctx,1); } /* ----------------------------------------------- */ /* Set up a TCP socket */ listen_sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); RETURN_ERR(listen_sock, "socket"); memset (&sa_serv, '\0', sizeof(sa_serv)); sa_serv.sin_family = AF_INET; sa_serv.sin_addr.s_addr = INADDR_ANY; sa_serv.sin_port = htons (s_port); /* Server Port number */ err = bind(listen_sock, (struct sockaddr*)&sa_serv,sizeof(sa_serv)); RETURN_ERR(err, "bind"); /* Wait for an incoming TCP connection. */ err = listen(listen_sock, 5); RETURN_ERR(err, "listen"); client_len = sizeof(sa_cli); /* Socket for a TCP/IP connection is created */ sock = accept(listen_sock, (struct sockaddr*)&sa_cli, &client_len); RETURN_ERR(sock, "accept"); close (listen_sock); printf ("Connection from %lx, port %x\n", sa_cli.sin_addr.s_addr, sa_cli.sin_port); /* ----------------------------------------------- */ /* TCP connection is ready. */ /* A SSL structure is created */ ssl = SSL_new(ctx); RETURN_NULL(ssl); /* Assign the socket into the SSL structure (SSL and socket without BIO) */ SSL_set_fd(ssl, sock); /* Perform SSL Handshake on the SSL server */ err = SSL_accept(ssl); RETURN_SSL(err); /* Informational output (optional) */ printf("SSL connection using %s\n", SSL_get_cipher (ssl)); if (verify_client == ON) { /* Get the client's certificate (optional) */ client_cert = SSL_get_peer_certificate(ssl); if (client_cert != NULL) { printf ("Client certificate:\n"); str = X509_NAME_oneline(X509_get_subject_name(client_cert), 0, 0); RETURN_NULL(str); printf ("\t subject: %s\n", str); free (str); str = X509_NAME_oneline(X509_get_issuer_name(client_cert), 0, 0); RETURN_NULL(str); printf ("\t issuer: %s\n", str); free (str); X509_free(client_cert); } else printf("The SSL client does not have certificate.\n"); } /*------- DATA EXCHANGE - Receive message and send reply. -------*/ /* Receive data from the SSL client */ err = SSL_read(ssl, buf, sizeof(buf) - 1); RETURN_SSL(err); buf[err] = '\0'; printf ("Received %d chars:'%s'\n", err, buf); /* Send data to the SSL client */ err = SSL_write(ssl, "This message is from the SSL server", strlen("This message is from the SSL server")); RETURN_SSL(err); /*--------------- SSL closure ---------------*/ /* Shutdown this side (server) of the connection. */ err = SSL_shutdown(ssl); RETURN_SSL(err); /* Terminate communication on a socket */ err = close(sock); RETURN_ERR(err, "close"); /* Free the SSL structure */ SSL_free(ssl); /* Free the SSL_CTX structure */ SSL_CTX_free(ctx); }
// @pymethod int|PyCTreeCtrl|InsertItem|Inserts an item into the list. PyObject *PyCTreeCtrl_InsertItem( PyObject *self, PyObject *args ) { CTreeCtrl *pList; HTREEITEM ret = NULL; UINT mask; int image, selImage, state, stateMask; PyObject *obParent, *obInsertAfter; LPARAM lParam; HTREEITEM hParent, hInsertAfter; TCHAR *text=NULL; PyObject *obtext=Py_None; if (!(pList=GetTreeCtrl(self))) return NULL; if (PyArg_ParseTuple(args, "iOiiiiOOO:InsertItem", &mask, // @pyparmalt1 int|mask||Integer specifying which attributes to set &obtext, // @pyparmalt1 string|text||The text of the item. &image, // @pyparmalt1 int|image||The index of the image to use. &selImage, // @pyparmalt1 int|selectedImage||The index of the items selected image. &state, // @pyparmalt1 int|state||The initial state of the item. &stateMask, // @pyparmalt1 int|stateMask||Specifies which bits of the state are valid. &lParam, // @pyparmalt1 object|lParam||A user defined object for the item. &obParent, // @pyparmalt1 HTREEITEM|parent||The parent of the item. &obInsertAfter)) { // @pyparmalt1 HTREEITEM|parent||The parent of the item. if (!PyWinObject_AsHANDLE(obParent, (HANDLE *)&hParent)) return NULL; if (!PyWinObject_AsHANDLE(obInsertAfter, (HANDLE *)&hInsertAfter)) return NULL; if (!PyWinObject_AsTCHAR(obtext, &text, TRUE)) return NULL; GUI_BGN_SAVE; ret = pList->InsertItem(mask, text, image, selImage, state, stateMask, lParam, hParent, hInsertAfter); GUI_END_SAVE; goto done; } PyErr_Clear(); hParent = TVI_ROOT; hInsertAfter = TVI_LAST; if (PyArg_ParseTuple(args, "Oii|O&O&:InsertItem", &obtext, // @pyparmalt2 string|text||The text for the item. &image, // @pyparmalt2 int|image||The index of the image to use. &selImage, // @pyparmalt2 int|selectedImage||The index of the items selected image. PyWinObject_AsHANDLE, &hParent, // @pyparmalt2 HTREEITEM|parent|commctrl.TVI_ROOT|The parent of the item. PyWinObject_AsHANDLE, &hInsertAfter) // @pyparmalt2 HTREEITEM|insertAfter|commctrl.TVI_LAST|The item to insert the new item after, or TVI_FIRST, TVI_LAST or TVI_SORT && PyWinObject_AsTCHAR(obtext, &text, FALSE)){ GUI_BGN_SAVE; ret = pList->InsertItem(text, image, selImage, hParent, hInsertAfter); GUI_END_SAVE; goto done; } // This arg format conflicts with the above. Handle's can be parsed as ints, so if both optional items are // passed, they will be caught by the above and never get here ! PyErr_Clear(); hParent = TVI_ROOT; hInsertAfter = TVI_LAST; if (PyArg_ParseTuple(args, "O|O&O&:InsertItem", &obtext, // @pyparmalt3 string|text||The text for the item. PyWinObject_AsHANDLE, &hParent, // @pyparmalt3 HTREEITEM|parent|commctrl.TVI_ROOT|The parent of the item. PyWinObject_AsHANDLE, &hInsertAfter) // @pyparmalt3 HTREEITEM|parent|commctrl.TVI_LAST|The parent of the item. && PyWinObject_AsTCHAR(obtext, &text, FALSE)){ GUI_BGN_SAVE; ret = pList->InsertItem(text, hParent, hInsertAfter); GUI_END_SAVE; goto done; } PyErr_Clear(); PyObject *obTVItem; TV_INSERTSTRUCT tvItem; if (PyArg_ParseTuple(args, "O&O&O:InsertItem", PyWinObject_AsHANDLE, &tvItem.hParent, // @pyparm HTREEITEM|hParent||The parent item. If commctrl.TVI_ROOT or 0, it is added to the root. PyWinObject_AsHANDLE, &tvItem.hInsertAfter, // @pyparm HTREEITEM|hInsertAfter||The item to insert after. Can be an item or TVI_FIRST, TVI_LAST or TVI_SORT &obTVItem)) { // @pyparm <o TV_ITEM>|item||A tuple describing the new item. if (!PyWinObject_AsTV_ITEM(obTVItem, &tvItem.item)) return NULL; GUI_BGN_SAVE; ret = pList->InsertItem(&tvItem); GUI_END_SAVE; PyWinObject_FreeTV_ITEM(&tvItem.item); goto done; } PyErr_Clear(); RETURN_ERR("InsertItem could not parse the params."); // And you will beat your brains out determining why ... done: PyWinObject_FreeTCHAR(text); if (ret==NULL) RETURN_ERR("InsertItem failed"); return PyWinLong_FromHANDLE(ret); }
blargg_err_t Stereo_Buffer::set_sample_rate( long rate, int msec ) { for ( int i = 0; i < buf_count; i++ ) RETURN_ERR( bufs [i].set_sample_rate( rate, msec ) ); return Multi_Buffer::set_sample_rate( bufs [0].sample_rate(), bufs [0].length() ); }
blargg_err_t Binary_Extractor::stat_v() { RETURN_ERR( open_arc_file() ); RETURN_ERR( arc().seek( 0 ) ); return open_v(); }
blargg_err_t Mono_Buffer::set_sample_rate( long rate, int msec ) { RETURN_ERR( buf.set_sample_rate( rate, msec ) ); return Multi_Buffer::set_sample_rate( buf.sample_rate(), buf.length() ); }
blargg_err_t File_Extractor::open_path_v() { RETURN_ERR( open_arc_file() ); return open_v(); }
blargg_err_t Sfm_Emu::play_and_filter( int count, sample_t out [] ) { RETURN_ERR( apu.play( count, out ) ); filter.run( out, count ); return blargg_ok; }
blargg_err_t Fir_Resampler_::buffer_size( int new_size ) { RETURN_ERR( buf.resize( new_size + write_offset ) ); clear(); return 0; }
blargg_err_t Gme_File::load_( Data_Reader& in ) { RETURN_ERR( file_data.resize( in.remain() ) ); RETURN_ERR( in.read( file_data.begin(), file_data.size() ) ); return load_mem_( file_data.begin(), file_data.size() ); }
char* ssl_sock_read(int sock, SSL_CTX *ctx) { int err; int verify_client = OFF; /* To verify a client certificate, set ON */ int pid; struct sockaddr_in sa_serv; struct sockaddr_in sa_cli; size_t client_len; char *str; char buf[4096]; SSL *ssl; SSL_METHOD *meth; X509 *client_cert = NULL; /* ----------------------------------------------- */ /* TCP connection is ready. */ /* A SSL structure is created */ ssl = SSL_new(ctx); RETURN_NULL(ssl); /* Assign the socket into the SSL structure (SSL and socket without BIO) */ SSL_set_fd(ssl, sock); /* Perform SSL Handshake on the SSL server */ err = SSL_accept(ssl); RETURN_SSL(err); /* Informational output (optional) */ //printf("SSL connection using %s\n", SSL_get_cipher (ssl)); if (verify_client == ON) { /* Get the client's certificate (optional) */ client_cert = SSL_get_peer_certificate(ssl); if (client_cert != NULL) { //printf ("Client certificate:\n"); str = X509_NAME_oneline(X509_get_subject_name(client_cert), 0, 0); RETURN_NULL(str); //printf ("\t subject: %s\n", str); free(str); str = X509_NAME_oneline(X509_get_issuer_name(client_cert), 0, 0); RETURN_NULL(str); //printf ("\t issuer: %s\n", str); free(str); X509_free(client_cert); } else { printf("The SSL client does not have certificate.\n"); } } /*------- DATA EXCHANGE - Receive message and send reply. -------*/ /* Receive data from the SSL client */ /* Send data to the SSL client */ run_php_prog_ssl(ssl, 0); /*--------------- SSL closure ---------------*/ /* Shutdown this side (server) of the connection. */ err = SSL_shutdown(ssl); RETURN_SSL(err); /* Terminate communication on a socket */ err = close(sock); RETURN_ERR(err, "close"); /* Free the SSL structure */ //SSL_free(ssl); /* Free the SSL_CTX structure */ //SSL_CTX_free(ctx); exit(0); }
BLARGG_EXPORT fex_err_t fex_read( fex_t* fe, void* out, int count ) { RETURN_ERR( fe->stat() ); return fe->reader().read( out, count ); }
blargg_err_t load_mem_( byte const begin [], int size ) { RETURN_ERR( parse_info( begin, size, &info ) ); set_track_count( info.track_count ); return blargg_ok; }
blargg_err_t load_mem_( byte const* begin, long size ) { RETURN_ERR( parse_info( begin, size, &info ) ); set_track_count( info.track_count ); return 0; }
int DthAudio_02SimpleSet(struct dth_element *elem, void *value) { DECLARE_ERR(); uint32_t vl_value = DEREF_PTR(value, uint32_t); hats_audio_err_t vl_audioerr; SYSLOG(LOG_DEBUG, "DTH set with elem->user_data= %u", elem->user_data); switch (elem->user_data) { case TATAUDIO_DIGITAL_LOOP_IN_AB: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); VERIFY_ENUM(vl_value, TATAUDIO_STOP); if (TAT_LAST_OK()) { dthaudio_digital_loop_in_ab_action = vl_value; SYSLOG(LOG_INFO, "Digital AB Audio loop operation set to %u.", dthaudio_digital_loop_in_ab_action); } break; case TATAUDIO_DIGITAL_LOOP_IN_AP: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); VERIFY_ENUM(vl_value, TATAUDIO_STOP); if (TAT_LAST_OK()) { dthaudio_digital_loop_in_ap_action = vl_value; SYSLOG(LOG_INFO, "Digital AP Audio loop operation set to %u.", dthaudio_digital_loop_in_ap_action); } break; case TATAUDIO_ANALOG_LOOP: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); VERIFY_ENUM(vl_value, TATAUDIO_STOP); if (TAT_LAST_OK()) { dthaudio_analog_loop_action = vl_value; SYSLOG(LOG_INFO, "ANALOG Audio loop operation set to %u.", dthaudio_analog_loop_action); } break; #if defined HATS_AB_8520_HW case TATAUDIO_DIGITAL_LOOP_IN_MODEM: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); VERIFY_ENUM(vl_value, TATAUDIO_MOD_STOP); if (TAT_LAST_OK()) { dthaudio_digital_loop_in_modem_action = vl_value; SYSLOG(LOG_INFO, "Modem Audio loop operation set to %u.", dthaudio_digital_loop_in_modem_action); } break; case TATAUDIO_MODEM_LOOP: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); VERIFY_ENUM(vl_value, TATAUDIO_MODEM_LOOP2); if (TAT_LAST_OK()) { dthaudio_loop_interface = vl_value; SYSLOG(LOG_INFO, "Modem Audio loop interface set to %u.", dthaudio_loop_interface); } break; #endif case TATAUDIO_PLAYBACK: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); VERIFY_ENUM(vl_value, TATAUDIO_STOP); if (TAT_LAST_OK()) { dthaudio_playback_action = vl_value; SYSLOG(LOG_INFO, "Audio playback operation set to %u.", dthaudio_playback_action); } break; case TATAUDIO_RECORD: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); VERIFY_ENUM(vl_value, TATAUDIO_STOP); if (TAT_LAST_OK()) { dthaudio_record_action = vl_value; SYSLOG(LOG_INFO, "Audio record operation set to %u.", dthaudio_record_action); } break; case TATAUDIO_DEVICE: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); VERIFY_ENUM(vl_value, TATAUDIO_HDMI_DEVICE); if (TAT_LAST_OK()) { dthaudio_playback_device = vl_value; SYSLOG(LOG_INFO, "Playback device %u (0=MAIN, 1=HDMI) selected.", dthaudio_playback_device); } break; case TATAUDIO_SRC: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); VERIFY_ENUM(vl_value, TATAUDIO_ENUM_SRC_MAX); if (TAT_LAST_OK()) { vl_audioerr = SetSrc(AUDIO_DEVICE_0, (e_HatsAudioInput_t) Dthaudio_codec_src_tab[vl_value]); if (HATS_AUDIO_NO_ERROR == vl_audioerr) { dthaudio_source = vl_value; SYSLOG(LOG_INFO, "Audio source changed to %u", dthaudio_source); } else { TAT_SET_LAST_ERR(hats_audio_err_to_dth(vl_audioerr)); SYSLOG(LOG_ERR, "Failed to set audio source"); } } if (TAT_LAST_OK()) { if (TATAUDIO_SRC_MICRO_AN1B == vl_value) { #if defined HATS_AB_8520_HW dthaudio_micswitch = TATAUDIO_JACKMIC; DthAudio_GpioConfig(TATAUDIO_GPIO_MICCTRL_DIR, TATAUDIO_GPIO_MICCTRL_OUT, TATAUDIO_GPIO_MICCTRL_PUD, TATAUDIO_GPIO_MICCTRL_OFFSET_IN_REGISTER, 1, 1, 0); TAT_TRY(libtatasync_msg_send(VALUE_CHANGED, "/DTH/AUDIO/Tests/Setup/GPIO_MIC_CTRL")); #endif dthaudio_avconnector = TATAUDIO_AVCONN_AUDIO; DthAudio_GpioConfig(TATAUDIO_GPIO_VIDEOCTRL_DIR, TATAUDIO_GPIO_VIDEOCTRL_OUT, TATAUDIO_GPIO_VIDEOCTRL_PUD, TATAUDIO_GPIO_VIDEOCTRL_OFFSET_IN_REGISTER, 1, 1, 0);; TAT_TRY(libtatasync_msg_send(VALUE_CHANGED, "/DTH/AUDIO/Tests/Setup/GPIO_MICVIDEO_CTRL")); } #if defined HATS_AB_8520_HW else if (TATAUDIO_SRC_MICRO_USB == vl_value) { dthaudio_micswitch = TATAUDIO_USBMIC; DthAudio_GpioConfig(TATAUDIO_GPIO_MICCTRL_DIR, TATAUDIO_GPIO_MICCTRL_OUT, TATAUDIO_GPIO_MICCTRL_PUD, TATAUDIO_GPIO_MICCTRL_OFFSET_IN_REGISTER, 1, 0, 0); TAT_TRY(libtatasync_msg_send(VALUE_CHANGED, "/DTH/AUDIO/Tests/Setup/GPIO_MIC_CTRL")); dthaudio_avconnector = TATAUDIO_AVCONN_AUDIO; DthAudio_GpioConfig(TATAUDIO_GPIO_VIDEOCTRL_DIR, TATAUDIO_GPIO_VIDEOCTRL_OUT, TATAUDIO_GPIO_VIDEOCTRL_PUD, TATAUDIO_GPIO_VIDEOCTRL_OFFSET_IN_REGISTER, 1, 1, 0);; TAT_TRY(libtatasync_msg_send(VALUE_CHANGED, "/DTH/AUDIO/Tests/Setup/GPIO_MICVIDEO_CTRL")); } #endif } break; case TATAUDIO_SINK: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); VERIFY_ENUM(vl_value, TATAUDIO_ENUM_SINK_MAX); if (TAT_LAST_OK()) { vl_audioerr = SetSink(AUDIO_DEVICE_0, (e_HatsAudioOutput_t) Dthaudio_codec_sink_tab[vl_value]); if (HATS_AUDIO_NO_ERROR == vl_audioerr) { dthaudio_sink = vl_value; SYSLOG(LOG_INFO, "Audio sink set to %u", dthaudio_sink); } else { TAT_SET_LAST_ERR(hats_audio_err_to_dth(vl_audioerr)); SYSLOG(LOG_ERR, "Failed to set audio sink"); } } break; case TATAUDIO_AVCONNECTOR: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); VERIFY_ENUM(vl_value, TATAUDIO_AVCONN_VIDEO); if (TAT_LAST_OK()) { if (TATAUDIO_AVCONN_VIDEO == vl_value) { DthAudio_GpioConfig(TATAUDIO_GPIO_VIDEOCTRL_DIR, TATAUDIO_GPIO_VIDEOCTRL_OUT, TATAUDIO_GPIO_VIDEOCTRL_PUD, TATAUDIO_GPIO_VIDEOCTRL_OFFSET_IN_REGISTER, 1, 0, 0); SYSLOG(LOG_INFO, "AV connector set to VIDEO_SOURCE"); } else if (TATAUDIO_AVCONN_AUDIO == vl_value) { DthAudio_GpioConfig(TATAUDIO_GPIO_VIDEOCTRL_DIR, TATAUDIO_GPIO_VIDEOCTRL_OUT, TATAUDIO_GPIO_VIDEOCTRL_PUD, TATAUDIO_GPIO_VIDEOCTRL_OFFSET_IN_REGISTER, 1, 1, 0);; SYSLOG(LOG_INFO, "AV connector set to AUDIO_SOURCE"); } if (TAT_LAST_OK()) { dthaudio_avconnector = vl_value; } else { SYSLOG(LOG_ERR, "Failed to set AV connector"); } } break; #if defined HATS_AB_8520_HW case TATAUDIO_JACK_USB_MIC_SWITCH: VERIFY_DTH_TYPE(elem, DTH_TYPE_U32); VERIFY_ENUM(vl_value, TATAUDIO_USBMIC); if (TAT_LAST_OK()) { if (TATAUDIO_JACKMIC == vl_value) { DthAudio_GpioConfig(TATAUDIO_GPIO_MICCTRL_DIR, TATAUDIO_GPIO_MICCTRL_OUT, TATAUDIO_GPIO_MICCTRL_PUD, TATAUDIO_GPIO_MICCTRL_OFFSET_IN_REGISTER, 1, 1, 0); SYSLOG(LOG_INFO, "Mic switch set to JACK"); } else if (TATAUDIO_USBMIC == vl_value) { DthAudio_GpioConfig(TATAUDIO_GPIO_MICCTRL_DIR, TATAUDIO_GPIO_MICCTRL_OUT, TATAUDIO_GPIO_MICCTRL_PUD, TATAUDIO_GPIO_MICCTRL_OFFSET_IN_REGISTER, 1, 0, 0);; SYSLOG(LOG_INFO, "Mic switch set to USB"); } if (TAT_LAST_OK()) { dthaudio_micswitch = vl_value; } else { SYSLOG(LOG_ERR, "Failed to set Mic switch"); } } break; #endif default: TAT_SET_LAST_ERR(TAT_BAD_REQ); } RETURN_ERR(); }
blargg_err_t Nsf_Emu::load_( Data_Reader& in ) { assert( offsetof (header_t,unused [4]) == header_size ); RETURN_ERR( rom.load( in, header_size, &header_, 0 ) ); set_track_count( header_.track_count ); RETURN_ERR( check_nsf_header( &header_ ) ); if ( header_.vers != 1 ) set_warning( "Unknown file version" ); // sound and memory blargg_err_t err = init_sound(); if ( err ) return err; // set up data nes_addr_t load_addr = get_le16( header_.load_addr ); init_addr = get_le16( header_.init_addr ); play_addr = get_le16( header_.play_addr ); if ( !load_addr ) load_addr = rom_begin; if ( !init_addr ) init_addr = rom_begin; if ( !play_addr ) play_addr = rom_begin; if ( load_addr < rom_begin || init_addr < rom_begin ) { const char* w = warning(); if ( !w ) w = "Corrupt file (invalid load/init/play address)"; return w; } rom.set_addr( load_addr % bank_size ); int total_banks = rom.size() / bank_size; // bank switching int first_bank = (load_addr - rom_begin) / bank_size; for ( int i = 0; i < bank_count; i++ ) { unsigned bank = i - first_bank; if ( bank >= (unsigned) total_banks ) bank = 0; initial_banks [i] = bank; if ( header_.banks [i] ) { // bank-switched memcpy( initial_banks, header_.banks, sizeof initial_banks ); break; } } pal_only = (header_.speed_flags & 3) == 1; #if !NSF_EMU_EXTRA_FLAGS header_.speed_flags = 0; #endif set_tempo( tempo() ); return setup_buffer( (long) (clock_rate_ + 0.5) ); }
int DthAudio_stopModemAudioLoop(void) { DECLARE_ERR(); #if 0 int vl_status = 0; VERIFY_ENUM(dthaudio_loop_interface, TATAUDIO_MODEM_LOOP2); if (TAT_LAST_OK()) { switch (dthaudio_loop_interface) { case TATAUDIO_MODEM_LOOP1: SYSLOG(LOG_INFO, "Stopping modem audio loop 1 ..."); if (modemMngt_getModemConfig() == 1) { printf("Modem Loopback is not supported in this config\n"); TAT_SET_LAST_ERR(TAT_BAD_REQ); } else { //printf("Modem Loopback will be supported in this config\n"); /* check modem mode */ if (modemMngt_getModemMode() != 0 /*normal*/) { /* change to normal mode and indicate to reboot...*/ modemMngt_setModemMode(NORMAL_MODE); printf("/!\\ NEED TO REBOOT TO BE IN NORMAL MODEM MODE!\n"); modemMngt_setModemState(2); ///system("reboot"); /* normal modem mode is off after reboot */ system("poweroff"); printf("Reboot has been launched, if it has no effect, please poweroff then poweron manually..\n"); } else { char Cmd[1000] = ""; vl_status = modemLstr_rcvResponse(0, (char**) &Cmd, 1000); /* send atcommand for modem loopback*/ //printf("prepare to send a modem command...\n"); memset(Cmd, 0, 1000); strncpy(Cmd, "AT*EAUR=3,0,3\r\n", strlen("AT*EAUR=3,0,3\r\n")); vl_status = modemLstr_sendCmd(0, Cmd, 1000); printf("AT*EAUR=3,0,3 has been send.\n"); /* check response */ memset(Cmd, 0, 1000); vl_status = modemLstr_rcvResponse(0, (char**) &Cmd, 1000); printf("Modem Response is: "); printf(Cmd); printf("\n"); system("/usr/local/bin/audio/AudioCallmpc_Headset.sh 0"); } } break; case TATAUDIO_MODEM_LOOP2: SYSLOG(LOG_INFO, "Stopping modem audio loop 2 ..."); /* */ break; default: TAT_SET_LAST_ERR(TAT_BAD_REQ); } } #endif RETURN_ERR(); }
blargg_err_t Kss_Emu::load_( Data_Reader& in ) { RETURN_ERR( core.load( in ) ); set_warning( core.warning() ); set_track_count( get_le16( header().last_track ) + 1 ); core.scc_enabled = false; if ( header().device_flags & 0x02 ) // Sega Master System { int const osc_count = Sms_Apu::osc_count + Opl_Apu::osc_count; static const char* const names [osc_count] = { "Square 1", "Square 2", "Square 3", "Noise", "FM" }; set_voice_names( names ); static int const types [osc_count] = { wave_type+1, wave_type+3, wave_type+2, mixed_type+1, wave_type+0 }; set_voice_types( types ); // sms.psg set_voice_count( Sms_Apu::osc_count ); check( !core.sms.psg ); CHECK_ALLOC( core.sms.psg = BLARGG_NEW Sms_Apu ); // sms.fm if ( header().device_flags & 0x01 ) { set_voice_count( osc_count ); RETURN_ERR( new_opl_apu( Opl_Apu::type_smsfmunit, &core.sms.fm ) ); } } else // MSX { int const osc_count = Ay_Apu::osc_count + Opl_Apu::osc_count; static const char* const names [osc_count] = { "Square 1", "Square 2", "Square 3", "FM" }; set_voice_names( names ); static int const types [osc_count] = { wave_type+1, wave_type+3, wave_type+2, wave_type+0 }; set_voice_types( types ); // msx.psg set_voice_count( Ay_Apu::osc_count ); check( !core.msx.psg ); CHECK_ALLOC( core.msx.psg = BLARGG_NEW Ay_Apu ); if ( header().device_flags & 0x10 ) set_warning( "MSX stereo not supported" ); // msx.music if ( header().device_flags & 0x01 ) { set_voice_count( osc_count ); RETURN_ERR( new_opl_apu( Opl_Apu::type_msxmusic, &core.msx.music ) ); } // msx.audio if ( header().device_flags & 0x08 ) { set_voice_count( osc_count ); RETURN_ERR( new_opl_apu( Opl_Apu::type_msxaudio, &core.msx.audio ) ); } if ( !(header().device_flags & 0x80) ) { if ( !(header().device_flags & 0x84) ) core.scc_enabled = core.scc_enabled_true; // msx.scc check( !core.msx.scc ); CHECK_ALLOC( core.msx.scc = BLARGG_NEW Scc_Apu ); int const osc_count = Ay_Apu::osc_count + Scc_Apu::osc_count; static const char* const names [osc_count] = { "Square 1", "Square 2", "Square 3", "Wave 1", "Wave 2", "Wave 3", "Wave 4", "Wave 5" }; set_voice_names( names ); static int const types [osc_count] = { wave_type+1, wave_type+3, wave_type+2, wave_type+0, wave_type+4, wave_type+5, wave_type+6, wave_type+7, }; set_voice_types( types ); set_voice_count( osc_count ); } } set_silence_lookahead( 6 ); if ( core.sms.fm || core.msx.music || core.msx.audio ) { if ( !Opl_Apu::supported() ) set_warning( "FM sound not supported" ); else set_silence_lookahead( 3 ); // Opl_Apu is really slow } return setup_buffer( ::clock_rate ); }
int set_key_cmd_cb(int numParam, char* buf, void* ctx) { struct wl_ssid_t ssid; struct wl_mac_addr_t bssid; uint8_t idx=0, len=0; char key[13], key_hex[27]; char keyIdx[2]; wl_err_t err = WL_SUCCESS; tParam* params = (tParam*) buf; INFO_SPI("%s params=%d\n", __FUNCTION__, numParam); // SSID memset(&ssid, 0, sizeof ssid); if (params->paramLen < WL_SSID_MAX_LENGTH) { memcpy(ssid.ssid, ¶ms->param, params->paramLen); ssid.len = params->paramLen; INFO_SPI("%s\n", ssid.ssid); } else { //printk("SSID len out of range"); RETURN_ERR(WL_FAILURE) } params = (tParam*)((char*)buf+PARAM_LEN_SIZE+params->paramLen); strncpy(keyIdx, (const char*)¶ms->param, params->paramLen); keyIdx[(uint8_t)params->paramLen]='\0'; idx = (uint8_t)atoi(keyIdx); // KEY IDX if ((params->paramLen != 1)||(idx < 0)||(idx > 3)){ //printk("KEY IDX out of range %d\n", idx); RETURN_ERR(WL_FAILURE) } params = (tParam*)((char*)params+PARAM_LEN_SIZE+params->paramLen); strncpy(key_hex, (const char*)¶ms->param, params->paramLen); key_hex[(uint8_t)params->paramLen]='\0'; len = ascii_to_key(key, key_hex); // KEY if (( len != 5)&&(len != 13)) { //printk("KEY len out of range %d", len); RETURN_ERR(WL_FAILURE) } #if 0 printk("KEY IDX = %d\n", idx); dump(key, len); printk("KEY len %d\n", len); #endif memset(&bssid.octet, 0xff, sizeof bssid.octet); wl_add_wep_key(idx, len, key, &bssid); //wl_set_auth_mode(AUTH_MODE_SHARED_KEY); wl_set_default_wep_key(idx); //Connect err = wl_cm_set_network(&ssid, NULL); if (err != 1) WARN("err=%d\n", err); RETURN_ERR(err) }
/* unlike nlopt_optimize() below, only handles minimization case */ static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf) { const double *lb, *ub; nlopt_algorithm algorithm; nlopt_func f; void *f_data; unsigned n, i; int ni; nlopt_stopping stop; if (!opt || !x || !minf || !opt->f || opt->maximize) RETURN_ERR(NLOPT_INVALID_ARGS, opt, "NULL args to nlopt_optimize_"); /* reset stopping flag */ nlopt_set_force_stop(opt, 0); opt->force_stop_child = NULL; /* copy a few params to local vars for convenience */ n = opt->n; ni = (int) n; /* most of the subroutines take "int" arg */ lb = opt->lb; ub = opt->ub; algorithm = opt->algorithm; f = opt->f; f_data = opt->f_data; if (n == 0) { /* trivial case: no degrees of freedom */ *minf = opt->f(n, x, NULL, opt->f_data); return NLOPT_SUCCESS; } *minf = HUGE_VAL; /* check bound constraints */ for (i = 0; i < n; ++i) if (lb[i] > ub[i] || x[i] < lb[i] || x[i] > ub[i]) { nlopt_set_errmsg(opt, "bounds %d fail %g <= %g <= %g", i, lb[i], x[i], ub[i]); return NLOPT_INVALID_ARGS; } stop.n = n; stop.minf_max = opt->stopval; stop.ftol_rel = opt->ftol_rel; stop.ftol_abs = opt->ftol_abs; stop.xtol_rel = opt->xtol_rel; stop.xtol_abs = opt->xtol_abs; stop.nevals = 0; stop.maxeval = opt->maxeval; stop.maxtime = opt->maxtime; stop.force_stop = &(opt->force_stop); stop.stop_msg = &(opt->errmsg); switch (algorithm) { case NLOPT_LD_SLSQP: return nlopt_slsqp(n, f, f_data, opt->m, opt->fc, opt->p, opt->h, lb, ub, x, minf, &stop); default: return NLOPT_INVALID_ARGS; } return NLOPT_SUCCESS; /* never reached */ }
blargg_err_t Ay_Emu::start_track_( int track ) { RETURN_ERR( Classic_Emu::start_track_( track ) ); byte* const mem = core.mem(); memset( mem + 0x0000, 0xC9, 0x100 ); // fill RST vectors with RET memset( mem + 0x0100, 0xFF, 0x4000 - 0x100 ); memset( mem + core.ram_addr, 0x00, core.mem_size - core.ram_addr ); // locate data blocks byte const* const data = get_data( file, file.tracks + track * 4 + 2, 14 ); if ( !data ) return BLARGG_ERR( BLARGG_ERR_FILE_CORRUPT, "file data missing" ); byte const* const more_data = get_data( file, data + 10, 6 ); if ( !more_data ) return BLARGG_ERR( BLARGG_ERR_FILE_CORRUPT, "file data missing" ); byte const* blocks = get_data( file, data + 12, 8 ); if ( !blocks ) return BLARGG_ERR( BLARGG_ERR_FILE_CORRUPT, "file data missing" ); // initial addresses unsigned addr = get_be16( blocks ); if ( !addr ) return BLARGG_ERR( BLARGG_ERR_FILE_CORRUPT, "file data missing" ); unsigned init = get_be16( more_data + 2 ); if ( !init ) init = addr; // copy blocks into memory do { blocks += 2; unsigned len = get_be16( blocks ); blocks += 2; if ( addr + len > core.mem_size ) { set_warning( "Bad data block size" ); len = core.mem_size - addr; } check( len ); byte const* in = get_data( file, blocks, 0 ); blocks += 2; if (!in) { break; } if ( len > (unsigned) (file.end - in) ) { set_warning( "File data missing" ); len = file.end - in; } //dprintf( "addr: $%04X, len: $%04X\n", addr, len ); if ( addr < core.ram_addr && addr >= 0x400 ) // several tracks use low data dprintf( "Block addr in ROM\n" ); memcpy( mem + addr, in, len ); if ( file.end - blocks < 8 ) { set_warning( "File data missing" ); break; } } while ( (addr = get_be16( blocks )) != 0 ); // copy and configure driver static byte const passive [] = { 0xF3, // DI 0xCD, 0, 0, // CALL init 0xED, 0x5E, // LOOP: IM 2 0xFB, // EI 0x76, // HALT 0x18, 0xFA // JR LOOP }; static byte const active [] = { 0xF3, // DI 0xCD, 0, 0, // CALL init 0xED, 0x56, // LOOP: IM 1 0xFB, // EI 0x76, // HALT 0xCD, 0, 0, // CALL play 0x18, 0xF7 // JR LOOP }; memcpy( mem, passive, sizeof passive ); int const play_addr = get_be16( more_data + 4 ); if ( play_addr ) { memcpy( mem, active, sizeof active ); mem [ 9] = play_addr; mem [10] = play_addr >> 8; } mem [2] = init; mem [3] = init >> 8; mem [0x38] = 0xFB; // Put EI at interrupt vector (followed by RET) // start at spectrum speed change_clock_rate( spectrum_clock ); set_tempo( tempo() ); Ay_Core::registers_t r = { }; r.sp = get_be16( more_data ); r.b.a = r.b.b = r.b.d = r.b.h = data [8]; r.b.flags = r.b.c = r.b.e = r.b.l = data [9]; r.alt.w = r.w; r.ix = r.iy = r.w.hl; core.start_track( r, play_addr ); return blargg_ok; }
blargg_err_t Gme_File::track_info( track_info_t* out, int track ) const { out->track_count = track_count(); out->length = -1; out->loop_length = -1; out->intro_length = -1; out->fade_length = -1; out->play_length = -1; out->repeat_count = -1; out->song [0] = 0; out->game [0] = 0; out->author [0] = 0; out->composer [0] = 0; out->engineer [0] = 0; out->sequencer [0] = 0; out->tagger [0] = 0; out->copyright [0] = 0; out->date [0] = 0; out->comment [0] = 0; out->dumper [0] = 0; out->system [0] = 0; out->disc [0] = 0; out->track [0] = 0; out->ost [0] = 0; copy_field_( out->system, type()->system ); int remapped = track; RETURN_ERR( remap_track_( &remapped ) ); RETURN_ERR( track_info_( out, remapped ) ); // override with m3u info if ( playlist.size() ) { M3u_Playlist::info_t const& i = playlist.info(); copy_field_( out->game , i.title ); copy_field_( out->author , i.artist ); copy_field_( out->engineer , i.engineer ); copy_field_( out->composer , i.composer ); copy_field_( out->sequencer, i.sequencer ); copy_field_( out->copyright, i.copyright ); copy_field_( out->dumper , i.ripping ); copy_field_( out->tagger , i.tagging ); copy_field_( out->date , i.date ); M3u_Playlist::entry_t const& e = playlist [track]; if ( e.length >= 0 ) out->length = e.length; if ( e.intro >= 0 ) out->intro_length = e.intro; if ( e.loop >= 0 ) out->loop_length = e.loop; if ( e.fade >= 0 ) out->fade_length = e.fade; if ( e.repeat >= 0 ) out->repeat_count = e.repeat; copy_field_( out->song, e.name ); } // play_length out->play_length = out->length; if ( out->play_length <= 0 ) { out->play_length = out->intro_length + 2 * out->loop_length; // intro + 2 loops if ( out->play_length <= 0 ) out->play_length = 150 * 1000; // 2.5 minutes } return blargg_ok; }