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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
|
/* GSequencer - Advanced GTK Sequencer
* Copyright (C) 2005-2018 Joël Krähemann
*
* This file is part of GSequencer.
*
* GSequencer 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.
*
* GSequencer 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 GSequencer. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ags/audio/task/ags_set_device.h>
#include <ags/i18n.h>
void ags_set_device_class_init(AgsSetDeviceClass *set_device);
void ags_set_device_init(AgsSetDevice *set_device);
void ags_set_device_set_property(GObject *gobject,
guint prop_id,
const GValue *value,
GParamSpec *param_spec);
void ags_set_device_get_property(GObject *gobject,
guint prop_id,
GValue *value,
GParamSpec *param_spec);
void ags_set_device_dispose(GObject *gobject);
void ags_set_device_finalize(GObject *gobject);
void ags_set_device_launch(AgsTask *task);
/**
* SECTION:ags_set_device
* @short_description: set device
* @title: AgsSetDevice
* @section_id:
* @include: ags/audio/task/ags_set_device.h
*
* The #AgsSetDevice task sets device of #AgsSoundcard or #AgsSequencer.
*/
static gpointer ags_set_device_parent_class = NULL;
enum{
PROP_0,
PROP_SCOPE,
PROP_DEVICE,
};
GType
ags_set_device_get_type()
{
static gsize g_define_type_id__static = 0;
if(g_once_init_enter(&g_define_type_id__static)){
GType ags_type_set_device = 0;
static const GTypeInfo ags_set_device_info = {
sizeof(AgsSetDeviceClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) ags_set_device_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof(AgsSetDevice),
0, /* n_preallocs */
(GInstanceInitFunc) ags_set_device_init,
};
ags_type_set_device = g_type_register_static(AGS_TYPE_TASK,
"AgsSetDevice",
&ags_set_device_info,
0);
g_once_init_leave(&g_define_type_id__static, ags_type_set_device);
}
return(g_define_type_id__static);
}
void
ags_set_device_class_init(AgsSetDeviceClass *set_device)
{
GObjectClass *gobject;
AgsTaskClass *task;
GParamSpec *param_spec;
ags_set_device_parent_class = g_type_class_peek_parent(set_device);
/* gobject */
gobject = (GObjectClass *) set_device;
gobject->set_property = ags_set_device_set_property;
gobject->get_property = ags_set_device_get_property;
gobject->dispose = ags_set_device_dispose;
gobject->finalize = ags_set_device_finalize;
/* properties */
/**
* AgsSetDevice:scope:
*
* The assigned #AgsSoundcard or #AgsSequencer instance.
*
* Since: 3.0.0
*/
param_spec = g_param_spec_object("scope",
i18n_pspec("scope to set device"),
i18n_pspec("The scope to set device"),
G_TYPE_OBJECT,
G_PARAM_READABLE | G_PARAM_WRITABLE);
g_object_class_install_property(gobject,
PROP_SCOPE,
param_spec);
/**
* AgsSetDevice:device:
*
* The device to set.
*
* Since: 3.0.0
*/
param_spec = g_param_spec_string("device",
i18n_pspec("device"),
i18n_pspec("The device"),
NULL,
G_PARAM_READABLE | G_PARAM_WRITABLE);
g_object_class_install_property(gobject,
PROP_DEVICE,
param_spec);
/* task */
task = (AgsTaskClass *) set_device;
task->launch = ags_set_device_launch;
}
void
ags_set_device_init(AgsSetDevice *set_device)
{
set_device->scope = NULL;
set_device->device = NULL;
}
void
ags_set_device_set_property(GObject *gobject,
guint prop_id,
const GValue *value,
GParamSpec *param_spec)
{
AgsSetDevice *set_device;
set_device = AGS_SET_DEVICE(gobject);
switch(prop_id){
case PROP_SCOPE:
{
GObject *scope;
scope = (GObject *) g_value_get_object(value);
if(set_device->scope == (GObject *) scope){
return;
}
if(set_device->scope != NULL){
g_object_unref(set_device->scope);
}
if(scope != NULL){
g_object_ref(scope);
}
set_device->scope = (GObject *) scope;
}
break;
case PROP_DEVICE:
{
gchar *device;
device = g_value_get_string(value);
if(device == set_device->device){
return;
}
g_free(set_device->device);
set_device->device = g_strdup(device);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, param_spec);
break;
}
}
void
ags_set_device_get_property(GObject *gobject,
guint prop_id,
GValue *value,
GParamSpec *param_spec)
{
AgsSetDevice *set_device;
set_device = AGS_SET_DEVICE(gobject);
switch(prop_id){
case PROP_SCOPE:
{
g_value_set_object(value, set_device->scope);
}
break;
case PROP_DEVICE:
{
g_value_set_string(value, set_device->device);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, param_spec);
break;
}
}
void
ags_set_device_dispose(GObject *gobject)
{
AgsSetDevice *set_device;
set_device = AGS_SET_DEVICE(gobject);
if(set_device->scope != NULL){
g_object_unref(set_device->scope);
set_device->scope = NULL;
}
/* call parent */
G_OBJECT_CLASS(ags_set_device_parent_class)->dispose(gobject);
}
void
ags_set_device_finalize(GObject *gobject)
{
AgsSetDevice *set_device;
set_device = AGS_SET_DEVICE(gobject);
if(set_device->scope != NULL){
g_object_unref(set_device->scope);
}
g_free(set_device->device);
/* call parent */
G_OBJECT_CLASS(ags_set_device_parent_class)->finalize(gobject);
}
void
ags_set_device_launch(AgsTask *task)
{
AgsSetDevice *set_device;
set_device = AGS_SET_DEVICE(task);
/* set audio channels */
if(AGS_IS_SOUNDCARD(set_device->scope)){
ags_soundcard_set_device(AGS_SOUNDCARD(set_device->scope),
set_device->device);
}else if(AGS_IS_SEQUENCER(set_device->scope)){
ags_sequencer_set_device(AGS_SEQUENCER(set_device->scope),
set_device->device);
}
}
/**
* ags_set_device_new:
* @scope: the #AgsSoundcard or #AgsSequencer to reset
* @device: the device as string
*
* Create a new instance of #AgsSetDevice.
*
* Returns: the new #AgsSetDevice.
*
* Since: 3.0.0
*/
AgsSetDevice*
ags_set_device_new(GObject *scope, gchar *device)
{
AgsSetDevice *set_device;
set_device = (AgsSetDevice *) g_object_new(AGS_TYPE_SET_DEVICE,
"scope", scope,
"device", device,
NULL);
return(set_device);
}
|