Пример #1
0
static void _al_xsys_xinerama_init(ALLEGRO_SYSTEM_XGLX *s)
{
   int event_base = 0;
   int error_base = 0;

   /* init xinerama info to defaults */
   s->xinerama_available = 0;
   s->xinerama_screen_count = 0;
   s->xinerama_screen_info = NULL;

   _al_mutex_lock(&s->lock);

   if (XineramaQueryExtension(s->x11display, &event_base, &error_base)) {
      int minor_version = 0, major_version = 0;
      int status = XineramaQueryVersion(s->x11display, &major_version, &minor_version);
      ALLEGRO_INFO("Xinerama version: %i.%i\n", major_version, minor_version);

      if (status && !XineramaIsActive(s->x11display)) {
         ALLEGRO_WARN("Xinerama is not active\n");
      }
      else {
         ALLEGRO_INFO("Xinerama is active\n");
         s->xinerama_available = 1;
      }
   }
   else {
      ALLEGRO_WARN("Xinerama extension is not available.\n");
   }

   _al_mutex_unlock(&s->lock);
}
Пример #2
0
static HWND get_window()
{
   const char *val = al_get_config_value(al_get_system_config(),
      "directsound", "window");
   HWND ret;
   if (val && strncmp(val, "foreground", 10) == 0) {
      ret = GetForegroundWindow();
      ALLEGRO_INFO("Using foreground window: %p\n", ret);
   }
   else {
      ret = GetDesktopWindow();
      ALLEGRO_INFO("Using desktop window: %p\n", ret);
   }
   return ret;
}
Пример #3
0
static void xfvm_store_video_mode(ALLEGRO_SYSTEM_XGLX *s)
{
    int n;

    ALLEGRO_DEBUG("xfullscreen: xfvm_store_video_mode\n");

#ifdef ALLEGRO_XWINDOWS_WITH_XINERAMA
    /* TwinView workarounds, nothing to do here, since we can't really change or restore modes */
    if (s->xinerama_available && s->xinerama_screen_count != s->xfvm_screen_count) {
        return;
    }
#endif

    // save all original modes
    int i;
    for (i = 0; i < s->xfvm_screen_count; i++) {
        n = xfvm_get_num_modes(s, i);
        if (n == 0) {
            /* XXX what to do here? */
            continue;
        }

        s->xfvm_screen[i].original_mode = s->xfvm_screen[i].modes[0];

        int j;
        for (j = 0; j <  s->xfvm_screen[i].mode_count; j++) {
            ALLEGRO_DEBUG("xfvm: screen[%d] mode[%d] = (%d, %d)\n",
                          i, j, s->xfvm_screen[i].modes[j]->hdisplay, s->xfvm_screen[i].modes[j]->vdisplay);
        }
        ALLEGRO_INFO("xfvm: screen[%d] original mode = (%d, %d)\n",
                     i, s->xfvm_screen[i].original_mode->hdisplay, s->xfvm_screen[i].original_mode->vdisplay);
    }
}
Пример #4
0
static bool init_touch_input(void)
{
   unsigned i;
   ALLEGRO_SYSTEM* system;

   if (installed)
      return false;

   if (!_al_win_init_touch_input_api())
      return false;

   memset(&touch_input_state, 0, sizeof(touch_input_state));

   _al_event_source_init(&touch_input.es);
   _al_event_source_init(&touch_input.mouse_emulation_es);

   touch_input.mouse_emulation_mode = ALLEGRO_MOUSE_EMULATION_TRANSPARENT;

   installed = true;

   system = al_get_system_driver();
   for (i = 0; i < _al_vector_size(&system->displays); ++i) {
      bool r;
      ALLEGRO_DISPLAY_WIN *win_display = *((ALLEGRO_DISPLAY_WIN**)_al_vector_ref(&system->displays, i));
      r = _al_win_register_touch_window(win_display->window, 0);
	  ALLEGRO_INFO("registering touch window %p: %d\n", win_display, r);
	  if (!r) {
		 ALLEGRO_ERROR("RegisterTouchWindow failed: %s\n", get_error_desc(GetLastError()));
	     return false;
	  }
   }

   return true;
}
Пример #5
0
static HMODULE load_library_at_path(const char *path_str)
{
    HMODULE lib;

    /*
     * XXX LoadLibrary will search the current directory for any dependencies of
     * the library we are loading.  Using LoadLibraryEx with the appropriate
     * flags would fix that, but when I tried it I was unable to load dsound.dll
     * on Vista.
     */

    ALLEGRO_DEBUG("Calling LoadLibrary %s\n", path_str);
    lib = LoadLibraryA(path_str);
    if (lib) {
        ALLEGRO_INFO("Loaded %s\n", path_str);
    }
    else {
        DWORD error = GetLastError();
        HRESULT hr = HRESULT_FROM_WIN32(error);
        /* XXX do something with it */
        (void)hr;
        ALLEGRO_WARN("Failed to load %s (error: %ld)\n", path_str, error);
    }

    return lib;
}
Пример #6
0
/* The close method should close the device, freeing any resources, and allow
   other processes to use the device */
static void _dsound_close()
{
   ALLEGRO_DEBUG("Releasing device\n");
   device->Release();
   ALLEGRO_DEBUG("Released device\n");
   ALLEGRO_INFO("DirectSound closed\n");
}
Пример #7
0
void _al_iphone_setup_opengl_view(ALLEGRO_DISPLAY *d)
{
    int w, h;
    _al_iphone_get_screen_size(&w, &h);
    _al_iphone_reset_framebuffer();
    glViewport(0, 0, w, h);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    
    glOrthof(0, w, h, 0, -1, 1);
    
    _screen_w = w;
    _screen_h = h;

    /* We automatically adjust the view if the user doesn't use 320x480. Users
     * of the iphone port are adviced to provide a 320x480 mode and do their
     * own adjustment - but for the sake of allowing ports without knowing
     * any OpenGL and not having to change a single character in your
     * application - here you go.
     */
    if (d->w != w || d->h != h) {
       double scale = 1, xoff = 0, yoff = 0;
       if (d->w >= d->h) {
          if (d->w * w > d->h * h) {
             scale = h * 1.0 / d->w;
             xoff = (w - d->h * scale) * 0.5;
             _screen_y = 0.5 * (d->h - w / scale);
          }
          else {
             scale = w * 1.0 / d->h;
             yoff = (h - d->w * scale) * 0.5;
             _screen_x = 0.5 * (d->w - h / scale);
          }

          glTranslatef(xoff, yoff, 0); 
          glTranslatef(w, 0, 0);
          glRotatef(90, 0, 0, 1);
          glScalef(scale, scale, 1);
       }
       else {
          // TODO
       }
        
       if (!_screen_hack) {
           _screen_hack = true;
           _screen_scale = scale;
           _screen_iscale = 1.0 / _screen_scale;
           
           ALLEGRO_INFO("Auto-scaling/rotating %dx%d display to %.fx%.f screen.\n",
                        d->w, d->h, _screen_w, _screen_h);
           ALLEGRO_DEBUG("x-off:%.f y-off:%.f scale:%.2f\n", _screen_x,
                         _screen_y, _screen_scale);
        }
    }

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}
Пример #8
0
/* The stop_voice method should stop playback. For non-streaming voices, it
   should leave the data loaded, and reset the voice position to 0. */
static int _dsound_stop_voice(ALLEGRO_VOICE* voice)
{
   ALLEGRO_DS_DATA *ex_data = (ALLEGRO_DS_DATA *)voice->extra;

   ALLEGRO_DEBUG("Stopping voice\n");

   if (!ex_data->ds8_buffer) {
      ALLEGRO_ERROR("Trying to stop empty voice buffer\n");
      return 1;
   }

   /* if playing a sample */
   if (!voice->is_streaming) {
      ALLEGRO_DEBUG("Stopping non-streaming voice\n");
      ex_data->ds8_buffer->Stop();
      ex_data->ds8_buffer->SetCurrentPosition(0);
      ALLEGRO_INFO("Non-streaming voice stopped\n");
      return 0;
   }

   if (ex_data->stop_voice == 0) {
      ALLEGRO_DEBUG("Joining thread\n");
      ex_data->stop_voice = 1;
      while (ex_data->stop_voice == 1) {
	  al_wait_cond(voice->cond, voice->mutex);
      }
      al_join_thread(ex_data->thread, NULL);
      ALLEGRO_DEBUG("Joined thread\n");

      ALLEGRO_DEBUG("Destroying thread\n");
      al_destroy_thread(ex_data->thread);
      ALLEGRO_DEBUG("Thread destroyed\n");
      /* This is required to restart the background thread when the voice
       * restarts.
       */
      ex_data->stop_voice = 1;
   }

   ALLEGRO_DEBUG("Releasing buffer\n");
   ex_data->ds8_buffer->Release();
   ex_data->ds8_buffer = NULL;

   ALLEGRO_INFO("Voice stopped\n");
   return 0;
}
Пример #9
0
/* This is called from the termination message - it has to return soon as the
 * user expects the app to close when it is closed.
 */
void _al_iphone_await_termination(void)
{
    ALLEGRO_INFO("Application awaiting termination.\n");
    al_lock_mutex(iphone->mutex);
    while (!iphone->has_shutdown) {
        al_wait_cond(iphone->cond, iphone->mutex);
    }
    al_unlock_mutex(iphone->mutex);
}
/* The close method should close the device, freeing any resources, and allow
   other processes to use the device */
static void _dsound_close()
{
   ALLEGRO_DEBUG("Releasing device\n");
   device->Release();
   ALLEGRO_DEBUG("Released device\n");

   _al_close_library(_al_dsound_module);
   ALLEGRO_INFO("DirectSound closed\n");
}
Пример #11
0
static int query_glx_version(ALLEGRO_SYSTEM_XGLX *system)
{
   int major, minor;
   int version;

   glXQueryVersion(system->x11display, &major, &minor);
   version = major * 100 + minor * 10;
   ALLEGRO_INFO("GLX %.1f.\n", version / 100.f);
   return version;
}
Пример #12
0
static ALLEGRO_DISPLAY* wgl_create_display(int w, int h)
{
   ALLEGRO_SYSTEM_WIN *system = (ALLEGRO_SYSTEM_WIN *)al_get_system_driver();
   ALLEGRO_DISPLAY_WGL **add;
   ALLEGRO_DISPLAY_WGL *wgl_display = al_calloc(1, sizeof *wgl_display);
   ALLEGRO_DISPLAY *ogl_display = (void*)wgl_display;
   ALLEGRO_DISPLAY     *display     = (void*)ogl_display;
   ALLEGRO_DISPLAY_WIN *win_disp = (ALLEGRO_DISPLAY_WIN *)display;

   win_disp->adapter = _al_win_determine_adapter();

   display->w = w;
   display->h = h;
   display->refresh_rate = al_get_new_display_refresh_rate();
   display->flags = al_get_new_display_flags();
   display->vt = &vt;

   display->ogl_extras = al_calloc(1, sizeof(ALLEGRO_OGL_EXTRAS));

   if (!create_display_internals(wgl_display)) {
      al_free(display->ogl_extras);
      al_free(display);
      return NULL;
   }

   /* Print out OpenGL version info */
   ALLEGRO_INFO("OpenGL Version: %s\n", (const char*)glGetString(GL_VERSION));
   ALLEGRO_INFO("Vendor: %s\n", (const char*)glGetString(GL_VENDOR));
   ALLEGRO_INFO("Renderer: %s\n\n", (const char*)glGetString(GL_RENDERER));

   /* Add ourself to the list of displays. */
   add = _al_vector_alloc_back(&system->system.displays);
   *add = wgl_display;

   /* Each display is an event source. */
   _al_event_source_init(&display->es);

   _al_win_set_system_mouse_cursor(display, ALLEGRO_SYSTEM_MOUSE_CURSOR_ARROW);
   _al_win_show_mouse_cursor(display);

   return display;
}
Пример #13
0
/* Function: al_resize_display
 */
bool al_resize_display(ALLEGRO_DISPLAY *display, int width, int height)
{
   ASSERT(display);
   ASSERT(display->vt);

   ALLEGRO_INFO("Requested display resize %dx%d\n", width, height);

   if (display->vt->resize_display) {
      return display->vt->resize_display(display, width, height);
   }
   return false;
}
Пример #14
0
/* The open method starts up the driver and should lock the device, using the
   previously set paramters, or defaults. It shouldn't need to start sending
   audio data to the device yet, however. */
static int _openal_open(void)
{
   ALenum openal_err;
   ALCenum alc_err;

   ALLEGRO_INFO("Starting OpenAL\n");

   /* clear the error state */
   openal_err = alGetError();

   /* pick default device. always a good choice */
   openal_dev = alcOpenDevice(NULL);

   alc_err = ALC_NO_ERROR;
   if (!openal_dev || (alc_err = alcGetError(openal_dev)) != ALC_NO_ERROR) {
      ALLEGRO_ERROR("Could not open audio device: %s\n",
         alc_get_err_str(alc_err));
      return 1;
   }

   openal_context = alcCreateContext(openal_dev, NULL);
   alc_err = ALC_NO_ERROR;
   if (!openal_context || (alc_err = alcGetError(openal_dev)) != ALC_NO_ERROR) {
      ALLEGRO_ERROR("Could not create current device context: %s\n",
         alc_get_err_str(alc_err));
      return 1;
   }

   alcMakeContextCurrent(openal_context);
#if !defined ALLEGRO_IPHONE
   if ((alc_err = alcGetError(openal_dev)) != ALC_NO_ERROR) {
      ALLEGRO_ERROR("Could not make context current: %s\n",
         alc_get_err_str(alc_err));
      return 1;
   }

   alDistanceModel(AL_NONE);
   if ((openal_err = alGetError()) != AL_NO_ERROR) {
      ALLEGRO_ERROR("Could not set distance model: %s\n",
         openal_get_err_str(openal_err));
      return 1;
   }
#endif

   ALLEGRO_DEBUG("Vendor: %s\n", alGetString(AL_VENDOR));
   ALLEGRO_DEBUG("Version: %s\n", alGetString(AL_VERSION));
   ALLEGRO_DEBUG("Renderer: %s\n", alGetString(AL_RENDERER));
   ALLEGRO_DEBUG("Extensions: %s\n", alGetString(AL_EXTENSIONS));

   return 0;
}
Пример #15
0
/* ljoy_init_joystick: [primary thread]
 *  Initialise the joystick driver.
 */
static bool ljoy_init_joystick(void)
{
    _al_vector_init(&joysticks, sizeof(ALLEGRO_JOYSTICK_LINUX *));
    num_joysticks = 0;

    if (!(config_mutex = al_create_mutex())) {
        return false;
    }

    // Scan for joysticks
    ljoy_scan(false);
    ljoy_merge();

#ifdef SUPPORT_HOTPLUG
    if (!(hotplug_mutex = al_create_mutex())) {
        al_destroy_mutex(config_mutex);
        return false;
    }
    if (!(hotplug_cond = al_create_cond())) {
        al_destroy_mutex(config_mutex);
        al_destroy_mutex(hotplug_mutex);
        return false;
    }
    if (!(hotplug_thread = al_create_thread(hotplug_proc, NULL))) {
        al_destroy_mutex(config_mutex);
        al_destroy_mutex(hotplug_mutex);
        al_destroy_cond(hotplug_cond);
        return false;
    }

    al_start_thread(hotplug_thread);

    inotify_fd = inotify_init();
    if (inotify_fd != -1) {
        fcntl(inotify_fd, F_SETFL, O_NONBLOCK);
        /* Modern Linux probably only needs to monitor /dev/input. */
        inotify_add_watch(inotify_fd, "/dev/input", IN_CREATE|IN_DELETE);
        _al_unix_start_watching_fd(inotify_fd, ljoy_config_dev_changed, NULL);
        ALLEGRO_INFO("Hotplugging enabled\n");
    }
    else {
        ALLEGRO_WARN("Hotplugging not enabled\n");
        if (inotify_fd != -1) {
            close(inotify_fd);
            inotify_fd = -1;
        }
    }
#endif

    return true;
}
Пример #16
0
int _al_xglx_fullscreen_select_mode(ALLEGRO_SYSTEM_XGLX *s, int adapter, int w, int h, int format, int refresh_rate)
{
    int i;
    int n;

    if (!init_mmon_interface(s))
        return -1;

    if (adapter < 0)
        adapter = _al_xglx_get_default_adapter(s);

    n = _al_xglx_get_num_display_modes(s, adapter);
    if (!n)
        return -1;

    /* Find all modes with correct parameters. */
    ALLEGRO_DISPLAY_MODE mode = {0, 0, 0, 0};
    int possible_modes[n];
    int possible_count = 0;
    for (i = 0; i < n; i++) {
        if (!_al_xglx_get_display_mode(s, adapter, i, &mode)) {
            continue;
        }
        if (mode.width == w && mode.height == h &&
                (format == 0 || mode.format == format) &&
                (refresh_rate == 0 || mode.refresh_rate == refresh_rate))
        {
            possible_modes[possible_count++] = i;
        }
    }
    if (!possible_count)
        return -1;

    /* Choose mode with highest refresh rate. */
    int best_mode = possible_modes[0];
    _al_xglx_get_display_mode(s, adapter, best_mode, &mode);
    for (i = 1; i < possible_count; i++) {
        ALLEGRO_DISPLAY_MODE mode2;
        if (!_al_xglx_get_display_mode(s, adapter, possible_modes[i], &mode2))  {
            continue;
        }
        if (mode2.refresh_rate > mode.refresh_rate) {
            mode = mode2;
            best_mode = possible_modes[i];
        }
    }

    ALLEGRO_INFO("best mode [%d] = (%d, %d)\n", best_mode, mode.width, mode.height);

    return best_mode;
}
Пример #17
0
static void *gtk_thread_func(void *data)
{
   GAsyncQueue *queue = data;
   int argc = 0;
   char **argv = NULL;
   bool again;

   ALLEGRO_DEBUG("Calling gtk_init_check.\n");
   if (gtk_init_check(&argc, &argv)) {
      g_async_queue_push(queue, ACK_OK);
   }
   else {
      ALLEGRO_ERROR("GTK initialisation failed.\n");
      g_async_queue_push(queue, ACK_ERROR);
      return NULL;
   }

   do {
      ALLEGRO_INFO("Entering GTK main loop.\n");
      gtk_main();

      /* Re-enter the main loop if a new window was created soon after the last
       * one was destroyed, which caused us to drop out of the GTK main loop.
       */
      g_static_mutex_lock(&gtk_lock);
      if (window_counter == 0) {
         gtk_thread = NULL;
         again = false;
      } else {
         again = true;
      }
      g_static_mutex_unlock(&gtk_lock);
   } while (again);

   ALLEGRO_INFO("GTK stopped.\n");
   return NULL;
}
Пример #18
0
bool _al_win_init_touch_input_api(void)
{
   /* Reference counter will be negative if we already tried to initialize the driver.
    * Lack of touch input API is persistent state, so do not test for it again. */
   if (touch_input_api_reference_counter < 0)
      return false;

   /* Increase API reference counter if it is already initialized. */
   if (touch_input_api_reference_counter > 0)
   {
      touch_input_api_reference_counter++;
      return true;
   }

   /* Open handle to user32.dll. This one should be always present. */
   user32_module = _al_open_library("user32.dll");
   if (NULL == user32_module)
      return false;

   _al_win_close_touch_input_handle = (CLOSETOUCHINPUTHANDLEPROC)_al_import_symbol(user32_module, "CloseTouchInputHandle");
   _al_win_get_touch_input_info     = (GETTOUCHINPUTINFOPROC)    _al_import_symbol(user32_module, "GetTouchInputInfo");
   _al_win_is_touch_window          = (ISTOUCHWINDOWPROC)        _al_import_symbol(user32_module, "IsTouchWindow");
   _al_win_register_touch_window    = (REGISTERTOUCHWINDOWPROC)  _al_import_symbol(user32_module, "RegisterTouchWindow");
   _al_win_unregister_touch_window  = (UNREGISTERTOUCHWINDOWPROC)_al_import_symbol(user32_module, "UnregisterTouchWindow");

   if (NULL == _al_win_close_touch_input_handle || NULL == _al_win_get_touch_input_info  ||
       NULL == _al_win_is_touch_window          || NULL == _al_win_register_touch_window ||
       NULL == _al_win_unregister_touch_window) {

      _al_close_library(user32_module);

      _al_win_close_touch_input_handle = NULL;
      _al_win_get_touch_input_info     = NULL;
      _al_win_is_touch_window          = NULL;
      _al_win_register_touch_window    = NULL;
      _al_win_unregister_touch_window  = NULL;

      /* Mark as 'do not try this again'. */
      touch_input_api_reference_counter = -1;
	  ALLEGRO_WARN("failed loading the touch input API\n");
      return false;
   }

   /* Set initial reference count. */
   touch_input_api_reference_counter = 1;
   ALLEGRO_INFO("touch input API installed successfully\n");
   return true;
}
Пример #19
0
static void *nd_gtk_thread_func(void *data)
{
   GAsyncQueue *queue = data;

   ALLEGRO_DEBUG("GLIB %d.%d.%d\n",
      GLIB_MAJOR_VERSION,
      GLIB_MINOR_VERSION,
      GLIB_MICRO_VERSION);

   g_async_queue_push(queue, ACK_OK);

   gtk_main();

   ALLEGRO_INFO("GTK stopped.\n");
   return NULL;
}
Пример #20
0
static void display_pixel_format(ALLEGRO_EXTRA_DISPLAY_SETTINGS *eds)
{
   ALLEGRO_INFO("Accelarated: %s\n", eds->settings[ALLEGRO_RENDER_METHOD] ? "yes" : "no");
   ALLEGRO_INFO("Single-buffer: %s\n", eds->settings[ALLEGRO_SINGLE_BUFFER] ? "yes" : "no");
   if (eds->settings[ALLEGRO_SWAP_METHOD] > 0)
      ALLEGRO_INFO("Swap method: %s\n", eds->settings[ALLEGRO_SWAP_METHOD] == 2 ? "flip" : "copy");
   else
      ALLEGRO_INFO("Swap method: undefined\n");
   ALLEGRO_INFO("Color format: r%i g%i b%i a%i, %i bit\n",
      eds->settings[ALLEGRO_RED_SIZE],
      eds->settings[ALLEGRO_GREEN_SIZE],
      eds->settings[ALLEGRO_BLUE_SIZE],
      eds->settings[ALLEGRO_ALPHA_SIZE],
      eds->settings[ALLEGRO_COLOR_SIZE]);
   ALLEGRO_INFO("Depth buffer: %i bits\n", eds->settings[ALLEGRO_DEPTH_SIZE]);
   ALLEGRO_INFO("Sample buffers: %s\n", eds->settings[ALLEGRO_SAMPLE_BUFFERS] ? "yes" : "no");
   ALLEGRO_INFO("Samples: %i\n", eds->settings[ALLEGRO_SAMPLES]);
}
Пример #21
0
static ALLEGRO_DISPLAY *iphone_create_display(int w, int h)
{
    ALLEGRO_DISPLAY_IPHONE *d = al_calloc(1, sizeof *d);
    ALLEGRO_DISPLAY *display = (void*)d;
    ALLEGRO_OGL_EXTRAS *ogl = al_calloc(1, sizeof *ogl);
    display->ogl_extras = ogl;
    display->vt = _al_get_iphone_display_interface();
    display->flags = al_get_new_display_flags();
    if (display->flags & ALLEGRO_FULLSCREEN_WINDOW) {
        _al_iphone_get_screen_size(&w, &h);
    }
    display->w = w;
    display->h = h;

    ALLEGRO_SYSTEM_IPHONE *system = (void *)al_get_system_driver();

    /* Add ourself to the list of displays. */
    ALLEGRO_DISPLAY_IPHONE **add;
    add = _al_vector_alloc_back(&system->system.displays);
    *add = d;
    
    /* Each display is an event source. */
    _al_event_source_init(&display->es);

   _al_iphone_update_visuals();

   ALLEGRO_EXTRA_DISPLAY_SETTINGS *eds[system->visuals_count];
   memcpy(eds, system->visuals, sizeof(*eds) * system->visuals_count);
   qsort(eds, system->visuals_count, sizeof(*eds), _al_display_settings_sorter);

   ALLEGRO_INFO("Chose visual no. %i\n", eds[0]->index); 

   memcpy(&display->extra_settings, eds[0], sizeof(ALLEGRO_EXTRA_DISPLAY_SETTINGS));

   /* This will add an OpenGL view with an OpenGL context, then return. */
   _al_iphone_add_view(display);
   _al_iphone_make_view_current();

   _al_ogl_manage_extensions(display);
   _al_ogl_set_extensions(ogl->extension_api);
   setup_gl(display);
    
   display->flags |= ALLEGRO_OPENGL;

   return display;
}
Пример #22
0
static int pulseaudio_load_voice(ALLEGRO_VOICE *voice, const void *data)
{
   PULSEAUDIO_VOICE *pv = voice->extra;

   if (voice->attached_stream->loop == ALLEGRO_PLAYMODE_BIDIR) {
      ALLEGRO_INFO("Backwards playing not supported by the driver.\n");
      return 1;
   }

   voice->attached_stream->pos = 0;

   pv->buffer = voice->attached_stream->spl_data.buffer.ptr;
   pv->buffer_end = pv->buffer + (voice->attached_stream->spl_data.len) * pv->frame_size;

   return 0;
   (void)data;
}
Пример #23
0
/* Function: al_load_ogg_vorbis
 */
ALLEGRO_SAMPLE *al_load_ogg_vorbis(const char *filename)
{
   ALLEGRO_FILE *f;
   ALLEGRO_SAMPLE *spl;
   ASSERT(filename);
   
   ALLEGRO_INFO("Loading sample %s.\n", filename);
   f = al_fopen(filename, "rb");
   if (!f) {
      ALLEGRO_WARN("Failed reading %s.\n", filename);
      return NULL;
   }

   spl = al_load_ogg_vorbis_f(f);

   return spl;
}
Пример #24
0
/* Function: al_load_ogg_vorbis_audio_stream
 */
ALLEGRO_AUDIO_STREAM *al_load_ogg_vorbis_audio_stream(const char *filename,
	size_t buffer_count, unsigned int samples)
{
   ALLEGRO_FILE *f;
   ALLEGRO_AUDIO_STREAM *stream;
   ASSERT(filename);

   ALLEGRO_INFO("Loading stream %s.\n", filename);
   f = al_fopen(filename, "rb");
   if (!f) {
      ALLEGRO_WARN("Failed reading %s.\n", filename);
      return NULL;
   }

   stream = al_load_ogg_vorbis_audio_stream_f(f, buffer_count, samples);

   return stream;
}
static void xglx_shutdown_system(void)
{
   ALLEGRO_SYSTEM *s = al_get_system_driver();
   ALLEGRO_SYSTEM_XGLX *sx = (void *)s;

   ALLEGRO_INFO("shutting down.\n");

   if (sx->x11display) {
      /* Events thread only runs if we are connected to an X server. */
      _al_thread_join(&sx->thread);
   }

   /* Close all open displays. */
   while (_al_vector_size(&s->displays) > 0) {
      ALLEGRO_DISPLAY **dptr = _al_vector_ref(&s->displays, 0);
      ALLEGRO_DISPLAY *d = *dptr;
      _al_destroy_display_bitmaps(d);
      al_destroy_display(d);
   }
   _al_vector_free(&s->displays);

   // Makes sure we wait for any commands sent to the X server when destroying the displays.
   // Should make sure we don't shutdown before modes are restored.
   if (sx->x11display) {
      XSync(sx->x11display, False);
   }
   
   _al_xsys_mmon_exit(sx);

   if (sx->x11display) {
      XCloseDisplay(sx->x11display);
      sx->x11display = None;
      ALLEGRO_DEBUG("xsys: close x11display.\n");
   }

   if (sx->gfxdisplay) {
      /* XXX for some reason, crashes if both XCloseDisplay calls are made */
      /* XCloseDisplay(sx->gfxdisplay); */
      sx->gfxdisplay = None;
   }

   al_free(sx);
}
/* The open method starts up the driver and should lock the device, using the
   previously set paramters, or defaults. It shouldn't need to start sending
   audio data to the device yet, however. */
static int _dsound_open()
{
   HRESULT hr;

   ALLEGRO_DEBUG("Loading DirectSound module\n");

   /* load DirectSound module */
   _al_dsound_module = _al_open_library(_al_dsound_module_name);
   if (_al_dsound_module == NULL) {
      ALLEGRO_ERROR("Failed to open '%s' library\n", _al_dsound_module_name);
      return 1;
   }

   /* import DirectSound create proc */
   _al_dsound_create = (DIRECTSOUNDCREATE8PROC)_al_import_symbol(_al_dsound_module, "DirectSoundCreate8");
   if (_al_dsound_create == NULL) {
      ALLEGRO_ERROR("DirectSoundCreate8 not in %s\n", _al_dsound_module_name);
      _al_close_library(_al_dsound_module);
      return 1;
   }

   ALLEGRO_INFO("Starting DirectSound...\n");

   /* FIXME: Use default device until we have device enumeration */
   hr = _al_dsound_create(NULL, &device, NULL);
   if (FAILED(hr)) {
      ALLEGRO_ERROR("DirectSoundCreate8 failed\n");
      _al_close_library(_al_dsound_module);
      return 1;
   }

   ALLEGRO_DEBUG("DirectSoundCreate8 succeeded\n");

   /* FIXME: The window specified here is probably very wrong. NULL won't work either. */
   hr = device->SetCooperativeLevel(GetForegroundWindow(), DSSCL_PRIORITY);
   if (FAILED(hr)) {
      ALLEGRO_ERROR("SetCooperativeLevel failed\n");
      _al_close_library(_al_dsound_module);
      return 1;
   }

   return 0;
}
Пример #27
0
ALLEGRO_SAMPLE *_al_load_voc(const char *filename)
{
   ALLEGRO_FILE *f;
   ALLEGRO_SAMPLE *spl;
   ASSERT(filename);
   
   ALLEGRO_INFO("Loading VOC sample %s.\n", filename);
   f = al_fopen(filename, "rb");
   if (!f) {
      ALLEGRO_WARN("Failed reading %s.\n", filename);
      return NULL;
   }

   spl = _al_load_voc_f(f);

   al_fclose(f);

   return spl;
}
Пример #28
0
ALLEGRO_SAMPLE *_al_load_voc(const char *filename)
{
   ALLEGRO_FILE *f;
   ALLEGRO_SAMPLE *spl;
   ASSERT(filename);
   
   ALLEGRO_INFO("Loading VOC sample %s.\n", filename);
   f = al_fopen(filename, "rb");
   if (!f) {
      ALLEGRO_ERROR("Unable to open %s for reading.\n", filename);
      return NULL;
   }

   spl = _al_load_voc_f(f);

   al_fclose(f);

   return spl;
}
Пример #29
0
static int oss_load_voice(ALLEGRO_VOICE *voice, const void *data)
{
   OSS_VOICE *ex_data = voice->extra;

   /*
    * One way to support backward playing would be to do like alsa driver does:
    * mmap(2) the FD and write reversed samples into that. To much trouble for
    * an optional feature IMO. -- milan
    */
   if (voice->attached_stream->loop == ALLEGRO_PLAYMODE_BIDIR) {
      ALLEGRO_INFO("Backwards playing not supported by the driver.\n");
      return -1;
   }

   voice->attached_stream->pos = 0;
   ex_data->len = voice->attached_stream->spl_data.len >> MIXER_FRAC_SHIFT;

   return 0;
   (void)data;
}
Пример #30
0
static void xglx_shutdown_system(void)
{
   ALLEGRO_SYSTEM *s = al_get_system_driver();
   ALLEGRO_SYSTEM_XGLX *sx = (void *)s;

   ALLEGRO_INFO("shutting down.\n");

   if (sx->have_xevents_thread) {
      _al_thread_join(&sx->xevents_thread);
      sx->have_xevents_thread = false;
   }

   /* Close all open displays. */
   while (_al_vector_size(&s->displays) > 0) {
      ALLEGRO_DISPLAY **dptr = _al_vector_ref(&s->displays, 0);
      ALLEGRO_DISPLAY *d = *dptr;
      al_destroy_display(d);
   }
   _al_vector_free(&s->displays);

   // Makes sure we wait for any commands sent to the X server when destroying the displays.
   // Should make sure we don't shutdown before modes are restored.
   if (sx->x11display) {
      XSync(sx->x11display, False);
   }

   _al_xsys_mmon_exit(sx);

   if (sx->x11display) {
      XCloseDisplay(sx->x11display);
      sx->x11display = None;
      ALLEGRO_DEBUG("xsys: close x11display.\n");
   }

   if (sx->gfxdisplay) {
      XCloseDisplay(sx->gfxdisplay);
      sx->gfxdisplay = None;
   }

   al_free(sx);
}