1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
/* sgi.c - SGI Audio Library output module
* Copyright (C) 1999 Michael Pruett <michael@68k.org>
*
* This file is part of AlsaPlayer.
*
* AlsaPlayer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* AlsaPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
* As an exception to the GPL-v3 licence, you are authorised to compile,
* link and distribute AlsaPlayer on a SGI system. See the COPYING file
* in the main AlsaPlayer directory.
*
*/
#include "config.h"
#include <stdio.h>
#include <dmedia/audio.h>
#include "output_plugin.h"
static ALport port = NULL;
static int sgi_init ()
{
port = alOpenPort("alsaplayer", "w", NULL);
if (port == NULL)
{
printf("alOpenPort failed!");
return 0;
}
return 1;
}
static int sgi_open (const char *device)
{
if (port != NULL)
return 1;
return 0;
}
static void sgi_close ()
{
return;
}
static int sgi_write (void *data, int count)
{
ALconfig config;
int blockSize, channelCount;
config = alGetConfig(port);
if (config == NULL)
{
printf("SGI: alGetConfig failed.\n");
return 0;
}
channelCount = alGetChannels(config);
blockSize = alGetWidth(config);
if (blockSize == 0 || channelCount == 0)
{
printf("SGI: bad configuration.\n");
return 0;
}
alWriteBlocks(port, data, count / (blockSize * channelCount));
return 1;
}
static int sgi_set_buffer(int *fragment_size, int *fragment_count, int *channels)
{
printf("SGI: fragments fixed at 256/256, stereo\n");
return 1;
}
static int sgi_set_sample_rate(int rate)
{
ALpv params;
int rv;
rv = alGetResource(port);
params.param = AL_RATE;
params.value.ll = (long long) rate << 32;
if (alSetParams(rv, ¶ms, 1) < 0)
{
printf("SGI: alSetParams failed: %s\n", alGetErrorString(oserror()));
return 0;
}
return rate;
}
static int sgi_get_latency ()
{
return ((256*256));
}
output_plugin sgi_output;
output_plugin *output_plugin_info(void)
{
memset(&sgi_output, 0, sizeof(output_plugin));
sgi_output.version = OUTPUT_PLUGIN_VERSION;
sgi_output.name = "SGI Audio Library output v1.0 (broken for mono output)";
sgi_output.author = "Michael Pruett";
sgi_output.init = sgi_init;
sgi_output.open = sgi_open;
sgi_output.close = sgi_close;
sgi_output.write = sgi_write;
sgi_output.set_buffer = sgi_set_buffer;
sgi_output.set_sample_rate = sgi_set_sample_rate;
sgi_output.get_latency = sgi_get_latency;
return &sgi_output;
}
|