# HG changeset patch # User Matti Hamalainen # Date 1368069532 -10800 # Node ID d345a898bda116965077a1b7ca236b1d08ccc406 # Parent d7bd9c11229e51d3d822ff14d3a7f50fa4743f06 Use DMMutex and the appropriate function wrappers. diff -r d7bd9c11229e -r d345a898bda1 tools/auval.c --- a/tools/auval.c Thu May 09 06:08:39 2013 +0300 +++ b/tools/auval.c Thu May 09 06:18:52 2013 +0300 @@ -35,7 +35,7 @@ int avail, bufsize, pos, oldpos; Uint8 *buf; - SDL_mutex *mutex; + DMMutex *mutex; } AUAudioData; @@ -389,7 +389,7 @@ const int xend = x1 * bpp; const float scale = 128.0f / (float) height; - SDL_LockMutex(data->mutex); + dmMutexLock(data->mutex); Uint8 *dp = data->buf, *sp = screen->pixels; @@ -400,7 +400,7 @@ sp[x + curr * pitch] = 255; } - SDL_UnlockMutex(data->mutex); + dmMutexUnlock(data->mutex); } @@ -409,7 +409,7 @@ int y; Uint8 *p = (Uint8 *) screen->pixels; - SDL_LockMutex(data->mutex); + dmMutexLock(data->mutex); Uint8 *dp = data->buf; @@ -422,7 +422,7 @@ p += screen->pitch - screen->w; } - SDL_UnlockMutex(data->mutex); + dmMutexUnlock(data->mutex); } @@ -553,7 +553,7 @@ { AUAudioData *data = (AUAudioData *) udata; - SDL_LockMutex(data->mutex); + dmMutexLock(data->mutex); data->avail = 0; @@ -600,7 +600,7 @@ memset(buf, 0, len); } - SDL_UnlockMutex(data->mutex); + dmMutexUnlock(data->mutex); } @@ -699,7 +699,7 @@ audata.bufsize = optAudioFreq; audata.buf = dmMalloc(audata.bufsize * sizeof(*audata.buf)); - audata.mutex = SDL_CreateMutex(); + audata.mutex = dmCreateMutex(); audata.varTime = 0; audata.varKeyFreq = 1.0f / (double) optAudioFreq; @@ -918,13 +918,13 @@ /* In keyboard jazz-mode, space stops playing */ if (key == SDLK_SPACE) { - SDL_LockMutex(audata.mutex); + dmMutexLock(audata.mutex); audata.varFreq = 1.0f; audata.pos = 0; audata.varTime = 0; audata.varKeyTime = 0; audata.varUnit = 0; - SDL_UnlockMutex(audata.mutex); + dmMutexUnlock(audata.mutex); audioPlaying = FALSE; SDL_PauseAudio(!audioPlaying); @@ -939,13 +939,13 @@ period = 7680 - (note * 64) - (/* finetune */ 128 / 2); if (period < 1) period = 1; - SDL_LockMutex(audata.mutex); + dmMutexLock(audata.mutex); audata.varFreq = 8363.0f * pow(2.0f, (4608.0f - (double) period) / 768.0f) / optAudioFreq ; audata.pos = 0; audata.varTime = 0; audata.varKeyTime = 0; audata.varUnit = 0; - SDL_UnlockMutex(audata.mutex); + dmMutexUnlock(audata.mutex); audioPlaying = TRUE; SDL_PauseAudio(!audioPlaying); @@ -1002,7 +1002,7 @@ editBuf->dirty = FALSE; editBuf->data[editBuf->len] = 0; - SDL_LockMutex(audata.mutex); + dmMutexLock(audata.mutex); dm_eval_free(audata.expr); DMEvalNode *tmp = NULL; @@ -1023,7 +1023,7 @@ audata.varKeyTime = 0; audata.varUnit = 0; - SDL_UnlockMutex(audata.mutex); + dmMutexUnlock(audata.mutex); } /* Check if visualizer needs redrawing @@ -1097,7 +1097,7 @@ /* Draw the function editor box */ if (needRedraw & REDRAW_EDITOR) { - SDL_LockMutex(audata.mutex); + dmMutexLock(audata.mutex); dmFillBox3D(screen, 0, eh - 15, screen->w - 1, screen->h - 1, audata.err ? dmMapRGB(screen, 255, 0, 0) : dmMapRGB(screen, 0, 128, 64), @@ -1109,7 +1109,7 @@ if (audata.errStr != NULL) dmDrawTTFTextConst(screen, font, fontcol, 5, screen->h - fh, audata.errStr); - SDL_UnlockMutex(audata.mutex); + dmMutexUnlock(audata.mutex); } if (SDL_MUSTLOCK(screen) != 0) @@ -1126,16 +1126,13 @@ au_save_history(AUVAL_HISTORY_FILE, histBuf, histMax); error_exit: - if (screen) - SDL_FreeSurface(screen); - if (font) TTF_CloseFont(font); if (audioPlaying) SDL_PauseAudio(1); - SDL_DestroyMutex(audata.mutex); + dmDestroyMutex(audata.mutex); if (initSDL) SDL_Quit();