[343] | 1 | //audiocd.c: |
---|
| 2 | |
---|
[688] | 3 | /* |
---|
[5961] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2014 |
---|
[688] | 5 | * |
---|
[4037] | 6 | * The code (may) include prototypes and comments (and maybe |
---|
| 7 | * other code fragements) from the yiff sound system. |
---|
| 8 | * According to the debian/copyright file upstream author is |
---|
| 9 | * Tara Milana <learfox@twu.net>. Also copyright is listed as: |
---|
| 10 | * Copyright (C) 1997-2003 WolfPack Entertainment |
---|
| 11 | * |
---|
[688] | 12 | * This file is part of libroaryiff a part of RoarAudio, |
---|
| 13 | * a cross-platform sound system for both, home and professional use. |
---|
| 14 | * See README for details. |
---|
| 15 | * |
---|
| 16 | * This file is free software; you can redistribute it and/or modify |
---|
| 17 | * it under the terms of the GNU General Public License version 3 |
---|
| 18 | * as published by the Free Software Foundation. |
---|
| 19 | * |
---|
| 20 | * libroaryiff is distributed in the hope that it will be useful, |
---|
| 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 23 | * GNU General Public License for more details. |
---|
| 24 | * |
---|
| 25 | * You should have received a copy of the GNU General Public License |
---|
| 26 | * along with this software; see the file COPYING. If not, write to |
---|
[3517] | 27 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 28 | * Boston, MA 02110-1301, USA. |
---|
[688] | 29 | * |
---|
[4037] | 30 | * NOTE: code fragments (like prototypes) taken from the yiff package |
---|
| 31 | * are 'GPLv2 or later' and are upgraded to GPLv3 by being used |
---|
| 32 | * within this document. |
---|
| 33 | * |
---|
[688] | 34 | */ |
---|
| 35 | |
---|
[343] | 36 | #include <libroaryiff.h> |
---|
| 37 | |
---|
[806] | 38 | struct { |
---|
[819] | 39 | int is_open; |
---|
| 40 | int is_playing; |
---|
| 41 | struct roar_cdrom cdrom[1]; |
---|
| 42 | } _g_roaryiff_cdrom = {0, 0, {}}; |
---|
[806] | 43 | |
---|
[343] | 44 | int YEjectAudioCD(YConnection *con) { |
---|
[806] | 45 | YStopAudioCD(con); |
---|
[343] | 46 | return system("eject") == 0 ? 0 : -1; |
---|
| 47 | } |
---|
| 48 | |
---|
[806] | 49 | int YPlayAudioCDTrack(YConnection *con, int track_number) { |
---|
| 50 | struct roar_connection rcon; |
---|
| 51 | |
---|
| 52 | if ( con == NULL ) |
---|
| 53 | return -1; |
---|
| 54 | |
---|
[1660] | 55 | roar_connect_fh(&rcon, con->fd); |
---|
[806] | 56 | |
---|
[819] | 57 | if ( ! _g_roaryiff_cdrom.is_open ) { |
---|
[5289] | 58 | if ( roar_cdrom_open(&rcon, _g_roaryiff_cdrom.cdrom, NULL, -1) == -1 ) |
---|
[806] | 59 | return -1; |
---|
| 60 | } |
---|
| 61 | |
---|
[819] | 62 | return roar_cdrom_play(_g_roaryiff_cdrom.cdrom, track_number); |
---|
[806] | 63 | } |
---|
| 64 | |
---|
| 65 | int YStopAudioCD(YConnection *con) { |
---|
| 66 | struct roar_connection rcon; |
---|
| 67 | |
---|
| 68 | if ( con == NULL ) |
---|
| 69 | return -1; |
---|
| 70 | |
---|
[1660] | 71 | roar_connect_fh(&rcon, con->fd); |
---|
[806] | 72 | |
---|
[819] | 73 | if ( _g_roaryiff_cdrom.is_playing ) { |
---|
| 74 | roar_cdrom_stop(_g_roaryiff_cdrom.cdrom); |
---|
| 75 | _g_roaryiff_cdrom.is_playing = 0; |
---|
[806] | 76 | } |
---|
| 77 | |
---|
[819] | 78 | if ( _g_roaryiff_cdrom.is_open ) { |
---|
| 79 | roar_cdrom_close(_g_roaryiff_cdrom.cdrom); |
---|
| 80 | _g_roaryiff_cdrom.is_open = 0; |
---|
[806] | 81 | } |
---|
| 82 | |
---|
| 83 | return 0; |
---|
| 84 | } |
---|
| 85 | |
---|
[343] | 86 | //ll |
---|