File indexing completed on 2024-04-21 04:54:20
0001 /* This file is part of the KDE project 0002 Copyright (C) 2006 Alexander Kern <alex.kern@gmx.de> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License version 2 as published by the Free Software Foundation. 0007 0008 This library is distributed in the hope that it will be useful, 0009 but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0011 Library General Public License for more details. 0012 0013 You should have received a copy of the GNU Library General Public License 0014 along with this library; see the file COPYING.LIB. If not, write to 0015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0016 Boston, MA 02110-1301, USA. 0017 0018 Linux digital audio functions. 0019 */ 0020 0021 #ifdef USE_ARTS 0022 0023 #include "audio.h" 0024 0025 #include <artsc.h> 0026 0027 arts_stream_t arts_stream = NULL; 0028 0029 int arts_open(void); 0030 int arts_close(void); 0031 int arts_stop(void); 0032 int arts_play(struct cdda_block *blk); 0033 int arts_state(struct cdda_block *blk); 0034 struct audio_oops* setup_arts(const char *dev, const char *ctl); 0035 0036 /* 0037 * Initialize the audio device. 0038 */ 0039 int 0040 arts_open(void) 0041 { 0042 int err; 0043 0044 DEBUGLOG("arts_open\n"); 0045 0046 if(!(arts_stream = arts_play_stream(44100, 16, 2, "cddaslave"))) { 0047 ERRORLOG("cannot open ARTS stream for playback\n"); 0048 return -1; 0049 } 0050 /* 1000 ms because we read 75 frames = 1 sec */ 0051 if((err = arts_stream_set(arts_stream, ARTS_P_BUFFER_TIME, 1000)) < 0) { 0052 ERRORLOG("arts_stream_set failed (%s)\n", arts_error_text(err)); 0053 return -1; 0054 } 0055 return 0; 0056 } 0057 0058 /* 0059 * Close the audio device. 0060 */ 0061 int 0062 arts_close(void) 0063 { 0064 arts_stop(); 0065 0066 DEBUGLOG("arts_close\n"); 0067 arts_close_stream(arts_stream); 0068 0069 arts_free(); 0070 0071 return 0; 0072 } 0073 0074 /* 0075 * Play some audio and pass a status message upstream, if applicable. 0076 * Returns 0 on success. 0077 */ 0078 int 0079 arts_play(struct cdda_block *blk) 0080 { 0081 int err; 0082 0083 if((err = arts_write(arts_stream, blk->buf, blk->buflen)) < 0) { 0084 ERRORLOG("arts_write failed (%s)\n", arts_error_text(err)); 0085 blk->status = WM_CDM_CDDAERROR; 0086 return -1; 0087 } 0088 0089 return 0; 0090 } 0091 0092 /* 0093 * Stop the audio immediately. 0094 */ 0095 int 0096 arts_stop(void) 0097 { 0098 DEBUGLOG("arts_stop\n"); 0099 0100 return 0; 0101 } 0102 0103 static struct audio_oops arts_oops = { 0104 .wmaudio_open = arts_open, 0105 .wmaudio_close = arts_close, 0106 .wmaudio_play = arts_play, 0107 .wmaudio_stop = arts_stop, 0108 .wmaudio_state = NULL, 0109 .wmaudio_balvol = NULL 0110 }; 0111 0112 struct audio_oops* 0113 setup_arts(const char *dev, const char *ctl) 0114 { 0115 int err; 0116 0117 if((err = arts_init())) { 0118 ERRORLOG("cannot initialize ARTS audio subsystem (%s)\n", arts_error_text(err)); 0119 return NULL; 0120 } 0121 0122 arts_open(); 0123 0124 return &arts_oops; 0125 } 0126 #endif