Ejemplo n.º 1
0
  /* Look at this class and it's superclass contents (which includes
   * included modules) and calculate out how to allocate the slots.
   *
   * This locks the class so that construction is serialized.
   */
  void Class::auto_pack(STATE) {
    hard_lock(state);

    // If another thread did this work while we were waiting on the lock,
    // don't redo it.
    if(type_info_->type == PackedObject::type) return;

    size_t slots = 0;

    LookupTable* lt = LookupTable::create(state);

    // If autopacking is enabled, figure out how many slots to use.
    if(state->shared.config.gc_autopack) {
      Module* mod = this;

      int slot = 0;

      while(!mod->nil_p()) {
        Array* info = 0;

        if(Class* cls = try_as<Class>(mod)) {
          info = cls->seen_ivars();
        } else if(IncludedModule* im = try_as<IncludedModule>(mod)) {
          info = im->module()->seen_ivars();
        }

        if(info && !info->nil_p()) {
          for(size_t i = 0; i < info->size(); i++) {
            if(Symbol* sym = try_as<Symbol>(info->get(state, i))) {
              bool found = false;
              lt->fetch(state, sym, &found);

              if(!found) {
                lt->store(state, sym, Fixnum::from(slot++));
              }
            }

            // Limit the number of packed ivars to 25.
            if(slot > 25) break;
          }
        }

        mod = mod->superclass();
      }
      slots = lt->entries()->to_native();
    }

    packed_size_ = sizeof(Object) + (slots * sizeof(Object*));
    packed_ivar_info(state, lt);

    set_object_type(state, PackedObject::type);

    hard_unlock(state);
  }
Ejemplo n.º 2
0
  Object* Class::set_packed(STATE, Array* info) {
    // Only transition Object typed objects to Packed
    if(type_info_->type != Object::type) return Fixnum::from(1);

    // Reject methods that already have packing.
    if(packed_size_) return Fixnum::from(2);

    LookupTable* lt = LookupTable::create(state);

    size_t s = info->size();
    for(size_t i = 0; i < s; i++) {
      Symbol* sym = as<Symbol>(info->get(state, i));
      lt->store(state, sym, Fixnum::from(i));
    }

    packed_size_ = sizeof(Object) + (s * sizeof(Object*));
    packed_ivar_info(state, lt);

    set_object_type(state, PackedObject::type);

    return Qtrue;
  }
Ejemplo n.º 3
0
BOOL CALLBACK QCProc(HWND hwndDlg, UINT message, 
                     WPARAM wParam, LPARAM lParam) 
{
	switch (message) 
	{ 
		case WM_INITDIALOG: 
 
			if(iniSettings.decode_mode == 0)
			{
				CheckDlgButton(hwndDlg,IDC_PLAYBACK,TRUE);
				CheckDlgButton(hwndDlg,IDC_WAV,TRUE);
				if(iniSettings.outputFormat != 1
					&& iniSettings.outputFormat != 5
					&& iniSettings.outputFormat != 6
					&& iniSettings.outputFormat != 7
					&& iniSettings.outputFormat != 8)
					CheckDlgButton(hwndDlg,IDC_16BIT,TRUE);
				else if(iniSettings.outputFormat == 1)
					CheckDlgButton(hwndDlg,IDC_16BIT,TRUE);
				else if(iniSettings.outputFormat == 5)
					CheckDlgButton(hwndDlg,IDC_16BIT_DITHER,TRUE);
				else if(iniSettings.outputFormat == 6)
					CheckDlgButton(hwndDlg,IDC_16BIT_L_SHAPE,TRUE);
				else if(iniSettings.outputFormat == 7)
					CheckDlgButton(hwndDlg,IDC_16BIT_M_SHAPE,TRUE);
				else if(iniSettings.outputFormat == 8)
					CheckDlgButton(hwndDlg,IDC_16BIT_H_SHAPE,TRUE);
				CheckDlgButton(hwndDlg,IDC_WAV,TRUE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_AIFF), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_SUNAU), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_DECAU), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_24BIT), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_32BIT), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_FLOATS), FALSE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT), TRUE);
				EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_DITHER), TRUE);
			}
			else if(iniSettings.decode_mode == 1)
			{
				CheckDlgButton(hwndDlg,IDC_PLAYBACK,FALSE);
				if(iniSettings.outputFormat == 1)
					CheckDlgButton(hwndDlg,IDC_16BIT,TRUE);
				else if(iniSettings.outputFormat == 2)
					CheckDlgButton(hwndDlg,IDC_24BIT,TRUE);
				else if(iniSettings.outputFormat == 3)
					CheckDlgButton(hwndDlg,IDC_32BIT,TRUE);
				else if(iniSettings.outputFormat == 4)
					CheckDlgButton(hwndDlg,IDC_FLOATS,TRUE);
				else if(iniSettings.outputFormat == 5)
					CheckDlgButton(hwndDlg,IDC_16BIT_DITHER,TRUE);
				else if(iniSettings.outputFormat == 6)
					CheckDlgButton(hwndDlg,IDC_16BIT_L_SHAPE,TRUE);
				else if(iniSettings.outputFormat == 7)
					CheckDlgButton(hwndDlg,IDC_16BIT_M_SHAPE,TRUE);
				else if(iniSettings.outputFormat == 8)
					CheckDlgButton(hwndDlg,IDC_16BIT_H_SHAPE,TRUE);

				if(iniSettings.fileType == 1)
					CheckDlgButton(hwndDlg,IDC_WAV,TRUE);
				else if(iniSettings.fileType == 2)
					CheckDlgButton(hwndDlg,IDC_AIFF,TRUE);
				else if(iniSettings.fileType == 3)
					CheckDlgButton(hwndDlg,IDC_SUNAU,TRUE);
				else if(iniSettings.fileType == 4)
					CheckDlgButton(hwndDlg,IDC_DECAU,TRUE);
			}

			if(iniSettings.object_type == 0)
				CheckDlgButton(hwndDlg,IDC_MAIN,TRUE);
			else if(iniSettings.object_type == 1)
				CheckDlgButton(hwndDlg,IDC_LC,TRUE);
			else if(iniSettings.object_type == 3)
				CheckDlgButton(hwndDlg,IDC_LTP,TRUE);
			else if(iniSettings.object_type == 23)
				CheckDlgButton(hwndDlg,IDC_LD,TRUE);
			break;

		case WM_CLOSE:
			EndDialog(hwndDlg, -1);
			break;

		case WM_COMMAND: 
			switch (LOWORD(wParam)) 
			{
				case IDC_BUTTON1:
				{
					if (IsDlgButtonChecked(hwndDlg, IDC_PLAYBACK) == BST_CHECKED)
						set_decode_mode(0);            // Playback
					else if (IsDlgButtonChecked(hwndDlg, IDC_DECODE) == BST_CHECKED)
						set_decode_mode(1);            // Decode to File

					if (IsDlgButtonChecked(hwndDlg, IDC_WAV) == BST_CHECKED)
						set_fileType(1);             // Microsoft WAV
					else if (IsDlgButtonChecked(hwndDlg, IDC_AIFF) == BST_CHECKED)
						set_fileType(2);             // Apple/SGI AIFF
					else if (IsDlgButtonChecked(hwndDlg, IDC_SUNAU) == BST_CHECKED)
						set_fileType(3);             // Sun/NeXT AU
					else if (IsDlgButtonChecked(hwndDlg, IDC_DECAU) == BST_CHECKED)
						set_fileType(4);             // DEC AU

					if (IsDlgButtonChecked(hwndDlg, IDC_16BIT) == BST_CHECKED)
						set_outputFormat(1);             // 16 bit PCM
					else if (IsDlgButtonChecked(hwndDlg, IDC_24BIT) == BST_CHECKED)
						set_outputFormat(2);             // 24 bit PCM
					else if (IsDlgButtonChecked(hwndDlg, IDC_32BIT) == BST_CHECKED)
						set_outputFormat(3);             // 32 bit PCM
					else if (IsDlgButtonChecked(hwndDlg, IDC_FLOATS) == BST_CHECKED)
						set_outputFormat(4);             // 32 bit floats
					else if (IsDlgButtonChecked(hwndDlg, IDC_16BIT_DITHER) == BST_CHECKED)
						set_outputFormat(5);             // 16 bit PCM dithered
					else if (IsDlgButtonChecked(hwndDlg, IDC_16BIT_L_SHAPE) == BST_CHECKED)
						set_outputFormat(6);             // dithered LIGHT noise shaping
					else if (IsDlgButtonChecked(hwndDlg, IDC_16BIT_M_SHAPE) == BST_CHECKED)
						set_outputFormat(7);             // dithered MEDIUM noise shaping
					else if (IsDlgButtonChecked(hwndDlg, IDC_16BIT_H_SHAPE) == BST_CHECKED)
						set_outputFormat(8);             // dithered HEAVY noise shaping

					if (IsDlgButtonChecked(hwndDlg, IDC_MAIN) == BST_CHECKED)
						set_object_type(0);             // Main
					else if (IsDlgButtonChecked(hwndDlg, IDC_LC) == BST_CHECKED)
						set_object_type(1);             // Low Complexity
					else if (IsDlgButtonChecked(hwndDlg, IDC_LTP) == BST_CHECKED)
						set_object_type(3);             // Long Term Prediction
					else if (IsDlgButtonChecked(hwndDlg, IDC_LD) == BST_CHECKED)
						set_object_type(23);            // Low Delay

					EndDialog(hwndDlg, -2);
					return TRUE;
				}
				case IDC_BUTTON6:
					EndDialog(hwndDlg, -7);
					return TRUE;

				case IDC_PLAYBACK:
					CheckDlgButton(hwndDlg,IDC_WAV,TRUE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_AIFF), FALSE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_SUNAU), FALSE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_DECAU), FALSE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_24BIT), FALSE);
					CheckDlgButton(hwndDlg,IDC_24BIT,FALSE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_32BIT), FALSE);
					CheckDlgButton(hwndDlg,IDC_32BIT,FALSE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_FLOATS), FALSE);
					CheckDlgButton(hwndDlg,IDC_FLOATS,FALSE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT), TRUE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_DITHER), TRUE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_L_SHAPE), TRUE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_M_SHAPE), TRUE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_H_SHAPE), TRUE);
					if (IsDlgButtonChecked(hwndDlg, IDC_16BIT_DITHER) != BST_CHECKED
						&& IsDlgButtonChecked(hwndDlg, IDC_16BIT_L_SHAPE) != BST_CHECKED
						&& IsDlgButtonChecked(hwndDlg, IDC_16BIT_M_SHAPE) != BST_CHECKED
						&& IsDlgButtonChecked(hwndDlg, IDC_16BIT_H_SHAPE) != BST_CHECKED)
						CheckDlgButton(hwndDlg,IDC_16BIT,TRUE);
					break;
				case IDC_DECODE:
					EnableWindow(GetDlgItem(hwndDlg, IDC_AIFF), FALSE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_SUNAU), FALSE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_DECAU), FALSE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_24BIT), TRUE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_32BIT), TRUE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_FLOATS), TRUE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT), TRUE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_DITHER), TRUE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_L_SHAPE), TRUE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_M_SHAPE), TRUE);
					EnableWindow(GetDlgItem(hwndDlg, IDC_16BIT_H_SHAPE), TRUE);
					break;
				default:
					break;
       	  		}
	}
	return FALSE; 
}
Ejemplo n.º 4
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
	static char szAppName[] = "aacDECdrop";
	HWND hwnd;
	MSG msg;
	WNDCLASS wndclass;
	const int width = 130;
	const int height = 130;
	int x;
	int y;

	hinst = hInstance;

	wndclass.style = CS_HREDRAW | CS_VREDRAW;
	wndclass.lpfnWndProc = WndProc;
	wndclass.cbClsExtra = 0;
	wndclass.cbWndExtra = 0;
	wndclass.hInstance = hInstance;
	wndclass.hIcon = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON1));
	wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
	wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wndclass.lpszMenuName = NULL;
	wndclass.lpszClassName = szAppName;

	RegisterClass(&wndclass);

	GetAACdecSettings();

	x = max(min(iniSettings.window_x, GetSystemMetrics(SM_CXSCREEN) - width), 0);
	y = max(min(iniSettings.window_y, GetSystemMetrics(SM_CYSCREEN) - height), 0);

	hwnd = CreateWindow(szAppName, "aacDECdrop", WS_POPUP | WS_DLGFRAME, x, y,
	width, height, NULL, NULL, hInstance, NULL);

	g_hwnd = hwnd;

	ShowWindow(hwnd, iCmdShow);
	UpdateWindow(hwnd);

	font2 = CREATEFONT(10);

	SetTimer(hwnd, 1, 80, NULL);

	set_always_on_top(hwnd, iniSettings.always_on_top);
	set_logerr(hwnd, iniSettings.logerr);
	set_decode_mode(iniSettings.decode_mode);
	set_outputFormat(iniSettings.outputFormat);
	set_fileType(iniSettings.fileType);
	set_object_type(iniSettings.object_type);
	
	for (frame = 0; frame < 8; frame++)
		hbm[frame] = LoadImage(hinst, MAKEINTRESOURCE(IDB_TF01 + frame), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
	frame = 0;

	while (GetMessage(&msg, NULL, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	for (frame = 0; frame < 8; frame++) 
		DeleteObject(hbm[frame]);

	return msg.wParam;
}